Security Scan workflow (outsourc-e/hermes-workspace)
The Security Scan workflow from outsourc-e/hermes-workspace, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Security Scan workflow from the outsourc-e/hermes-workspace repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
# Phase 2.5-001: Secrets scanning CI
# Scans for leaked secrets on PR and push to main
name: Security Scan
on:
push:
branches: [main, production]
pull_request:
branches: [main, production]
permissions:
contents: read
security-events: write
jobs:
secrets-scan:
name: Scan for Secrets
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run Gitleaks
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# No additional secrets required - uses built-in GITHUB_TOKEN
- name: Grep for common patterns (fallback)
if: always()
run: |
echo "π Scanning for common secret patterns..."
# Patterns that indicate secrets
PATTERNS=(
"sk-[a-zA-Z0-9]{20,}"
"sk-ant-"
"ghp_[a-zA-Z0-9]{36}"
"github_pat_"
"gho_[a-zA-Z0-9]{36}"
"PRIVATE KEY"
"-----BEGIN RSA"
"-----BEGIN OPENSSH"
)
FOUND=0
for pattern in "${PATTERNS[@]}"; do
if grep -rE "$pattern" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.json" --include="*.env*" . 2>/dev/null \
| grep -v node_modules \
| grep -v ".lock" \
| grep -v dist \
| grep -v "test-redaction" \
| grep -v "diagnostics.ts" \
| grep -v "placeholder" \
| grep -v "# pragma: allowlist secret" \
| grep -v "example\|sample\|fake\|dummy\|test\|mock" ; then
echo "β οΈ Potential secret found matching: $pattern"
FOUND=1
fi
done
if [ $FOUND -eq 1 ]; then
echo "β Potential secrets detected! Please review and remove."
exit 1
fi
echo "β
No obvious secret patterns found"
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
# Phase 2.5-001: Secrets scanning CI # Scans for leaked secrets on PR and push to main name: Security Scan on: push: branches: [main, production] pull_request: branches: [main, production] permissions: contents: read security-events: write concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: secrets-scan: timeout-minutes: 30 name: Scan for Secrets runs-on: latchkey-small steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - name: Run Gitleaks uses: gitleaks/gitleaks-action@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # No additional secrets required - uses built-in GITHUB_TOKEN - name: Grep for common patterns (fallback) if: always() run: | echo "π Scanning for common secret patterns..." # Patterns that indicate secrets PATTERNS=( "sk-[a-zA-Z0-9]{20,}" "sk-ant-" "ghp_[a-zA-Z0-9]{36}" "github_pat_" "gho_[a-zA-Z0-9]{36}" "PRIVATE KEY" "-----BEGIN RSA" "-----BEGIN OPENSSH" ) FOUND=0 for pattern in "${PATTERNS[@]}"; do if grep -rE "$pattern" --include="*.ts" --include="*.tsx" --include="*.js" --include="*.json" --include="*.env*" . 2>/dev/null \ | grep -v node_modules \ | grep -v ".lock" \ | grep -v dist \ | grep -v "test-redaction" \ | grep -v "diagnostics.ts" \ | grep -v "placeholder" \ | grep -v "# pragma: allowlist secret" \ | grep -v "example\|sample\|fake\|dummy\|test\|mock" ; then echo "β οΈ Potential secret found matching: $pattern" FOUND=1 fi done if [ $FOUND -eq 1 ]; then echo "β Potential secrets detected! Please review and remove." exit 1 fi echo "β No obvious secret patterns found"
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.