Keep the token out of the debug output - #20
Merged
Merged
Conversation
--debug prints the whole options object, the token included, and it is the first thing anyone turns on when a run misbehaves in CI. A build log is not a private place to keep a credential that can write to the repository, so the value is replaced with a marker. That a token was resolved is what the output is useful for; which one it is is not. The filter beside it compared each [key, value] entry against the string "debug" and so never matched, which is why --debug reported itself. It is the same expression and now destructures the key. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
--debugprints the whole options object, andtokenis one of the options, so thecredential is written to stdout in full:
--debugis the first thing anyone turns on when a run misbehaves, and a run thatmisbehaves is usually one in CI. A build log is not a private place to keep a token that
can write to the repository.
The fix
Report that the token is set, not what it is:
Token: <hidden>. Every other option isstill printed, since that is what the output is for.
_outputOptionsis the only place inlib/that prints the token.One line beyond the strict fix, flagged for review: the filter in the same expression
compared each
[key, value]entry against the string"debug", so it never matched and--debugreported itself. It now destructures the key. Happy to split this out if youwould rather keep the PR to the redaction alone.
Verification
The test was written first and failed for the reported reason
(
expected '\nOptions: \nTags: all\nPrefix: empty…' to not include 'ghp_averysecrettoken').Real run of
gren changelog --generate --override --debugagainst this repository,writing to a scratch file, counting occurrences of the actual
GREN_GITHUB_TOKENvalue inthe output:
The 28 vs 29 is the
Debug:line the filter now removes.npm test132 passing;env -u GREN_GITHUB_TOKEN npx mocha93 passing, 39 pending;npm run lintclean apart from the pre-existingmocha/no-pending-testswarning intest/Gren.spec.js.Worth doing separately
Any token that has been through a
--debugrun in a shared log should be rotated. Thischange stops new leaks; it cannot recall old ones.
🤖 Generated with Claude Code