Repository navigation
fix(config): resolve config paths from CWD in CLI and sandbox them in the API - #102
Merged
Merged
Conversation
… improved error reporting
…OCAL for consistent path handling
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.
Summary
Fixes config file path handling across CLI, API and service layers.
Defects fixed
~/.ciberwebscaninstead of the working directory.config load examples/profiles/bugbounty.yaml,config export backup.yamland--config rel.yamlfailed or wrote into the global config base instead of the CWD.save(None)with an explicitconfig_pathcould diverge from the loader and produced a rawIsADirectoryErrorfor directory destinations.path_policywas compared by identity without normalization:ConfigService(path_policy="config_dir")silently activated theLOCALbranch and escaped the~/.ciberwebscansandbox.docs/API.mddocumented wrong request contracts (updates,file_path,section) that returned 422 in practice.Changes
ConfigServicegainsPathPolicy(CONFIG_DIRsandbox for the API,LOCALCWD-based for the CLI); the constructor normalizesPathPolicy | strviaPathPolicy(path_policy)and raisesValueErrorfor unknown values (never a silent fallback toLOCAL).config_pathis normalized once (~, absolute) so loader andsave()always target the same file; directory destinations fail with a clearCONFIG_SAVE_ERROR.~is expanded before containment inCONFIG_DIR;.yaml/.yml/.jsonenforced in both policies; empty/null-byte/drive-relative paths rejected.validate_file_pathreports normalized absolute paths (missing file exits2, service failures exit1).docs/API.md(realpath/value/savecontracts, response shapes, API path sandbox section),docs/CLI.mdanddocs/CONFIGURATION.md(CWD path resolution rules).No changes to
utils/path_security.py, the CodeQL model, or API route handlers (they still constructConfigService()bare).Tests
New regression suites:
tests/unit/services/test_config_path_policy.py— policies,save(None)contract, LOCAL rules,path_policynormalization (enum/strings/invalid values)tests/unit/cli/test_config_cli_paths.py— CWD resolution,~, exit codestests/unit/api/routes/test_config_path_policies.py— sandbox,~, auth, request/response contracts, bare constructor, symlink escapeValidation
uv run pytest→ 1589 passed, 3 skipped (before the finalpath_policynormalization commit)uv run pytest tests/unit/services/test_config_path_policy.py tests/unit/api/routes/test_config_path_policies.py→ 40 passed, 1 skipped (after it)uv run ruff check .→ clean;uv run ruff format --check→ cleanuv run pyright→ 0 errors, 0 warningsuv run pre-commit run --all-files→ all hooks pass (prettier reformat of release-pleaseCHANGELOG.mdis pre-existing and was reverted to keep the diff scoped)Notes / limitations
C:file.yaml) are rejected only under theLOCALpolicy.