Skip to content

fix(config): redact a removed credential in the config copies - #2734

Merged
dan-petty merged 6 commits into
mainfrom
fix/2645-config-unset-removes-plaintext
Oct 30, 2026
Merged

dan-petty merged 6 commits into
mainfrom
fix/2645-config-unset-removes-plaintext

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

devops config unset <key> copied the config file to <name>.bak-<YYYYMMDD-HHMMSS> before it removed the key. For a plaintext credential, the copy kept the credential, with the mode of the file. devops config audit-keys does not scan the copies, so it reported no leak. The copies that earlier writes made held the credential too.

Now each copy of the file shows the value of a credential that the removal takes out as ***REDACTED***, with the key in place:

  • The new copy is written already redacted, through a temporary file and a replace. The older retained copies are redacted too. A removal of a section redacts each credential below it.
  • A comment line that holds the value loses its comment text. Every other line of a copy stays as it was, with its line ends. A copy keeps the mode of the file. The retention of 10 copies does not change.
  • A copy that is not UTF-8 text, is not YAML, or is not a YAML mapping stops the command with an error that names the copy and quotes no text. The command stops before the config file changes and makes no new copy.
  • The alert of devops config audit-keys no longer tells a person to delete the copy by hand.

The redaction uses the YAML round trip that devops-cli already has (round_trip.edit), so it adds no YAML code.

Change: openspec/changes/archive/2026-10-30-2645-config-unset-removes-plaintext/

Closes #2645

@dan-petty dan-petty added scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak labels Oct 30, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test results (targeted, after the rebase onto origin/main):

  • uv run devops ci test tests/config tests/commands/test_config.py tests/test_config_audit_keys.py tests/test_config_write_history.py tests/test_round_trip.py tests/test_openspec_gate.py: 65 passed.
  • uv run devops docs check and uv run devops openspec check: pass.

Fail-to-pass (uv run devops ci fail-to-pass --base origin/main): 11 tests fail on base, 50 pass. Summary of the output:

  failed on base: tests.config.test_config_key_removal::test_a_removal_of_a_section_redacts_each_credential_in_it (AssertionError: assert '# devops-cli...lue-grafana\n' == '# devops-cli...lue-grafana\n')
  failed on base: tests.config.test_config_key_removal::test_a_removal_of_a_credential_leaves_no_file_that_holds_its_value (AssertionError: assert ['config.yaml...61024-233005'] == [])
  failed on base: tests.config.test_config_key_removal::test_a_removal_of_a_credential_stops_when_a_copy_is_not_a_yaml_mapping[text-line] (Failed: DID NOT RAISE ConfigurationError)
  failed on base: tests.config.test_config_key_removal::test_a_removal_of_a_credential_drops_each_comment_that_holds_its_value (AssertionError: assert 'FAKE-2645-value' not in 'ai:\n  # th...# keep too\n')
  failed on base: tests.config.test_config_key_removal::test_a_removal_of_a_credential_stops_when_a_copy_is_not_a_yaml_mapping[list] (Failed: DID NOT RAISE ConfigurationError)
  failed on base: tests.config.test_config_key_removal::test_a_removal_of_a_credential_keeps_the_line_ends_of_each_copy (assert (b'# devops-c...ery task\r\n') == (b"# devops-c...ery task\r\n"))
  failed on base: tests.config.test_config_key_removal::test_a_removal_of_a_credential_stops_when_a_copy_is_not_a_yaml_mapping[not-utf-8] (Failed: DID NOT RAISE ConfigurationError)
  failed on base: tests.config.test_config_key_removal::test_a_removal_of_a_credential_redacts_it_in_each_copy_that_an_earlier_write_made (AssertionError: assert ['config.yaml...-000007', ...] == [])
  failed on base: tests.config.test_config_key_removal::test_a_removal_of_a_credential_stops_when_a_copy_is_not_yaml_and_changes_nothing (Failed: DID NOT RAISE ConfigurationError)
  failed on base: tests.commands.test_config::test_config_unset_of_a_credential_leaves_no_file_that_holds_its_value (AssertionError: assert ['config.yaml...61024-233005'] == [])
  failed on base: tests.test_config_audit_keys::test_config_audit_keys_alert_says_to_quote_the_values_and_names_no_copy_to_delete (AssertionError: assert '.bak-' not in 'Security Al...opy by hand.')
11 failed on base (11 failed and 50 passed in tests/commands/test_config.py, tests/config/test_config_key_removal.py, tests/test_config_audit_keys.py; 0 errored).
Elapsed: 14s

@dan-petty
dan-petty marked this pull request as ready for review October 30, 2026 01:36
@dan-petty
dan-petty merged commit f663344 into main Oct 30, 2026
18 checks passed
@dan-petty
dan-petty deleted the fix/2645-config-unset-removes-plaintext branch October 30, 2026 01:36
dan-petty pushed a commit that referenced this pull request Oct 30, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.21.4](v0.21.3...v0.21.4)
(2026-10-30)


### Bug Fixes

* **ai:** name each prewarm server by host and port
([#2737](#2737))
([2e2e4fa](2e2e4fa)),
closes [#2676](#2676)
* **ai:** the mcp benchmark tool takes no file path
([#2738](#2738))
([5d5da15](5d5da15)),
closes [#2704](#2704)
* **config:** redact a removed credential in the config copies
([#2734](#2734))
([f663344](f663344)),
closes [#2645](#2645)
* **rag:** name the Qdrant server by host and port
([#2733](#2733))
([39aca9d](39aca9d)),
closes [#2709](#2709)
* **roadmap:** tick turn and kept diff for implement steps
([#2744](#2744))
([890d2a6](890d2a6)),
closes [#2721](#2721)
* **security:** refuse the gh and kubectl keys that run a program
([#2732](#2732))
([ad0bdf1](ad0bdf1)),
closes [#2672](#2672)
* **security:** refuse the keys that make a child write a file
([#2746](#2746))
([1cd187e](1cd187e)),
closes [#2674](#2674)

---
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(config): devops config unset leaves the plaintext secret that it removes in its .bak copy

1 participant