ci(#557): add CodeQL, Scorecard, dependency-review, Bandit/pip-audit gates#566
Conversation
|
Warning Review limit reached
More reviews will be available in 39 minutes and 39 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR adds four CI security workflows (CodeQL, Dependency Review, OpenSSF Scorecard, Security Scan) plus README badges. Three workflows use SHA-pinned reusable templates; the Security Scan workflow runs Bandit and pip-audit locally. ChangesSecurity and dependency scanning workflows
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/dependency-review.yml:
- Around line 22-24: The workflow currently uses advisory: true and
fail-on-severity: moderate but advisory:true does not cause PRs to be blocked;
either enable the repository Dependency Graph/security-advisories feature before
making this workflow a required branch-protection check, or do not add this
workflow to the required-check set yet; in short, ensure Dependency Graph is
enabled (so advisory + fail-on-severity: moderate can actually fail PRs) or keep
this workflow out of required checks until that prerequisite is met.
In @.github/workflows/security-scan.yml:
- Around line 22-23: The checkout steps leave the GITHUB_TOKEN in git config
which can be exfiltrated by repository-controlled install hooks (e.g., the
subsequent pip install -e .), so update both actions/checkout steps to disable
credential persistence by adding the input persist-credentials: false to each
checkout invocation (i.e., the steps using actions/checkout in this workflow) so
the token is not written to local git config before running repo-provided
build/install code.
- Around line 33-46: The pip-audit job is currently non-blocking because
continue-on-error: true; remove that setting or set continue-on-error: false for
the job named "pip-audit" so the workflow fails (and blocks merges) when
pip-audit detects vulnerabilities — update the pip-audit job definition (the job
with name "pip-audit" and the continue-on-error field) accordingly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 3cb22a9d-c3b3-4a87-a8c5-6a4a270aea0e
📒 Files selected for processing (5)
.github/workflows/codeql.yml.github/workflows/dependency-review.yml.github/workflows/scorecard.yml.github/workflows/security-scan.ymlREADME.md
| pip-audit: | ||
| name: pip-audit (advisory) | ||
| runs-on: ubuntu-latest | ||
| continue-on-error: true | ||
| steps: | ||
| - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | ||
| - uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | ||
| with: | ||
| python-version: "3.13" | ||
| - run: python -m pip install --upgrade pip pip-audit==2.9.0 | ||
| - name: Install project runtime deps so pip-audit sees them | ||
| run: python -m pip install -e . | ||
| - name: Audit installed dependencies for known CVEs | ||
| run: pip-audit |
There was a problem hiding this comment.
pip-audit findings won't block merges.
continue-on-error: true makes this job informational only, so a PR can still merge cleanly with known vulnerable runtime dependencies. That conflicts with the documented requirement for pip-audit to be part of the blocking security scan.
🧰 Tools
🪛 zizmor (1.25.2)
[warning] 38-38: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/security-scan.yml around lines 33 - 46, The pip-audit job
is currently non-blocking because continue-on-error: true; remove that setting
or set continue-on-error: false for the job named "pip-audit" so the workflow
fails (and blocks merges) when pip-audit detects vulnerabilities — update the
pip-audit job definition (the job with name "pip-audit" and the
continue-on-error field) accordingly.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/security-scan.yml:
- Around line 40-42: Replace the shell fallback "|| true" on the Bandit
invocation with Bandit's built-in exit-zero flag so tool failures still surface;
update the run command that currently calls `bandit -r . --exclude
'./tests,./dashboard,./docs,./mocks,./.claude' --skip B101 --severity-level
medium --confidence-level medium || true` to instead use `--exit-zero`
(preserving all existing flags and excludes) in the Bandit invocation so
findings return exit code 0 while actual execution errors still fail the step.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 414fd5a8-6bd9-405e-b5ca-8bee9b2ddf77
📒 Files selected for processing (1)
.github/workflows/security-scan.yml
| # `|| true` keeps this advisory (green-with-findings in the log) until | ||
| # #562 clears the B608 backlog; drop it to make Bandit blocking. | ||
| run: bandit -r . --exclude './tests,./dashboard,./docs,./mocks,./.claude' --skip B101 --severity-level medium --confidence-level medium || true |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Does Bandit's --exit-zerooption return success for findings while still allowing genuine execution errors to fail, and is it preferred over shell|| true in CI?
💡 Result:
Bandit's --exit-zero option is designed to make the tool exit with a status code of 0 even when security findings are detected [1][2]. It does not suppress genuine execution errors, such as configuration issues or file access problems; these will still result in a non-zero exit status [3][4]. Regarding its preference over shell idioms like || true in CI environments: 1. Consistency and Alignment: Using --exit-zero is generally considered the more idiomatic approach because it aligns Bandit with other common Python ecosystem tools (such as flake8 and Pylint) that provide the same flag [4]. This makes your configuration more portable and readable across different environments (local vs. CI) without relying on shell-specific behavior [4]. 2. Integration: The option was specifically implemented to facilitate CI integration where security reports need to be generated (e.g., for consumption by platforms like SonarQube) without blocking the entire pipeline [3][5]. While both methods achieve the same goal of preventing a pipeline failure due to security findings, --exit-zero is preferred as it is a built-in feature of the tool, whereas || true is an external shell bypass that may mask legitimate tool failures or behave inconsistently depending on the shell environment [4]. However, note that if the purpose of the CI job is to enforce security standards, you should generally avoid using --exit-zero and instead allow the pipeline to fail upon the discovery of vulnerabilities [5].
Citations:
- 1: https://bandit.readthedocs.io/en/latest/man/bandit.html?highlight=context+lines
- 2: https://bandit.readthedocs.io/en/latest/man/bandit.html
- 3: --exit-zero option PyCQA/bandit#510
- 4: --exit-zero option PyCQA/bandit#419
- 5: https://blog.devops.dev/step-by-step-guide-to-devsecops-ci-cd-pipeline-with-jenkins-part-9-python-security-scanning-d7bacb79770c
Replace shell || true with bandit --exit-zero
Bandit’s --exit-zero exits with status 0 when security findings are detected, but it does not hide genuine execution/tooling failures (e.g., misconfiguration or file access issues). Using shell || true masks both and weakens CI signal.
Suggested change
- # `|| true` keeps this advisory (green-with-findings in the log) until
- # `#562` clears the B608 backlog; drop it to make Bandit blocking.
- run: bandit -r . --exclude './tests,./dashboard,./docs,./mocks,./.claude' --skip B101 --severity-level medium --confidence-level medium || true
+ # `--exit-zero` keeps this advisory (findings don't fail the step) while
+ # still surfacing genuine execution/tooling failures.
+ run: bandit -r . --exclude './tests,./dashboard,./docs,./mocks,./.claude' --skip B101 --severity-level medium --confidence-level medium --exit-zero📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # `|| true` keeps this advisory (green-with-findings in the log) until | |
| # #562 clears the B608 backlog; drop it to make Bandit blocking. | |
| run: bandit -r . --exclude './tests,./dashboard,./docs,./mocks,./.claude' --skip B101 --severity-level medium --confidence-level medium || true | |
| # `--exit-zero` keeps this advisory (findings don't fail the step) while | |
| # still surfacing genuine execution/tooling failures. | |
| run: bandit -r . --exclude './tests,./dashboard,./docs,./mocks,./.claude' --skip B101 --severity-level medium --confidence-level medium --exit-zero |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/security-scan.yml around lines 40 - 42, Replace the shell
fallback "|| true" on the Bandit invocation with Bandit's built-in exit-zero
flag so tool failures still surface; update the run command that currently calls
`bandit -r . --exclude './tests,./dashboard,./docs,./mocks,./.claude' --skip
B101 --severity-level medium --confidence-level medium || true` to instead use
`--exit-zero` (preserving all existing flags and excludes) in the Bandit
invocation so findings return exit code 0 while actual execution errors still
fail the step.
…gates Security/governance CI gates for SOC 2 readiness (#557). Consumes the SHA-pinned reusable workflow_call templates published by BicameralAI/bicameral-integrations (pinned @b1b52b5d, 2026-06-08 main HEAD); vendors Bandit/pip-audit (no reusable; retargeted to mcp's flat layout, actions SHA-pinned per #544). - codeql.yml → _reusable-codeql (languages: python); push/PR main + weekly cron - scorecard.yml → _reusable-scorecard; push main + weekly cron (no public badge: publish_results=false) - dependency-review.yml → _reusable-dependency-review; PR-only, advisory:true until Dependency Graph confirmed - security-scan.yml → vendored Bandit (blocking) + pip-audit (advisory) - README: CodeQL + Security Scan status badges SBOM+attestation intentionally NOT added — already shipped in publish.yml (CycloneDX 1.5 + Cosign/Rekor). See docs/research-brief-557-ci-security-gates-2026-06-08.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…562 First Bandit pass on the full (never-scanned) mcp tree surfaces pre-existing findings — mostly Low-severity (try/except/pass, subprocess), plus the Medium B608 hardcoded-SQL sites in the ledger/CLI query paths that #562 remediates. Per the warn-not-obstruct gating doctrine, start advisory (continue-on-error) with Medium+ severity/confidence focus; drop continue-on-error once #562 clears the B608 backlog. Also exclude .claude tooling hooks from the scan. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
continue-on-error renders the check as a red 'fail' on the PR even though it's non-blocking — confusing on a SOC 2 evidence PR. Use '|| true' so the advisory scan reports findings in the log and the check is green; drop it to make Bandit blocking once #562 clears the B608 SQL-injection backlog. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
09f2aea to
6b79e9f
Compare
Closes #557.
What
Adds the security/governance CI gates for SOC 2 readiness, reconciled against what already exists.
codeql.yml— consumes_reusable-codeql.yml(languages: python); push/PRmain+ weekly cron.scorecard.yml— consumes_reusable-scorecard.yml; pushmain+ weekly cron.dependency-review.yml— consumes_reusable-dependency-review.yml; PR-only,advisory: true(see below).security-scan.yml— vendored Bandit (blocking) + pip-audit (advisory); no reusable exists and the scan targets differ for mcp's flat layout. Actions SHA-pinned per P1: Complete GitHub Actions SHA-pinning + dep lockfile (SOC2 CC8.1 / OWASP LLM05·A06 / SSDF PO.5) #544.The three consumed templates are the SHA-pinned
workflow_callreusables published byBicameralAI/bicameral-integrations, pinned@b1b52b5d1c37c8cfdd5f916a9558cbf019b66a6e(integrationsmainHEAD, 2026-06-08).Scope corrections (vs the issue)
publish.yml(CycloneDX 1.5 + Cosign/Rekor, release-integrated). Adding the SPDX reusable would duplicate a stronger existing gate.publish_results: false(org OIDC-publish policy); results upload to code-scanning as SARIF, but there is no public scorecard.dev badge to add.advisory: false+fail-on-severity: moderateonce Dependency Graph is confirmed on.Verify on first run
BicameralAI/bicameral-integrationsreusables; if org/visibility policy refuses cross-repoworkflow_call, they'llstartup_failureand I'll vendor the three callers instead.Refs
Summary by CodeRabbit