Skip to content

refactor(shell): use [[ ]] for conditional tests in scripts/compliance-audit.sh (S7688, part of #1462) - #1502

Merged
don-petry merged 1 commit into
mainfrom
sonar-s7688/compliance-audit
Nov 10, 2026
Merged

don-petry merged 1 commit into
mainfrom
sonar-s7688/compliance-audit

Conversation

@don-petry

@don-petry don-petry commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What

Split B of 5 of #1463, split by directory at the Maintainer's direction: scripts/compliance-audit.sh (1 files). It is part of #1462, SonarCloud shell:S7688: use [[ instead of [.

The files are taken unchanged from #1463 head 3c6d334, which was level with main. That PR's review rounds (CodeRabbit, Codex, pr-review) are already folded in. #1463 is closed in favour of these five smaller PRs, because a 68-file mechanical change kept drawing review rounds and never converged.

Split Scope
A scripts/canary-rollout.sh + tests/canary_rollout.bats
B scripts/compliance-audit.sh
C other top-level scripts/*.sh + their tests
D scripts/lib/*.sh + their tests
E .github/scripts/**

#1462 stays open until all five merge.

Review focus

Inside [[ ]], -eq/-ne/-lt/-le/-gt/-ge evaluate both operands as arithmetic, which [ ] does not:

  • an empty or non-numeric operand now compares as 0 instead of failing the test;
  • a leading-zero value is read as octal (08 is an error, 010 is 8). feat: implement issue #1462 — SonarCloud: miscellaneous findings #1463 added $((10#…)) normalisation and tests where it found config values;
  • a value from outside (API JSON, issue text, env input) that reaches such a comparison unvalidated is evaluated, and a string like a[$(cmd)] would run cmd.

Please check each numeric comparison in this diff whose operand is not a local counter or exit status.

Checks

  • Every changed file passes bash -n (bash 5) and is not a #!/bin/sh script.
  • shellcheck -x -S warning reports no new findings compared with main.
  • Related bats suites, run locally on this branch (GNU date, bash 5), with any failure re-run on main: compliance-audit suites (27 files) — 361 ok, 0 failed.

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

Problem

See the linked issue.

Risk

Low — changes automation shell logic under scripts/, covered by shellcheck (--severity=warning) and the bats suite.

Test plan

No test files were added or updated. Verification: bash scripts/dev-lead-lint.sh (shellcheck --severity=warning) ran pre-commit; the existing CI (bats + lint) guards the change.

Rollback

Revert this PR. No non-revertible side effects (no tags, migrations, or external state).

Monitoring

This PR's Lint (shellcheck) and bats checks show pass/fail; watch subsequent dev-lead / pr-review runs for behavioral regressions.

…e-audit.sh (S7688, part of #1462)

Split B of 5 of #1463, by directory, at the Maintainer's direction. These 1
file(s) are taken unchanged from #1463 head 3c6d334, which was level with main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@don-petry
don-petry requested a review from a team as a code owner November 10, 2026 17:07
@chatgpt-codex-connector

This comment has been minimized.

@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.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Refactor
    • Updated internal compliance audit checks while preserving their existing behavior and outcomes.
    • No changes to user-facing features or functionality.

The script replaces single-bracket test expressions with Bash [[ ... ]] across audit checks, issue handling, summary generation, and main. The supplied summaries report that conditions, branches, and return paths remain otherwise unchanged.

Changes: Compliance audit conditionals

Layer / File(s) Summary
Repository and workflow audit checks
scripts/compliance-audit.sh
Audit predicates for repository state, workflows, rulesets, and declared checks now use [[ ... ]]. The summaries report unchanged conditions and outcomes.
Policy and tooling audit checks
scripts/compliance-audit.sh
Predicates for CODEOWNERS, scanning, workflow permissions, repository settings, and instruction files now use [[ ... ]].
Issue handling and audit reporting
scripts/compliance-audit.sh
Issue mutation, closure, summary generation, structural counts, and main predicates now use [[ ... ]].

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Possibly related issues

  • combsmith/.github#1462 — The issue concerns shell:S7688 findings in scripts/compliance-audit.sh; this PR changes conditional tests in that file.

Possibly related PRs

  • combsmith/.github#1463 — The PR makes the same conditional-test conversion in scripts/compliance-audit.sh.
Merge Risk: Minimal · up to 3e053

No merge-blocking risk was identified. Normal checks remain appropriate.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly identifies the change: using [[ ]] for conditional tests in scripts/compliance-audit.sh.
Docstring Coverage Passed Docstring coverage is 93.62% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description explains the change to scripts/compliance-audit.sh, its purpose, review focus, and reported tests.
Full details: Docstring Coverage

Explanation

Docstring coverage is 93.62% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 47 functions across 1 files.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: d4bb1a0a-8703-49bc-a26d-b1b9be8657a1
Commits

Reviewing files that changed from the base of the PR and between 14e9c7d and 3e0536b.

Files selected for processing: 1

  • scripts/compliance-audit.sh

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — waiting on PR blockers (intent: review-changes)

PR: #1502
No changes were committed, but the PR still can't be marked done: required check SonarCloud is still pending. The retry cron will re-attempt automatically. Next attempt after: 2026-11-10T17:38:05Z

@don-petry

Copy link
Copy Markdown
Contributor Author

Note

@don-petry I reviewed this PR and no code changes were needed, but I can't mark it done yet: required check SonarCloud is still pending. I'll re-check automatically.
Next attempt after: 2026-11-10T17:38:05Z

@don-petry
don-petry enabled auto-merge (squash) November 10, 2026 17:08
@sonarqubecloud

Copy link
Copy Markdown

@donpetry-bot

Copy link
Copy Markdown
Contributor

Advisory bots were rate-limited; auto-approval is withheld until they recover. pr-review-sweep will re-review this PR after 2026-11-10T18:10:06Z.

@don-petry

Copy link
Copy Markdown
Contributor Author

Acknowledged: the Codex review status table reports a failed run (usage limit) and lists no actual findings. No action needed.

@don-petry

Copy link
Copy Markdown
Contributor Author

Acknowledged: Codex usage-limit notice, no finding and no code action required.

@don-petry

Copy link
Copy Markdown
Contributor Author

Acknowledged: CodeRabbit reports no actionable comments, Merge Risk Minimal, and all 5 pre-merge checks passed. No finding-bearing section is present.

@don-petry

Copy link
Copy Markdown
Contributor Author

Acknowledged: SonarCloud Quality Gate passed. No action needed.

@don-petry

Copy link
Copy Markdown
Contributor Author

Dev-Lead — fix-reviews (no-changes)

Agent reasoning
Addressed 0 threads. There were no open review threads, and I made no code changes.
- **Tier 1 blockers:** none. No CI check failed, and the only reviewer state is CodeRabbit's `APPROVED`. The one `in_progress` check is the dev-lead dispatch for this pass.
- **Issue comments:** I posted one `informational` disposition on each of four bot comments (each reply has its own marker):
  - Codex review summary (failed run, no findings), id `IC_kwDORyesfc8AAAABk8C6MA`
  - Codex usage-limit notice, id `IC_kwDORyesfc8AAAABk8C9bA`
  - CodeRabbit summary (no actionable comments, Merge Risk Minimal, all 5 pre-merge checks passed), id `IC_kwDORyesfc8AAAABk8DKWA`
  - SonarCloud Quality Gate passed, id `IC_kwDORyesfc8AAAABk8EjCA`
- **Skipped:** I left the `don-petry` and `donpetry-bot` comments alone. They carry our own dev-lead and pr-review-agent markers.
- **Test verification:** I did not run the test suite because nothing changed.
- **Files changed:** none.

@don-petry
don-petry enabled auto-merge (squash) November 10, 2026 17:14

@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: 3e0536b34cba6ec1de8f179bb277130152215bd7
Review mode: triage-approved (single reviewer)

Summary

This PR changes [ ... ] to [[ ... ]] throughout scripts/compliance-audit.sh, with 194 lines added and 194 removed, as split B of 5 of the closed #1463 (SonarCloud shell:S7688). I read the whole diff. Every hunk is a bracket swap with the same operands and operators, and no logic, control flow or output text changes. I agree with the triage verdict: LOW risk, style-only.

Linked issue analysis

No closing issue is linked, and that is deliberate. The PR refers to #1462 ("#1462 stays open until all five merge"), so it should not auto-close it. Its scope matches its row in the description's split table: one file. I did not read #1462 itself because it was not in the pre-fed context.

Findings

No blocking findings.

What I checked: the risk the description asks reviewers to look at. Inside [[ ]], -eq/-ne/-lt/-gt evaluate both operands as arithmetic. I traced the operand of every numeric comparison in the diff:

  • Exit codes and PIPESTATUS: rc, list_rc, persona_rc, api_ok, match_rc, lint_rc. These are always integers.
  • Loop counters and local flags: i / attempt (from for … in 1 2 3), broad, channel_seen, missing, inline_seen, inline_missing, $#, ${#ECOSYSTEMS[@]}.
  • Counts from grep -c or jq length: total_findings and cat_count come from jq over the script's own $FINDINGS_FILE. In close_resolved_issues, the empty case is checked before the numeric test. The grep -vx … | grep -c . count in check_reusable_workflows_disabled is also always an integer.

No value from an API, an issue or the environment reaches an arithmetic comparison without first going through grep -c or jq length. The one operand I could not trace is $retries in gh_api, because its definition is outside the diff context. It is almost certainly a local constant, but I could not confirm that.

String comparisons: every right-hand side of = / != is either quoted or a bare literal with no glob characters (false, true). The newly pattern-matched right side of [[ == ]] therefore cannot change any result, including "**" and "$(ring_canonical_ref …)", which are quoted and so compared literally.

Non-blocking, existing before this PR: in check_workflow_permissions, job_count and has_job_perms use grep -cE … || echo "0". When nothing matches, grep -c prints 0 and exits 1, so the variable becomes 0\n0. Before this PR, [ "0\n0" -eq 0 ] errored and counted as false. Now [[ ]] reports an arithmetic syntax error and returns false. The result is the same, so this PR introduces no regression. The underlying bug is that a single-job workflow with no job-level permissions: is never flagged as missing permissions. Consider fixing it in a follow-up with $(grep -cE … || true).

Context I could not access: I had no MCP secret-scanning tool and no shell, so I did not run shellcheck or bats myself. I relied on the CI results below and the author's reported run (361 bats ok, no new shellcheck findings).

CI status

All checks completed, with no failures and no pending checks. These passed: Lint, ShellCheck, Compliance Audit Tests (Lint and bats), CodeQL (actions, python), SonarCloud and SonarCloud Code Analysis (Quality Gate passed, 0 new issues, 0 hotspots), Secret scan (gitleaks), Agent Security Scan, AgentShield, duplicate-decl-gate, dependency audit gate, CodeRabbit and Graphite. The remaining checks were skipped because they did not apply.

CodeRabbit approved at this SHA with no actionable comments. Codex failed because it hit its usage limit, so it produced no findings. There are no unresolved review threads and no unanswered questions from human reviewers. The merge state is BLOCKED only because the required org-leads review is still outstanding.


Reviewed automatically by the PR-review agent (single-reviewer mode: opus 5.5 [opus 4.8, opus 4.7]). Reply if you need a human review.

@donpetry-bot

Copy link
Copy Markdown
Contributor

pr-review approved on PARTIAL advisory evidence: 2/5 required advisory bots reported before the gate's head-age-timeout fallback proceeded. Recorded for the miss-rate metric (#1596).

@don-petry

Copy link
Copy Markdown
Contributor Author

No description provided.

@don-petry
don-petry disabled auto-merge November 10, 2026 18:23
@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 merged commit d5b9825 into main Nov 10, 2026
48 checks passed
@don-petry
don-petry deleted the sonar-s7688/compliance-audit branch November 10, 2026 18:23
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.

2 participants