Skip to content

feat: implement issue #355 — Compliance: secret_scanning_ai_detection#435

Merged
don-petry merged 29 commits into
mainfrom
dev-lead/issue-355-20260610-1424
Jun 15, 2026
Merged

feat: implement issue #355 — Compliance: secret_scanning_ai_detection#435
don-petry merged 29 commits into
mainfrom
dev-lead/issue-355-20260610-1424

Conversation

@don-petry

@don-petry don-petry commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Closes #355

Implemented by dev-lead agent. Please review.

Summary by CodeRabbit

Release Notes

  • New Features

    • Monitoring expanded to include AI-based secret detection and non-provider pattern detection.
  • Improvements

    • Security settings now verified post-application with detailed status reporting for mismatches.
    • Audit logic enhanced to better suppress findings for unavailable settings.
  • Tests

    • Added test suite for security settings verification logic.

Copilot AI review requested due to automatic review settings June 10, 2026 14:34
@don-petry don-petry requested a review from a team as a code owner June 10, 2026 14:34
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@don-petry, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 10 minutes and 7 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ba74d2d4-631b-4988-b9d7-24648833eba3

📥 Commits

Reviewing files that changed from the base of the PR and between 7f1746e and 5882f65.

📒 Files selected for processing (1)
  • scripts/lib/push-protection.sh
📝 Walkthrough

Walkthrough

Two new warning-severity entries (secret_scanning_ai_detection and secret_scanning_non_provider_patterns) are added to PP_REQUIRED_SA_SETTINGS. The apply function now re-fetches and verifies post-PATCH state, emitting warnings for unresolved keys. The audit function skips matching settings and suppresses null-status findings for plan-gated warnings. A new Bats test suite and shared helper file cover all check behaviors.

Changes

Push-protection security_and_analysis enforcement

Layer / File(s) Summary
Required settings list and audit check logic
scripts/lib/push-protection.sh
Appends secret_scanning_ai_detection:enabled and secret_scanning_non_provider_patterns:enabled (both warning-severity) to PP_REQUIRED_SA_SETTINGS. Refines the pp_check_security_and_analysis audit loop to skip findings when actual equals expected and to suppress findings for warning-severity settings when the API reports null status.
Post-PATCH apply verification
scripts/lib/push-protection.sh
Replaces the single success log line in pp_apply_security_and_analysis with a re-fetch of security_and_analysis and a per-key verification loop that warns on unresolved keys and confirms verified keys as ok.
Test helpers and Bats test suite
test/scripts/lib/helpers/setup.bash, test/scripts/lib/push-protection.bats
Introduces setup.bash exporting TT_REPO_ROOT, TT_SCRIPTS_LIB_DIR, tt_make_tmpdir, and tt_cleanup_tmpdir. Adds a full Bats suite for pp_check_security_and_analysis with a stubbed gh_api, a findings log, and tests covering all severity/plan-gating combinations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • petry-projects/.github#422: Directly coupled — adds remediation logic to PATCH security_and_analysis.secret_scanning_non_provider_patterns, the same setting added as a warning-severity entry in this PR.
  • petry-projects/.github#224: Modifies pp_apply_security_and_analysis and pp_check_security_and_analysis in the same file to change how findings are produced when security_and_analysis data is missing or partially applicable.
  • petry-projects/.github#134: Updates the same push-protection apply/check logic around security_and_analysis secret-scanning flags, including AI detection and non-provider patterns enforcement.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 36.36% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly addresses issue #355 by naming the specific compliance feature (secret_scanning_ai_detection) being implemented, which aligns with the main objective of enabling this feature.
Linked Issues check ✅ Passed The implementation successfully adds secret_scanning_ai_detection to the required settings list, updates the audit logic to handle warning-severity flags appropriately, and includes comprehensive test coverage validating the new behavior.
Out of Scope Changes check ✅ Passed All changes are directly related to the compliance requirement: adding secret_scanning_ai_detection support, creating test infrastructure, and updating audit/apply logic. No extraneous modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dev-lead/issue-355-20260610-1424

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates scripts/lib/push-protection.sh to add detailed explanations for required security settings and introduces a verification step to confirm that settings are successfully applied after a PATCH request. The review feedback recommends optimizing this verification step by parsing the JSON response once into an associative array, which avoids spawning multiple jq processes in a loop and improves execution speed.

Comment thread scripts/lib/push-protection.sh Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the push-protection compliance library to add additional context around certain security_and_analysis settings (notably secret_scanning_ai_detection and secret_scanning_non_provider_patterns) and to verify whether a successful PATCH actually resulted in the desired state.

