fix(compliance-audit): use null-safe jq for boolean settings checks#131
fix(compliance-audit): use null-safe jq for boolean settings checks#131
Conversation
jq's // operator treats false as falsy, so false // "null" returns "null" rather than "false". This caused boolean settings checks with expected value of false (e.g. has_wiki) to always report a compliance finding even when the setting was correctly set to false. Replace the // "null" fallback with an explicit null test: if .$key == null then "null" else (.$key | tostring) end This correctly returns "false" for a false value and "null" only when the field is actually absent. Closes petry-projects/ContentTwin#63
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 45 minutes and 48 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR fixes JSON value extraction logic in the compliance audit script to properly handle null values from the GitHub API. The change improves null-to-string conversion and adjusts the default branch extraction method to use Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 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 |
|
@don-petry This PR fixes the root cause of the compliance finding in petry-projects/ContentTwin#63. The ContentTwin wiki is already correctly set to |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR fixes compliance audit false-positives for boolean repo settings (notably when the correct value is false) by making the jq extraction null-safe instead of using jq’s // operator.
Changes:
- Replace jq
// "null"fallback with an explicitnullcheck andtostringconversion for boolean settings.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@claude[agent] - Fix merge conflicts |
- Merge PR #133 from main (same jq boolean fix) - Apply printf instead of echo for JSON piping (safer) - Use jq --arg for key interpolation (prevents injection) Agent-Logs-Url: https://github.com/petry-projects/.github/sessions/bc09d7ce-9add-488c-a416-223d826cc900 Co-authored-by: don-petry <36422719+don-petry@users.noreply.github.com>
Merge conflicts resolved in commit 5358531. The resolution merges PR #133 from main (which had the same boolean fix with cleaner jq syntax) and applies both Copilot review suggestions:
All changes tested and verified working correctly. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot resolve the merge conflicts in this pull request |
…intf and --arg key Co-authored-by: don-petry <36422719+don-petry@users.noreply.github.com>
Merge conflicts resolved in c10108f. The conflict in |
don-petry
left a comment
There was a problem hiding this comment.
Automated review — APPROVED
Risk: LOW
Reviewed commit: 07060da8ae3a4246d6b830ca73cac46687248652
Cascade: triage → deep (see triage: haiku 4.5 → deep: sonnet 4.6 + duck: gpt-5.4 → audit: opus 4.6 for models)
Summary
Single-file shell script fix replacing echo with printf '%s' and dynamic jq key interpolation with --arg/.[$key] for safer jq invocation. All CI checks pass (ShellCheck, Lint, SonarCloud quality gate, CodeQL, Agent Security Scan). The triage escalation was caused by a triage-tier failure, not a real risk signal — the change itself is a low-risk correctness and hardening improvement.
Findings
Info — Correctness
scripts/compliance-audit.sh:305— Replacesecho | jq -r '.$key ...'withprintf '%s' | jq -r --arg key '$key' '.[$key] ...'. Usingprintfavoids echo flag edge-cases (-e,-n) when$settingscontains leading-dash or backslash content, and--arg/.[$key]prevents jq filter injection if a key name ever contains special characters. Minor but strictly better.scripts/compliance-audit.sh:315— Sameecho→printfchange fordefault_branchextraction. No functional difference for a static field path, but consistent with the pattern above.
Info — CI
- All checks green: Lint, ShellCheck, Agent Security Scan, CodeQL (actions), SonarCloud (0 new issues, 0 security hotspots), CodeRabbit. No failures or warnings.
Info — Triage
- Triage escalation reason was
triage-output-invalid— the triage tier failed to produce output, not a genuine risk signal in this PR. No HIGH-risk patterns (auth/secrets/credentials/crypto, DB migrations, injection, hardcoded secrets, CI tampering) were present.
CI status
All checks green: Lint, ShellCheck, Agent Security Scan, CodeQL (actions), SonarCloud (0 new issues, 0 security hotspots), CodeRabbit. No failures or warnings.
Reviewed by the don-petry PR-review cascade (triage: haiku 4.5 → deep: sonnet 4.6 + duck: gpt-5.4 → audit: opus 4.6). Reply with @don-petry if you need a human.
Automated review — APPROVEDRisk: LOW
SummarySingle-file shell script hardening: replaces FindingsInfo
CI statusAll checks green: Lint, ShellCheck, AgentShield, CodeQL, SonarCloud (0 new issues, 0 security hotspots), CodeRabbit. Reviewed by the don-petry PR-review cascade (triage: haiku 4.5 → deep: sonnet 4.6 + duck: gpt-5.4 → audit: opus 4.6). Reply with |
|
Automated review — APPROVEDRisk: LOW SummarySingle-file shell script hardening in FindingsInfo (informational only — no action required)
CI statusAll checks green: Lint, ShellCheck, AgentShield, CodeQL (actions), SonarCloud (0 new issues, 0 security hotspots), CodeRabbit, Agent Security Scan, Dependency audit. No failures or warnings. Reviewed by the don-petry PR-review cascade (triage: haiku 4.5 → deep: sonnet 4.6 + duck: gpt-5.4 → audit: opus 4.6). Reply with |



Summary
//operator bug that causedhas_wiki: falseto always be reported ascurrent: null//(alternative) operator treatsfalseas falsy — sofalse // "null"returns"null"instead of"false"false(e.g.has_wiki) to perpetually flag as non-compliant even when correctly setRoot Cause
Line 303 in
scripts/compliance-audit.sh:Before (broken for false values):
actual=$(echo "$settings" | jq -r ".$key // "null"")
After (null-safe):
actual=$(echo "$settings" | jq -r "if .$key == null then "null" else (.$key | tostring) end")
Verification
echo '{"has_wiki": false}' | jq -r 'if .has_wiki == null then "null" else (.has_wiki | tostring) end'
=> false (correct)
echo '{"has_wiki": false}' | jq -r '.has_wiki // "null"'
=> null (broken — was causing the false positive)
Closes petry-projects/ContentTwin#63
Generated with Claude Code
Summary by CodeRabbit