Repository navigation
FIX: Reject explicitly supplied --config-file paths that do not exist - #3767
Merged
Merged
Conversation
Roman Lutz (romanlutz)
approved these changes
Nov 1, 2026
Assert missing explicit config paths fail before the banner or shell is initialized, with and without a default config and with server/auth overrides. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #3706.
Problem
If you passed a
--config-filepath that doesn't exist, the CLI dropped it without saying anything and carried on with defaults. A typo could therefore leavepyrit_scanorpyrit_shellpointed at an unintended server or auth mode. For example,pyrit_scan list-targets --config-file /does/not/exist.yaml ...exited 0.Change
pyrit/cli/_config_reader.py: added a small_resolve_config_pathshelper.read_server_settings(and soread_server_url) andvalidate_client_confignow use it instead of each building the path list themselves.~/.pyrit/.pyrit_confis still optional.config_filethat doesn't exist now raisesConfigError("Config file <path> does not exist.").ConfigErrordocstring and theRaises:sections to match.Both
pyrit_scan.mainandpyrit_shell.mainalready callvalidate_client_configbefore doing anything else, and they already catchConfigError, printError: ...to stderr and return 1. The new error is reported the same way as the existing malformed-config error.Tests
tests/unit/cli/test_config_reader.py: the two tests that asserted a missing path is silently ignored now passconfig_file=None. They still check that a missing default file is fine. New tests check that a missing explicit config raises inread_server_url,read_server_settings(even when a valid default exists) andvalidate_client_config.tests/unit/cli/test_pyrit_scan.py: addedtest_main_missing_config_is_hard_error, modelled on the existing malformed-config test. It checks for exit code 1 and the message on stderr.tests/unit/cli/test_pyrit_shell.py:test_main_log_level_and_config_filepassed a path that didn't exist. It now creates that file first so the test still covers what it was meant to.I couldn't run the test suite in this environment, so these tests have not been run.
Fixes #3706
Happy to adjust anything or close it if it isn't a fit.