Repository navigation
Description
Problem Description
redact_text in src/devops_cli/security/sanitizer.py does not mask a credential value when the line after it starts with (. The api_key, access_token, bearer_token and auth_token rule ends with the call check (?!\s*\(). In Python, \s also matches a line break. Thus, the check reads past the end of the line, and the first character of the next line (or of a later line, after blank lines) decides the result for the current line. When that character is (, the rule does not match, and the secret stays in clear text.
The requirement "A credential keyword and its value sit on one line" of the secret-masking spec says that the value comes only from the same line. #2450 changed the other keyword-to-value patterns, but kept this check as it was.
The review of #2461 also found gaps in the tests of #2450:
- No test puts a line break between a keyword and its separator, such as
passwordon one line and: <value>on the next line. Each of the five rules forpassword,token,aws_secret_access_key,client_secretandapi_keycan go back to\sbefore the separator, and all tests still pass. The same is true for the\btokenalternative of thesecret_rule. - No test joins a one-line pair with a tab or a no-break space. If each
[^\S\r\n]becomes[ ], all tests still pass, butpassword:followed by a no-break space and a value is no longer masked. - The one-line test does not compare the whole result with an expected value (docs/TESTING.md). A change to the replacement text of a rule still passes.
Reproduction Steps
- Run
uv run python -c 'from devops_cli.security.sanitizer import redact_text; print(repr(redact_text("api_key: " + "Zq8xW2mN" * 3 + "\n(rotated monthly)")))'. - Run the same command with
"\nrotated monthly"in place of"\n(rotated monthly)".
Expected vs Actual Behavior
Expected: the two commands give api_key=<masked-api-key> on the first line, and keep the second line unchanged.
Actual: step 2 masks the value. Step 1 returns the input unchanged, with the 24-character value in clear text. The same occurs with access_token= and two line breaks before (next paragraph), in data and code syntax.
Environment Diagnostics
- DevOps CLI version: 0.9.0 (main at 8b650a6)
- Python version: 3.14
- OS: Linux x86_64
- Execution environment: DevContainer
Pre-Submission Checklist
- I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
- I have checked existing issues and pull requests to ensure this is not a duplicate.
Source: #2461
Activity
dan-petty commentedon Oct 28, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
A credential value is left unmasked in output, which is a security gap.A real credential leak, but only when the next line starts with a parenthesis.Prevents a narrow but real credential leak in masked output.A single regex lookahead needs to stop at line boundaries instead of matching \s.Both fix line-break leakage in the same sanitizer regex, but #2450 fixed the keyword-to-value separator and this fixes the negative lookahead after the value.fix(security): a credential value is masked also when the next line s…
chore(main): release 0.10.0 (#2463)