Changes:

  • Expanded the audit/apply “human detail” messages for AI detection and non-provider patterns to include plan/feature-availability caveats.
  • Added a post-PATCH re-fetch step in pp_apply_security_and_analysis() to warn when settings remain non-compliant after the API call is accepted.

Comment thread scripts/lib/push-protection.sh
Comment thread scripts/lib/push-protection.sh
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (applied)

Changes committed and pushed.

@don-petry don-petry enabled auto-merge (squash) June 10, 2026 14:50
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 10, 2026
@don-petry don-petry disabled auto-merge June 10, 2026 14:55
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (applied)

Changes committed and pushed.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 10, 2026
@sonarqubecloud

Copy link
Copy Markdown

@don-petry don-petry disabled auto-merge June 10, 2026 15:19
…al repos

gh release download uses GITHUB_TOKEN which is repo-scoped and returns
401 Unauthorized when downloading releases from external repos (gitleaks/gitleaks).
Replace with a direct curl call which works for public release assets
without authentication. Update standards/push-protection.md template to match.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (applied)

Changes committed and pushed.

@don-petry don-petry disabled auto-merge June 11, 2026 12:16
@don-petry don-petry enabled auto-merge (squash) June 11, 2026 12:21
@don-petry don-petry disabled auto-merge June 11, 2026 12:23
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-bot-comment (applied)

Changes committed and pushed.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (applied)

Changes committed and pushed.

@don-petry don-petry enabled auto-merge (squash) June 14, 2026 11:19
@don-petry don-petry disabled auto-merge June 14, 2026 11:19
@don-petry don-petry enabled auto-merge (squash) June 14, 2026 11:22
@don-petry don-petry disabled auto-merge June 14, 2026 11:22
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
   - Logs when settings remain non-compliant after PATCH due to org plan limitations
2. **Plan-gated key null suppression**: ✅ Fixed
   - Lines 205–227: Restricted null-value suppression to only keys in `PP_PLAN_GATED_KEYS`
   - `dependabot_security_updates` now properly generates findings for non-plan-gated repos
   - Tests at lines 143–150 validate this behavior
**Files changed:** 
- `scripts/lib/push-protection.sh`
**Skipped:** 0 (no informational-only issues)
---
**Result:** The PR is clean. All identified issues have been addressed by the commits in this branch. No additional changes needed.

@don-petry don-petry enabled auto-merge (squash) June 14, 2026 11:24
@don-petry don-petry disabled auto-merge June 15, 2026 11:36
@don-petry don-petry enabled auto-merge (squash) June 15, 2026 11:40
@don-petry don-petry disabled auto-merge June 15, 2026 11:41
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-bot-comment (no-changes)

Agent reasoning
### Details
All issues from automated reviews have been resolved:
1. **CodeRabbit findings** (both marked resolved/outdated):
   - `warn` function call issue → Fixed by using `info` (line 149)
   - Null suppression too broad → Fixed by `PP_PLAN_GATED_KEYS` logic (lines 52-56, 215-224)
2. **Copilot-pull-request-reviewer open thread**: The reviewer questioned whether the check logic was updated to treat plan-unavailable features as non-actionable. I confirmed the fix is in place:
   - `PP_PLAN_GATED_KEYS` array defines keys requiring plan upgrades (lines 52-56)
   - Check function skips findings for plan-gated keys with null status (lines 222-224)
   - Thread resolved ✓
**PR Status:** ✓ All checks passing | ✓ All review threads resolved | ✓ Ready to merge

@don-petry don-petry enabled auto-merge (squash) June 15, 2026 11:42
@don-petry don-petry disabled auto-merge June 15, 2026 11:58
@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — review-changes (no-changes)

No changes were needed for this PR.

@don-petry don-petry enabled auto-merge (squash) June 15, 2026 12:01

@donpetry-bot donpetry-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review — APPROVED ✓

Risk: LOW
Reviewed commit: ff531750afa8eee8c48cb4b3bf3f813544359ada
Review mode: triage-approved (single reviewer)

Summary

