Use the hook to catch a leak before it enters history. Use CI to catch anything that gets past the hook.
GitHub Actions with SARIF#
name: secret scan
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
security-events: write
jobs:
mint-guard:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Scan for leaked secrets
run: npx --yes @xnah/mint guard scan --fail-on high --format sarif > mintguard.sarif
- name: Upload SARIF
if: always()
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: mintguard.sarif
category: mint-guardThe scan step returns 1 when a finding is at or above the threshold. The upload step still runs because of if: always(), so the findings appear in GitHub code scanning.
Pre-commit hook#
mint guard install-hook --fail-on high
mint guard uninstall-hookThe installed hook runs mint guard scan --staged --fail-on high against the index. If mint is not available, the hook warns and lets the commit through, so keep CI as the authoritative gate.
An existing hook is preserved. With --force, the guard block is added after the shebang; without it, the command explains that a hook already exists.
Any CI system#
npx --yes @xnah/mint guard scan --fail-on highFor SARIF:
npx --yes @xnah/mint guard scan --fail-on high --format sarif > mintguard.sarifFor a Markdown job summary:
npx --yes @xnah/mint guard scan --format markdown >> "$CI_SUMMARY_FILE"The scanner itself makes no network calls. npx needs network access only to fetch the package.
npm scripts#
{
"scripts": {
"secrets:scan": "mint guard scan --fail-on high",
"secrets:staged": "mint guard scan --staged --fail-on high",
"secrets:env": "mint guard env",
"secrets:baseline": "mint guard baseline"
}
}Then:
npm run secrets:scan
npm run secrets:stagedBaselines in a team#
If a repository already has reviewed findings, record a baseline:
mint guard baseline
git add .mintguard-baseline.json .mintguard.json .mintguardignore
git commit -m "chore: add mint guard baseline"The baseline contains salted hashes, never secrets. Later scans fail only on new findings.
Do not baseline a real credential instead of rotating it. The baseline is for accepted false positives or fixture data.
Suggested rollout#
- Run
mint guard scan --fail-on highlocally and fix the critical findings. - Add the GitHub Actions job with
--fail-on high. - Install the pre-commit hook.
- Move to
--fail-on mediumonce the backlog is clear. - Review
.mintguardignoreand disabled rules periodically. Every exclusion is a blind spot.
History#
A history scan can be slow on a large repository. Start with a date:
mint guard scan --history --since "30 days ago" --fail-on criticalHistory findings include the commit hash, author and date. The whole-file GCP service account rule is not applied in history mode because only added lines are available.