Skip to content

ci: verify codeql guard search hits against file contents#33

Merged
haasonsaas merged 1 commit intomainfrom
codex/codeql-guard-verify-hits
Apr 30, 2026
Merged

ci: verify codeql guard search hits against file contents#33
haasonsaas merged 1 commit intomainfrom
codex/codeql-guard-verify-hits

Conversation

@haasonsaas
Copy link
Copy Markdown
Contributor

Summary

  • verify each org code-search hit by fetching the current workflow file contents
  • skip stale or tokenized search hits that no longer contain an actual uses: github/codeql-action step
  • preserve unverified fetch failures as drift hits so auth/API issues do not hide policy violations

Verification

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 30, 2026

PR Summary

Medium Risk
Updates a security-policy CI workflow that can change which repos are flagged for CodeQL drift; mistakes could hide violations or create noise if content fetching/regex matching behaves unexpectedly.

Overview
Improves the scheduled codeql-guard org sweep by fetching each matched workflow file via the GitHub Contents API and only reporting hits that still contain a real uses: github/codeql-action step.

Search hits that can’t be verified (API/auth failures) are still preserved as potential violations, while stale/tokenized matches are skipped with a notice to reduce false positives.

Reviewed by Cursor Bugbot for commit 6b0897a. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Grep misses - uses: YAML shorthand format
    • The workflow verification regex now accepts an optional YAML list prefix before uses:, so shorthand - uses: CodeQL steps are detected correctly.
Preview (6b0897a18e)
diff --git a/.github/workflows/codeql-guard.yml b/.github/workflows/codeql-guard.yml
--- a/.github/workflows/codeql-guard.yml
+++ b/.github/workflows/codeql-guard.yml
@@ -81,7 +81,19 @@
             if [ "${repo}" = "evalops/.github" ] && [ "${path}" = ".github/workflows/codeql-guard.yml" ]; then
               continue
             fi
-            hits+=("${repo}"$'\t'"${path}")
+            if ! content="$(
+              GH_TOKEN="${ORG_CODE_SEARCH_TOKEN}" gh api "repos/${repo}/contents/${path}" --jq '.content' |
+                base64 --decode
+            )"; then
+              echo "::warning::Could not verify ${repo}:${path}; preserving search hit."
+              hits+=("${repo}"$'\t'"${path}")
+              continue
+            fi
+            if grep -Eq '^[[:space:]]*(-[[:space:]]*)?uses:[[:space:]]*github/codeql-action([/@]|[[:space:]]|$)' <<< "${content}"; then
+              hits+=("${repo}"$'\t'"${path}")
+            else
+              echo "::notice::Skipping stale or non-use search hit ${repo}:${path}"
+            fi
           done <<< "${response}"
           if [ "${#hits[@]}" -eq 0 ]; then
             echo "ok: no CodeQL workflow files found in any evalops repo"

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit a1763e4. Configure here.

Comment thread .github/workflows/codeql-guard.yml Outdated
@haasonsaas haasonsaas force-pushed the codex/codeql-guard-verify-hits branch from a1763e4 to 6b0897a Compare April 30, 2026 15:07
@haasonsaas haasonsaas merged commit b3a15ce into main Apr 30, 2026
6 checks passed
@haasonsaas haasonsaas deleted the codex/codeql-guard-verify-hits branch April 30, 2026 15:15
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.

1 participant