Skip to content

fix: stop flagging the commit hash in a GitHub link as a secret - #763

Merged
brendt merged 1 commit into
dev-null-sh:productionfrom
rohitsasi720:fix/secret-warning-commit-links
Oct 22, 2026
Merged

brendt merged 1 commit into
dev-null-sh:productionfrom
rohitsasi720:fix/secret-warning-commit-links

Conversation

@rohitsasi720

@rohitsasi720 rohitsasi720 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to @kachelle's comment on #600: sharing a GitHub commit link raises the "Possible secret detected" warning.

Problem

@sanity-labs/secret-scan's rule github_oauth2-2 matches any 40-character hex string once the text contains "github", with no entropy floor. Every commit hash is exactly that, so https://github.com/owner/repo/commit/<hash> (or a /blob/<hash>/…, /tree/<hash>, /pull/1/commits/<hash> link) is flagged as a GitHub OAuth secret, and the draft isn't stashed.

Fix

resources/js/lib/sensitive-text.ts skips a github_oauth2-2 match when it's a segment of a link's path: the text right before it, up to the last whitespace, is a host followed by a path ending in /. findSecrets, removeSecrets and stashableBody all apply it, so the warning, "remove secrets" and the stash agree.

Still flagged:

  • a hash written outside a link, e.g. "My GitHub client secret: ",
  • a hash in a link's query or fragment (?client_secret=<hash>),
  • a hash before the host (https://<hash>@github.com/…, https://user:<hash>@…),
  • a secret next to a commit link (only the link's hash is skipped).

No other rule changes. #600 edits the same file for the Docker username rules; whichever merges second needs a small rebase, and I'll do it.

Before and after

Before (production) After
image image

Tests

  • tests/Unit/SensitiveText.test.ts: commit and blob links pass through findSecrets, removeSecrets and stashableBody unchanged; a GitHub secret outside a link path, in a clone URL, and beside a commit link is still redacted. Both fail without the fix.
  • bun run test:lint, bun run test:types and bun run test:unit (103 tests) pass locally.
  • In Chrome with Playwright, typing into the composer: a post with a GitHub commit link shows no warning (it did before), and "My GitHub client secret is " still warns and selects the hash.

Once a post mentions GitHub, the scanner reads any 40-character hex
string as a GitHub OAuth secret, so sharing a commit link raised the
"possible secret" warning. A hash that's a segment of a link's path is
an address, so it's no longer flagged. A secret in a link's query or
before its host, or written outside a link, still is.
@brendt
brendt merged commit 68eeece into dev-null-sh:production Oct 22, 2026
6 checks passed
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.

2 participants