Repository navigation
fix(config): devops config audit-keys scans each config file that the settings merge - #2516
Conversation
|
Test results for the head of this branch, after the rebase onto Targeted tests:
Fail-to-pass, An earlier fail-to-pass run, before the commits of task group 2, also exited 0. Both cases of |
259dbff to
926def0
Compare
|
Fix round 1: the The branch is rebased onto
|
926def0 to
058d821
Compare
|
Fix round 2: a merge conflict with
Results on the new head:
|
The audit of devops config audit-keys scans each config file that the settings merge, so a plaintext secret in the global config file fails the audit. Plans #2426
…global config file The settings merge the global config file and the project file. The test puts ai.api_key in the global file and a clean project file in DEVOPS_CLI_CONFIG, or in .devcontainer/config.yaml for the directory walk. It expects exit 1, the leak and both files in the report (#2426).
… settings merge The settings merge the global config file and the project config file. The audit scanned only the file of get_active_config_path(), which is the project file when one exists or DEVOPS_CLI_CONFIG is set. Thus a plaintext secret in the global file went into the settings, and the audit exited 0. config_layer_paths() in config/settings.py now gives the files that the settings merge, in the merge order. The load, the error of an unknown key and the audit get their files from it, so the audit scans each file that gives a value to the settings (#2426).
…at the audit scans The help names the global config file and the project config file that the settings merge, and config.yaml and .devops/config.yaml in the current directory. devops docs generate --sync-readme writes the same text into the generated documents (#2426).
…patch of CONFIG_PATH docs/TESTING.md does not let a test patch `CONFIG_PATH` or another devops-cli attribute. The test of #2426 now writes the secret into the real global config file, `CONST_CONFIG_PATH`, in the isolated HOME of the worker. The teardown removes the file and the config directory, so the worker-home tripwire finds no state that stays. The test fails on the source of origin/main and passes on this branch.
… loader cannot load unaudited The safe loader of PyYAML raises KeyError, AttributeError, IndexError or RecursionError for some files, and the message can quote the value. The settings load refuses these errors (#1468), but the scanner of the audit does not catch them. The audit then stops with the value in the output and in the log. This change reads the global config file in more cases (#2426), so the test puts each of these files there. The test fails in four of its six cases.
…loader that the settings load refuses The scanner of the audit caught only YAMLError, OSError and ValueError. A tagged value that the safe loader cannot build, such as `!!bool <text>`, raised KeyError, and the audit stopped with the value in the output and in the log. The scanner now catches `_YAML_LOAD_ERRORS` of the settings load (#1468) and logs only the file, the type of the error and its position, with `_yaml_error_location`. The audit reports the file unaudited, prints the full report and exits 1. The load and the audit use one rule for these errors. The scan of the keys is outside the `try` block, so the broad error types catch only the load of the file.
…s config file The audit now scans the global config file and the project config file, and both files have the name `config.yaml`. A leak that names only the file name does not tell which file holds the secret, and the table output does not show `scanned_config_files`. The tests now expect the full path of the file in each leak, in the table and in the JSON report.
…f its config file The audit scans the global config file and the project config file, and both files can have the name `config.yaml`. A leak named only the file name, so the alert of the table did not tell which file holds the secret. A leak is now `<path>:<section>.<key>`, with the resolved path that `scanned_config_files` also shows.
…s in the change 2426 design.md now names the third case where the audit and `get_active_config_path()` differ: a `..` segment in `DEVOPS_CLI_CONFIG`. It adds decision 4 (the scanner refuses `_YAML_LOAD_ERRORS`, which delivers the audit item of #2451) and decision 5 (a leak names the full path of its file). The spec delta has a requirement for each of these behaviors. tasks.md adds group 2 and names the follow-up issues #2511 and #2513. The long sentences of the proposal and the design are shorter, as ASD-STE100 asks.
… typed tuple, which mypy accepts in an except clause
…file whose document is a list
058d821 to
db27754
Compare
|
Fix round 3: the Two new tests in
The behavior does not change. Without the new tests, coverage of
|
🤖 I have created a release *beep* *boop* --- ## [0.11.1](v0.11.0...v0.11.1) (2026-10-28) ### Bug Fixes * **config:** devops config audit-keys scans each config file that the settings merge ([#2516](#2516)) ([57541df](57541df)) * **security:** the osv, internetdb, radar and cloudflare api clients dial through the egress-checked factory at the public level ([#2509](#2509)) ([0379f21](0379f21)) ### Code Refactoring * **k8s:** KubernetesService is the Kubernetes API seam, with a shared fake cluster and its contract suite ([#2527](#2527)) ([0f6b9af](0f6b9af)), closes [#1315](#1315) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
devops config audit-keysscans each config file that the settings merge: the global config file and the project config file. Before this change, the audit scanned onlyget_active_config_path(), which is the one file that a settings save writes. WhenDEVOPS_CLI_CONFIGwas set, or the directory walk found a project file, the audit did not scan the global file. A plaintext secret in the global file went into the settings, but the audit reported the config compliant and exited 0. The devcontainer always setsDEVOPS_CLI_CONFIG, so there the audit never read the global file.config_layer_paths()insrc/devops_cli/config/settings.pygives the global config file and the project config file.load_settingsreads the files of this function through_config_layers, andaudit_keys_cmdscans the same files. Thus the load and the audit use one rule for their files.config.yamland.devops/config.yamlin the current directory, as before._YAML_LOAD_ERRORS, fix(config): a config file that does not parse never prints its line from any command that loads settings #1468). It reports the file unaudited and quotes no text of the file. Before, a value such as!!bool <text>stopped the audit with aKeyErrorthat held the value.<path>:<section>.<key>. The global file and a project file can both have the nameconfig.yaml.config-commandsspec has three new requirements for these behaviors.Closes #2426
Change:
openspec/changes/archive/2026-10-28-2426-audit-keys-scans-global-config/