Skip to content

fix(github): keep a quote mark that the mask did not open - #3691

Merged
dan-petty merged 4 commits into
mainfrom
fix/2569-mask-keeps-json-quote
Nov 5, 2026
Merged

dan-petty merged 4 commits into
mainfrom
fix/2569-mask-keeps-json-quote

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

devops gh api printed a JSON reply that no parser could read. The masks for token, password, client_secret and aws_secret_access_key took the quote mark that closes a JSON string, together with a secret in a URL query.

A rule now takes a closing quote mark only after a quote mark of the same kind. The value of the token and password rules also ends before an escaped quote mark, and a double backslash stays whole. So the mask never leaves a quote mark with no escape.

A value in a pair of quote marks is still masked with the pair. A value with an opening quote mark and no closing one is still masked.

Closes #2569

Change: openspec/changes/archive/2026-11-05-2569-mask-keeps-json-quote/
Elapsed: 8.21s

Plans #2569. The change folder holds the proposal, the design, the spec delta and the tasks.
A credential rule took the quote mark after a value even when no quote mark opened the value. A secret in the query of a URL inside a JSON string lost the quote that closes the string, and devops gh api printed text that is not JSON. The rules for token, password, client_secret and aws_secret_access_key now take a closing quote mark only after a quote mark of the same kind.
The value of the token and password rules held the backslash of a JSON escape. A secret before an escaped quote mark lost the backslash, and the quote mark then ended the string early. The value now ends before a backslash that starts an escaped quote mark, and a double backslash stays whole.

The tests of the first fix now fake gh at the process edge and cover the escaped quote mark. The text of the change folder uses sentences of at most 25 words.
@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/github GitHub Projects v2, Views, Milestones, Labels, and PR automation labels Nov 5, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Test results

fail-to-pass (uv run devops ci fail-to-pass --base origin/main): 26 tests fail on the base and pass on the head. The run covers tests/commands/test_gh_cmd.py, tests/security/test_redaction_properties.py and tests/security/test_secret_redaction.py. 335 other tests pass on both.

Narrow runs on the rebased head: tests/security, tests/commands/test_gh_cmd.py and tests/invariants give 2069 passed. ruff check, ruff format, mypy on sanitizer.py and devops openspec check pass.

Full uv run devops ci on the head before the archive commit: every row passes except pytest & coverage. It gives 19059 passed, 4 failed and 1 error, and coverage is 94.53% of 85%. The four failures and the one error are the host-state tests of #3585 (a stale /tmp/config.yaml, the devcontainer tool and popeye installed on this host). They fail the same way on origin/main, and this change does not touch them. The evidence is in a comment on #3585.

Review findings fixed

  • Major, the escaped quote mark. The finding is right. The first fix of the closing quote mark left a value that took the backslash of \", so the quote mark stayed with no escape. A run on {"a":"curl \"https://x/f?token=abcdefgh12345678\"","b":1} gave invalid JSON. The value of the token and password rules now ends before \" and \', and a double backslash stays whole. The tests test_the_escaped_quote_after_a_secret_in_a_json_string_stays_escaped and test_a_double_backslash_at_the_end_of_a_secret_in_a_json_string_is_one_character hold it. The property now also writes " and \ after the secret. On the first fix, 7 of those cases failed. The rules for client_secret and aws_secret_access_key have no backslash in the value class, so they need no change.
  • Minor, the test double. The finding is right. The devops gh api test now fakes gh at the process edge and patches no devops-cli function.
  • Minor, the sentence length. The finding is right. The change folder and the helper docstring now use sentences of at most 25 words (20 in a task).

Outside this item

  • A JSON-escaped double-quoted value, such as {"body":"export token=\"abcdefgh1234\" now"}, is not masked at all. The secret stays in the text. The value rule needs 8 characters before the backslash. This is not new, and a separate issue is worth filing.
  • ?token=<value>&page=2 masks &page=2 too, because the value class includes &. The rule fails closed and the JSON stays valid.

@dan-petty
dan-petty marked this pull request as ready for review November 5, 2026 20:02
@dan-petty
dan-petty merged commit ed91c67 into main Nov 5, 2026
23 checks passed
@dan-petty
dan-petty deleted the fix/2569-mask-keeps-json-quote branch November 5, 2026 20:03
dan-petty pushed a commit that referenced this pull request Nov 5, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.63.2](v0.63.1...v0.63.2)
(2026-11-05)


### Bug Fixes

* **github:** keep a quote mark that the mask did not open
([#3691](#3691))
([ed91c67](ed91c67))

---
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/github GitHub Projects v2, Views, Milestones, Labels, and PR automation type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(github): devops gh api masks a token in a JSON reply together with the closing quote, so the output is not valid JSON

1 participant