fix(compliance-audit): use null-safe jq for boolean settings checks#131
fix(compliance-audit): use null-safe jq for boolean settings checks#131don-petry wants to merge 104 commits into
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
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughNormalized how JSON is passed into jq across two scripts: replaced Changesjq input and key-lookup normalization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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.
Outdated review (superseded by re-review at
|
Outdated review (superseded by re-review at
|
|
@dev-lead - please fix this PR |
|



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