Repository navigation
fix(security): upgrade secret scanning from retired trufflehog to gitleaks #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,66 +1,22 @@ | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
| # // Copyright (c) Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk> | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
| name: Secret Scanner | ||
| # Calls the estate's shared secret scanner (gitleaks + rust-secrets + | ||
| # shell-secrets). Replaces an inline trufflehog job: trufflehog was retired | ||
| # estate-wide as redundant, and this repo had no other leak scanning, so the | ||
| # scanner is UPGRADED here rather than removed. | ||
| # | ||
| # `secrets: inherit` is REQUIRED — without it the gitleaks action's inner | ||
| # secrets.GITHUB_TOKEN is empty and the scan silently degrades. | ||
| name: 'Secret Scanner' | ||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: [main] | ||
| # Estate guardrail: cancel superseded runs so re-pushes / rebased PR | ||
| # updates do not pile up queued runs against the shared account-wide | ||
| # Actions concurrency pool. Applied only to read-only check workflows | ||
| # (no publish/mutation), so cancelling a superseded run is always safe. | ||
| branches: [main, master] | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| permissions: | ||
| actions: read | ||
| contents: read | ||
| jobs: | ||
| trufflehog: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4 | ||
| with: | ||
| fetch-depth: 0 # Full history for scanning | ||
| - name: TruffleHog Secret Scan | ||
| uses: trufflesecurity/trufflehog@6c05c4a00b91aa542267d8e32a8254774799d68d # v3 | ||
| with: | ||
| # The v3 action injects --fail automatically on pull_request events. | ||
| # Passing --fail here triggers "flag 'fail' cannot be repeated". | ||
| extra_args: --only-verified | ||
| # Rust-specific: Check for hardcoded crypto values | ||
| rust-secrets: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 15 | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4 | ||
| - name: Check for hardcoded secrets in Rust | ||
| run: | | ||
| if ! find . -name Cargo.toml -not -path './target/*' -print -quit | grep -q .; then | ||
| echo 'No Cargo.toml found — skipping Rust secrets check' | ||
| exit 0 | ||
| fi | ||
| # Patterns that suggest hardcoded secrets | ||
| PATTERNS=( | ||
| 'const.*SECRET.*=.*"' | ||
| 'const.*KEY.*=.*"[a-zA-Z0-9]{16,}"' | ||
| 'const.*TOKEN.*=.*"' | ||
| 'let.*api_key.*=.*"' | ||
| 'HMAC.*"[a-fA-F0-9]{32,}"' | ||
| 'password.*=.*"[^"]+"' | ||
| ) | ||
|
|
||
| found=0 | ||
| for pattern in "${PATTERNS[@]}"; do | ||
| if grep -rn --include="*.rs" -E "$pattern" src/; then | ||
| echo "WARNING: Potential hardcoded secret found matching: $pattern" | ||
| found=1 | ||
| fi | ||
| done | ||
|
|
||
| if [ $found -eq 1 ]; then | ||
| echo "::error::Potential hardcoded secrets detected. Use environment variables instead." | ||
| exit 1 | ||
| fi | ||
| scan: | ||
| uses: hyperpolymath/standards/.github/workflows/secret-scanner-reusable.yml@bd0df9ead7faf0cdfe0e13e7966d91e28d0101d4 | ||
| secrets: inherit | ||
|
Check warning on line 22 in .github/workflows/secret-scanner.yml
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Bug: Caller permissions may under-grant the reusable scanner
The caller now grants only
contents: read(the previousactions: readwas dropped) and calls the reusablesecret-scanner-reusable.yml. Reusable-workflow jobs cannot exceed the caller'spermissions, so if the gitleaks/rust-secrets/shell-secrets jobs require more (e.g.security-events: writeto upload SARIF, oractions: read), those steps will be denied or silently degrade — the exact quiet-failure mode this PR aims to eliminate. Confirm the reusable workflow's required scopes and mirror them in this caller'spermissions:block.Was this helpful? React with 👍 / 👎