Repository navigation
ci(fleet): posture-B floor — SAST + secret-scan #42
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Fleet-added (Apollo/greploop posture-B floor). NOT upstream — do not expect on NousResearch/hermes-agent. | ||
| # Provides the `sast` deterministic-floor component. Diff-aware where it helps, full-tree gate at ERROR. | ||
| name: Fleet SAST (semgrep) | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: fleet-sast-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| sast: | ||
| name: sast | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Install semgrep | ||
| run: pip install "semgrep==1.46.0" | ||
|
|
||
| - name: Run semgrep (ERROR severity gate) | ||
| run: | | ||
| semgrep \ | ||
| --config=p/python \ | ||
| --config=p/secrets \ | ||
| --severity=ERROR \ | ||
| --error \ | ||
| --quiet \ | ||
| hermes/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # Fleet-added (Apollo/greploop posture-B floor). NOT upstream — do not expect on NousResearch/hermes-agent. | ||
| # Provides the `secret_scan` deterministic-floor component. DIFF-SCOPED on PRs: scans only the PR | ||
| # commit range, NOT full history (the fork inherits ~768 generic-api-key false positives in upstream | ||
| # test fixtures/docs — a full-tree scan would pin this RED forever). On push to main, scans the push range. | ||
| name: Fleet Secret Scan (gitleaks) | ||
|
|
||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: fleet-secret-scan-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| secret_scan: | ||
| name: secret_scan | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout (full history for range scan) | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Compute scan range | ||
| id: range | ||
| run: | | ||
| if [ "${{ github.event_name }}" = "pull_request" ]; then | ||
| BASE="${{ github.event.pull_request.base.sha }}" | ||
| HEAD="${{ github.event.pull_request.head.sha }}" | ||
| else | ||
| BASE="${{ github.event.before }}" | ||
| HEAD="${{ github.sha }}" | ||
| fi | ||
| # Guard against the all-zero "before" SHA on first push / new branch. | ||
| if ! git cat-file -e "${BASE}^{commit}" 2>/dev/null; then | ||
| BASE="$(git rev-parse "${HEAD}~1" 2>/dev/null || echo "${HEAD}")" | ||
| fi | ||
| echo "base=${BASE}" >> "$GITHUB_OUTPUT" | ||
| echo "head=${HEAD}" >> "$GITHUB_OUTPUT" | ||
| echo "scanning ${BASE}..${HEAD}" | ||
|
Comment on lines
+40
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the push-to-main path hits a branch where |
||
|
|
||
| - name: Install gitleaks | ||
| run: | | ||
| VER=8.18.4 | ||
| curl -fsSL "https://github.com/gitleaks/gitleaks/releases/download/v${VER}/gitleaks_${VER}_linux_x64.tar.gz" -o gl.tgz | ||
| tar xzf gl.tgz gitleaks | ||
| sudo mv gitleaks /usr/local/bin/ | ||
|
Comment on lines
+47
to
+52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The gitleaks tarball is downloaded and immediately extracted and moved to |
||
|
|
||
| - name: Gitleaks (diff-scoped) | ||
| run: | | ||
| gitleaks detect \ | ||
| --source . \ | ||
| --no-banner \ | ||
| --redact \ | ||
| --log-opts="${{ steps.range.outputs.base }}..${{ steps.range.outputs.head }}" \ | ||
| --exit-code 1 | ||
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.
actions/checkout@v4andactions/setup-python@v5(same pattern infleet-secret-scan.yml) are pinned to floating tags rather than commit SHAs. A tag can be force-pushed to point at a different commit, meaning a compromised or accidental re-tag could silently alter what code runs in CI. Pinning to the full SHA (e.g.,actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683) provides a stable, tamper-evident reference.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!