Skip to content

fix(security): a credential value is masked also when the next line starts with a parenthesis - #2477

Merged
dan-petty merged 5 commits into
mainfrom
fix/2471-call-check-one-line
Oct 28, 2026
Merged

dan-petty merged 5 commits into
mainfrom
fix/2471-call-check-one-line

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

redact_text did not mask a credential value when the line after it started with (. The api_key rule (for api_key, access_token, bearer_token and auth_token) ends an unquoted value with a call check, so that it does not mask a call such as api_key=settings_mod.get_ai_api_key(st). The check was (?!\s*\(). In Python, \s also matches a line break, so the check read past the end of the line. When the next line, or a line after blank lines, started with (, the check stopped the match, and the value stayed in clear text. #2450 limited the other keyword-to-value patterns to one line, but kept this check as it was.

The check is now (?![^\S\r\n]*\(). A ( on the same line, also after a space or a tab, continues to mark a call. A line break ends the check, so the next line does not change the result. The spec of secret-masking gets a new requirement: the text after a line break does not change how the line before it is masked.

The review of #2450 also found gaps in its tests. These tests now hold each whitespace class of the keyword-to-value rules:

  • Each of the password, token, aws_secret_access_key, client_secret and api_key rules gets a pair with the line break between the keyword and its separator, and the secret_ rule gets a pair with the line break after token.
  • The one-line test compares the whole masked text, and joins each pair with a space, a tab or a no-break space.
  • A Hypothesis property shows that the line after a credential line never changes the result for that line. Explicit examples hold the ( lines.

On main, the tests passed when sanitizer.py had one of these classes back as \s, each [^\S\r\n] changed to [ ] or [ \t], or no call check. Each of these changes to sanitizer.py now makes tests fail.

Closes #2471

Change: openspec/changes/archive/2026-10-28-2471-call-check-one-line/

…dential value

The call check after an unquoted api_key value was (?!\s*\(). Its \s
crossed a line break, so a line that started with ( stopped the match
and the value stayed in clear text. The check now allows only
whitespace that is not a line break before the (.

Refs #2471
…value rules

Each keyword-to-value rule gets a pair with the line break between the
keyword and its separator. The one-line test compares the whole masked
text, with a space, a tab or a no-break space between the parts.

Refs #2471
@dan-petty

Copy link
Copy Markdown
Owner Author

Fail-to-pass: https://github.com/dan-petty/devops-cli/actions/runs/40739345252/job/122996385947. On the merge base, 7 changed tests fail: the 6 cases of test_a_parenthesis_on_the_next_line_does_not_unmask_a_credential with a ( on a later line, and the property test_the_next_line_never_changes_how_a_credential_line_is_masked.

This pull request continues the review of #2461, which merged before the review findings were done. The findings and their results:

  1. The call check (?!\s*\() crossed a line break: reproduced on main, fixed in sanitizer.py, with failing tests first.
  2. Six whitespace classes before a separator, and the token alternative of the secret_ rule, had no test: reproduced (each change back to \s passed all 136 tests of the three sanitizer test files). Each change now fails 4 tests.
  3. No test used a tab or a no-break space: reproduced (each [^\S\r\n] changed to [ ] passed all tests). That change now fails 56 tests, and [ \t] fails 28.
  4. The one-line test did not compare whole values: reproduced by reading the test. It now compares the whole masked text, so a change to the replacement text of the password rule fails 18 tests, not 6.

@dan-petty
dan-petty marked this pull request as ready for review October 28, 2026 18:00
@dan-petty
dan-petty merged commit ece25ca into main Oct 28, 2026
17 checks passed
@dan-petty
dan-petty deleted the fix/2471-call-check-one-line branch October 28, 2026 18:00
dan-petty pushed a commit that referenced this pull request Oct 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.10.0](v0.9.0...v0.10.0)
(2026-10-28)


### Features

* **review:** devops review intake hands the findings of a session on
merged code to roadmap intake
([#2455](#2455))
([a5c7b82](a5c7b82))
* **security:** devops k8s audit runs Popeye in the tool sandbox with a
kube-api network profile that only reads the API server
([#2467](#2467))
([e02c3fb](e02c3fb))
* **security:** the App's installation tokens carry only the permissions
the roadmap jobs use
([#2482](#2482))
([9599ef2](9599ef2)),
closes [#2473](#2473)


### Bug Fixes

* **config:** a config file that is not valid YAML stops the load with
an error that quotes none of its text
([#2468](#2468))
([91fe5dc](91fe5dc))
* **config:** config set reports an unknown key as unknown, not as a key
that needs a value
([#2465](#2465))
([8b650a6](8b650a6))
* **devcontainer:** run the checkout's devops in devcontainer terminals
([#2460](#2460))
([abd2d41](abd2d41))
* **k8s:** loki runs from the grafana-community chart on loki 3.7.9, out
of reach of CVE-2026-21729
([#2470](#2470))
([96c50c9](96c50c9))
* **security:** a credential keyword at the end of a line no longer
masks the first word of the next line
([#2461](#2461))
([b754a73](b754a73))
* **security:** a credential value is masked also when the next line
starts with a parenthesis
([#2477](#2477))
([ece25ca](ece25ca)),
closes [#2471](#2471)
* **security:** pin kubeconform and replace Checkov with Trivy's
misconfiguration scan
([#2464](#2464))
([960e357](960e357))
* **security:** refuse GCONV_PATH, SHELLOPTS, BASHOPTS and PS4 from a
caller, and archive the merged security changes
([#2453](#2453))
([1f9231d](1f9231d))


### Code Refactoring

* **ai:** chat_structured is the one structured-output path
([#2452](#2452))
([3509732](3509732))
* **github:** pr check-readiness reads one merge-readiness verdict from
github/ ([#2456](#2456))
([16442c4](16442c4))

---
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(security): a credential value is masked also when the next line starts with a parenthesis

1 participant