Merge pull request #695 from PR0M3TH3AN/codex/define-safe_special_chars-constant

Add SAFE_SPECIAL_CHARS constant usage
This commit is contained in:
thePR0M3TH3AN
2025-07-31 08:50:24 -04:00
committed by GitHub
4 changed files with 18 additions and 3 deletions

View File

@@ -239,7 +239,7 @@ seedpass entry get "email"
# Sort or filter the list view
seedpass list --sort label
seedpass list --filter totp
# Generate a password with the safe character set
# Generate a password with the safe character set defined by `SAFE_SPECIAL_CHARS`
seedpass util generate-password --length 20 --special-mode safe --exclude-ambiguous
# Use the **Settings** menu to configure an extra backup directory

View File

@@ -109,7 +109,7 @@ Each entry is stored within `seedpass_entries_db.json.enc` under the `entries` d
- **min_special** (`integer`, default `2`): Minimum required special characters.
- **include_special_chars** (`boolean`, default `true`): Enable or disable any punctuation in generated passwords.
- **allowed_special_chars** (`string`, optional): Restrict punctuation to this exact set.
- **special_mode** (`string`, default `"standard"`): Choose `"safe"` for the `!@#$%^*-_+=?` set, otherwise the full `string.punctuation` is used.
- **special_mode** (`string`, default `"standard"`): Choose `"safe"` for the `SAFE_SPECIAL_CHARS` set (`!@#$%^*-_+=?`), otherwise the full `string.punctuation` is used.
- **exclude_ambiguous** (`boolean`, default `false`): Omit confusing characters like `O0Il1`.
Example:

View File

@@ -42,7 +42,12 @@ except ModuleNotFoundError: # pragma: no cover - fallback for removed module
from local_bip85.bip85 import BIP85
from constants import DEFAULT_PASSWORD_LENGTH, MIN_PASSWORD_LENGTH, MAX_PASSWORD_LENGTH
from constants import (
DEFAULT_PASSWORD_LENGTH,
MIN_PASSWORD_LENGTH,
MAX_PASSWORD_LENGTH,
SAFE_SPECIAL_CHARS,
)
from .encryption import EncryptionManager
# Instantiate the logger

View File

@@ -4,6 +4,8 @@ import sys
sys.path.append(str(Path(__file__).resolve().parents[1]))
from constants import SAFE_SPECIAL_CHARS
from seedpass.core.password_generation import PasswordGenerator, PasswordPolicy
@@ -47,3 +49,11 @@ def test_exclude_ambiguous_chars():
pw = pg.generate_password(length=32, index=2)
for ch in "O0Il1":
assert ch not in pw
def test_safe_special_chars_mode():
policy = PasswordPolicy(special_mode="safe")
pg = make_generator(policy)
pw = pg.generate_password(length=32, index=3)
specials = [c for c in pw if c in string.punctuation]
assert specials and all(c in SAFE_SPECIAL_CHARS for c in specials)