Fixes a non-actionable compliance finding (#355) by teaching pp_check_security_and_analysis() to skip warning-severity, plan-gated keys (secret_scanning_ai_detection, secret_scanning_non_provider_patterns, dependabot_security_updates) when their API status is null — i.e. the feature is unavailable for the org plan and cannot be remediated. Also adds post-PATCH verification of applied settings and a new bats test suite. +284/-8 across 3 files (1 lib, 2 test).

Linked issue analysis

Closes #355, which was an auto-generated audit finding flagging secret_scanning_ai_detection as null vs expected enabled. The root cause is that the feature is plan-gated (requires Copilot/GHAS), so a null status is not actionable. The PR addresses this precisely: null status for an explicitly allowlisted plan-gated key no longer produces a finding, while a disabled status (feature available but off) still does. Substantively resolved.

Findings

No blocking issues. Prior bot review findings were all raised and resolved:

  • (gemini) per-iteration jq forking in the verify loop — optimized.
  • (copilot) issue intent: distinguish null (plan-gated) from disabled — implemented via early continue.
  • (copilot/coderabbit) post-PATCH loop used warn, which is outside the pp_apply_* caller contract and also fired for error-severity keys — switched to info.
  • (coderabbit) null-suppression too broad — narrowed via explicit PP_PLAN_GATED_KEYS allowlist so error-severity keys (secret_scanning, push_protection) still report on null.
    The suppression is correctly scoped to warning-severity plan-gated keys with null status only; error-severity settings are unaffected. Test coverage exercises null-suppressed, disabled-still-flagged, and error-severity paths.

CI status

All required checks green: ShellCheck, Lint, CodeQL, SonarCloud, Secret scan (gitleaks), Agent Security Scan, AgentShield, CodeRabbit all SUCCESS. Language-specific audits (npm/pip/cargo/go/pnpm) appropriately SKIPPED. All 5 review threads resolved; CodeRabbit's latest review is APPROVED (2026-06-15). mergeStateStatus is BLOCKED only pending this required review.


Reviewed automatically by the PR-review agent (single-reviewer mode: fable 5). Reply if you need a human review.

@sonarqubecloud

Copy link
Copy Markdown

@don-petry don-petry merged commit 8b3caff into main Jun 15, 2026
30 of 38 checks passed

@donpetry-bot donpetry-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review — APPROVED ✓

Risk: MEDIUM
Reviewed commit: 5882f65636816073c578d3b98da804f9df7a240d
Review mode: triage-approved (single reviewer)

Summary

Refines the push-protection compliance audit so that plan-gated, warning-severity security settings (secret_scanning_ai_detection, secret_scanning_non_provider_patterns, dependabot_security_updates) no longer emit non-actionable findings when the GitHub API reports their status as null/absent (i.e. the org plan does not offer the feature). Also adds post-PATCH verification in pp_apply_security_and_analysis that re-fetches each setting and reports any key the API silently ignored, plus a new bats test suite. 284/-8 across 3 files.

Linked issue analysis

Closes #355, which is the auto-filed compliance finding 'secret_scanning_ai_detection should be enabled (current: null, expected: enabled)'. The root cause was that an absent (null) status for a plan-gated feature was treated as non-compliance even though it cannot be remediated without a plan upgrade. The PR suppresses exactly this case (plan-gated key AND actual == null), directly resolving the issue. Tests confirm the finding is still emitted when the same feature is present but disabled, and error-severity settings (secret_scanning, push_protection) are never suppressed.

Findings

No blocking issues.

  • Suppression is narrowly scoped: it only skips when the key is in PP_PLAN_GATED_KEYS and actual == null. A disabled status still produces a finding, and error-severity keys are never plan-gated — verified by the new bats tests.
  • The post-PATCH verification loop is a net security-posture improvement: it surfaces settings the API accepts (HTTP 200) but silently ignores due to plan limits, rather than reporting blanket success.
  • Nit (non-blocking): the warning-detail strings now embed plan-requirement context, which is helpful; no action needed.

CI status

Effectively green. All substantive checks pass: CodeQL, ShellCheck, Lint, SonarCloud, Agent Security Scan, Secret scan (gitleaks), AgentShield, pr-auto-review all SUCCESS. CANCELLED entries (Lint, ShellCheck, Agent Security Scan, gitleaks, dev-lead dispatch/ci-relay) are concurrency-cancelled duplicates — each non-dev-lead one has a SUCCESS counterpart, and dev-lead's are the known concurrency-cancel case (per #608/#609). Language audits (npm/pnpm/pip/cargo/go) SKIPPED as not applicable. reviewDecision=APPROVED; CodeRabbit ultimately APPROVED; no unresolved review threads.


Reviewed automatically by the PR-review agent (single-reviewer mode: fable 5). Reply if you need a human review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compliance: secret_scanning_ai_detection

3 participants