BUILD-10745 Add audit script#235
BUILD-10745 Add audit script#235mikolaj-matuszny-ext-sonarsource wants to merge 2 commits intomasterfrom
Conversation
SummaryThis PR adds a Python audit script to detect non-compliant GitHub Action versions across an organization. It searches all What reviewers should knowKey implementation details to watch:
Review focus: Regex correctness (does it match the action syntax you care about?), rate limit sleeps (necessary but could be tuned if you hit API errors), and the error recovery strategy (is failing silently on unreachable files acceptable?).
|
Code reviewFound 4 issues:
ci-github-actions/tools/audit-action-version.py Lines 181 to 185 in aef2454
ci-github-actions/tools/audit-action-version.py Lines 143 to 145 in aef2454
ci-github-actions/tools/audit-action-version.py Lines 254 to 262 in aef2454
ci-github-actions/tools/audit-action-version.py Lines 8 to 10 in aef2454 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
- Fix regex to only allow /subpath after action name, preventing false positives on actions sharing a name prefix - Increase search API sleep from 2s to 6s to respect 10 req/min limit - Replace for/else with explicit check for 1000-result API cap - Add 0.5s delay between file content fetches to avoid secondary rate limits - Fix docstring: Python 3.7+ (not 3.6+), correct script path Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
SonarQube reviewer guide
|
|
|
||
| versions = extract_versions_from_file(repo, filepath, args.action) | ||
|
|
||
| if i > 0: |
There was a problem hiding this comment.
The sleep is placed after extract_versions_from_file (which makes the gh api call), not before it. This means there's zero delay between the 0th and 1st file fetch — the pair most likely to trigger a secondary rate limit since they fire back-to-back immediately after the search completes.
Move the sleep before the fetch:
for i, file_info in enumerate(matched_files):
repo = file_info["repo"]
filepath = file_info["path"]
if i > 0:
time.sleep(0.5) # Avoid hitting GitHub secondary rate limits
versions = extract_versions_from_file(repo, filepath, args.action)- Mark as noise




Summary
Adds a Python audit script (
tools/audit-action-version.py) that scans a GitHub organization to find all usages of a specified GitHub Action and reports which repositories are not using an allowed version (tag or SHA).How it works
ghCLI) to find all references to the target action in.github/directories across the orgUsage
python tools/audit-action-version.py \ --org SonarSource \ --action SonarSource/gh-action_cache \ --allowed-refs v1,54a48984cf6564fd48f3c6c67c0891d7fe89604c \ [--output report.csv] [--verbose]Prerequisites
ghCLI (authenticated)