Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ For random passwords, displayed entropy is `log₂` of the exact number of valid
- Random choices use Python's `secrets` module.
- Passphrases default to six independently selected EFF words (about 77.5 bits).
- The web interface returns generated values only to the current page and does not write them to history.
- CLI history is written only when `--save-history` is supplied or the interactive save prompt is confirmed.
- CLI history is written only when `--save-history` is supplied or the interactive save prompt is confirmed with `Yes`, `yes`, `y`, or `Y`; `No`, `no`, `N`, `n`, and an empty response decline.
- History and exports receive owner-only permissions on POSIX systems.
- Custom wordlists are constrained to PassGen's local wordlist directory.

Expand Down
9 changes: 3 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,12 +667,9 @@ def _run_once() -> bool:
if args.copy:
copy_flag = True
if not save_history:
save_history = (
console.input(
"[info]Save to local plaintext history? [y/N]: [/info]"
).lower()
== "y"
)
save_history = console.input(
"[info]Save to local plaintext history? [y/N]: [/info]"
).strip().lower() in {"y", "yes"}
else:
passphrase_mode = args.passphrase
length = args.length
Expand Down
10 changes: 6 additions & 4 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,9 @@ def test_interactive_export_with_no_history_returns_to_menu(
assert "No passwords to export" in output
assert "Goodbye" in output

@pytest.mark.parametrize("save_response", ["Yes", "yes", "y", "Y"])
def test_interactive_generation_can_opt_in_to_history(
self, monkeypatch, tmp_path
self, monkeypatch, tmp_path, save_response
):
self.configure_paths(monkeypatch, tmp_path)
monkeypatch.setattr(main_module, "password_history", main_module.PasswordHistory())
Expand All @@ -520,7 +521,7 @@ def test_interactive_generation_can_opt_in_to_history(
"1",
"wifi",
"n",
"y",
save_response,
"q",
]
)
Expand All @@ -532,8 +533,9 @@ def test_interactive_generation_can_opt_in_to_history(
assert len(stored) == 1
assert stored[0]["category"] == "wifi"

@pytest.mark.parametrize("save_response", ["No", "no", "N", "n"])
def test_interactive_generation_does_not_save_when_prompt_is_declined(
self, monkeypatch, tmp_path
self, monkeypatch, tmp_path, save_response
):
self.configure_paths(monkeypatch, tmp_path)
monkeypatch.setattr(main_module, "password_history", main_module.PasswordHistory())
Expand All @@ -551,7 +553,7 @@ def test_interactive_generation_does_not_save_when_prompt_is_declined(
"1",
"",
"n",
"n",
save_response,
"q",
]
)
Expand Down
Loading