Repository navigation
Add public-exposure-check workflow (gitleaks + commit metadata) - #1
Conversation
Required-workflow candidate for public repos: fails a PR on a secret (gitleaks, built-in rules forced on, base-branch config, inline allow comments ignored) or a corporate email in commit author, committer or message. Non-noreply addresses are warnings only. Refs INFOSEC-652 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| python3 -I - <<'PY' | ||
| import os, re, subprocess, sys | ||
| base, head = os.environ["BASE_SHA"], os.environ["HEAD_SHA"] | ||
| corp = re.compile(r"(?i)[a-z0-9._%+-]*@([a-z0-9-]+\.)*(sandboxaq|sandboxquantum)\.com") |
There was a problem hiding this comment.
@paul-abb Would it make sense to also filter the contractor domain(s)?
There was a problem hiding this comment.
Good call. Done in the latest commit: the check now treats sbt-ext.com (contractors) and sandbox-quantum.com (release bots) as corporate alongside sandboxaq.com/sandboxquantum.com, so they fail like other company addresses; personal domains stay warnings. Controls: contractor author, bot co-author and corporate author fail; Gmail and a look-alike (notsbt-ext.com) warn; noreply passes. Outside switch (excluded), no commit in the last 90 days would newly fail. The same change is in the weekly monitor (sbt-secops#283).
Adds sbt-ext.com (contractor accounts) and sandbox-quantum.com (release bots) to the corporate-email pattern alongside sandboxaq.com and sandboxquantum.com, as suggested in review. Outside switch, which is excluded, no commit in the last 90 days would newly fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Annotations without a file land on the workflow file, which a required workflow shows as '.github'. Prefer a file the commit changed that is in the PR diff, so the error shows in Files changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks. All three addressed, with test evidence: Not at root: ran it end to end as a ruleset-required workflow in a throwaway private repo (org ruleset with a
Runner: switched to Budget: runs took 7–14 s. Standard hosted runners are free and unlimited on public repos, and the ruleset only targets public repos (switch excluded). The in-scope repos had ~44 pushes to PRs in the last 30 days. Full history is cheap: the largest in-scope repo clones in ~1 s, and even switch (3,881 commits) clones in ~3 s. I also anchored the commit-metadata annotations to a file the offending commit changed, so they show in Files changed instead of on the workflow file. All cases above were re-run on the latest commit ( |
… hide files from gitleaks
What does this PR change?
Adds
.github/workflows/public-exposure-check.yml, a PR check meant to be required on every publicsandbox-quantumrepo through an org rulesetworkflowsrule. This repo is public because GitHub only lets public repos call or require public workflows.What specific problem does this PR solve?
Commits to public repos can carry secrets or corporate email addresses. Once pushed to a public PR they're exposed for good, because
refs/pull/*is permanent. The org "Email filter" rulesets refuse non-noreply authors on pushes to org repos, but commits in a fork PR are never pushed here, so they're only caught at merge, with a terse error, and the rulesets never look for secrets. This check gives every PR author, fork or not, early and clear feedback on both.Without this change, a leaked token in a public PR is only caught by GitHub push protection (provider tokens only) or a later sweep.
How does this PR solve it?
On
pull_requestandmerge_group, withcontents: readonly and no secrets:base..headwith built-in rules forced on. The config and ignore list are read from the base branch, so a PR can't allowlist its own leak. The PR's.gitleaksignoreis removed and inlinegitleaks:allowcomments are ignored. A malformed base config fails with a clear error naming the file.@sandboxaq.com,@sandboxquantum.com,@sandbox-quantum.comor@sbt-ext.com, any subdomain) in author, committer or message (includingCo-authored-by/Signed-off-by) fails. It's the same pattern the Email filter ruleset enforces at merge, so it adds no new rejections. A non-noreply address is a warning.GIT_ATTR_SOURCE), so a PR can't add a.gitattributesentry such as*.ipynb -diffthat makes git report files as binary and hides them from gitleaks.Actions are pinned by SHA. gitleaks is checksum-verified. Untrusted PR data only reaches scripts through
env:, and scanner output is wrapped in a random stop-commands token.Rollout (org admin, after merge): add an org ruleset
workflowsrule targetingvisibility:publicand excludingemail-privacy-exempt(soswitchis out, matching the Email filter ruleset). Start in evaluate mode, then switch to active. Pin theworkflowsrule to a commit SHA of this file rather thanmain(or add apull_requestrule to this repo), because once it's required, a direct push tomainhere changes code that runs on every public repo's PRs.Known limits: a secret introduced only while resolving a merge conflict (merge commits have no diff in
git log -p) or stored through LFS isn't scanned, which is a gitleaks limitation. Retargeting a PR's base branch doesn't re-run the check, and GitHub doesn't run it on PRs with merge conflicts; the weekly public-repo monitor (sbt-secops#283) covers both gaps.Testing
Co-authored-by: fail;.gitleaks.tomlto allowlist its own token: still fails;gitleaks:allow: still fails;.gitleaks.toml: clear error;::error::injection in filenames and emails: escaped.gitleaks:allowbypass, malformed-config traceback, unusedworkflow_call).05112ccscanned4963d13..05112cc(4 commits) onubuntu-slimwith 0 findings..gitattributesbypass (found in a second adversarial review, 2026-10-29): reproduced with gitleaks 8.30.1 and this workflow's flags; with*.ipynb -diffthe token in a notebook was missed, and withGIT_ATTR_SOURCEset to the empty tree it was found. Also confirmed with plaingit log -pon git 2.56. No in-scope public repo has a.gitattributestoday.actions/checkout3d3c42eis tag v7.0.1, and the gitleaks v8.30.1 SHA256 matches GitHub's asset digest.Tracking: INFOSEC-652 (parent INFOSEC-647).
🤖 Generated with Claude Code