Skip to content

fix: fall back to workflow scanning when code scanning API returns 403#2311

Merged
Marfuen merged 2 commits intotrycompai:mainfrom
kline7:fix/fallback-workflow-scanning-on-403
Mar 16, 2026
Merged

fix: fall back to workflow scanning when code scanning API returns 403#2311
Marfuen merged 2 commits intotrycompai:mainfrom
kline7:fix/fallback-workflow-scanning-on-403

Conversation

@kline7
Copy link
Contributor

@kline7 kline7 commented Mar 16, 2026

Problem

The getCodeScanningStatus function in sanitized-inputs.ts returns early with ghas-required or permission-denied when the GitHub code-scanning API returns HTTP 403. This skips workflow file scanning entirely, preventing detection of third-party SAST tools (Semgrep, Snyk, Trivy, etc.) that upload SARIF results via github/codeql-action/upload-sarif.

Impact: Private repos without GitHub Advanced Security (GHAS) can never pass the code scanning check, even if they have properly configured SAST workflows using third-party tools.

Root Cause

The code-scanning default-setup API requires GHAS (or security_events permission) for private repos, but reading workflow file contents via the tree/contents API only requires contents:read. These are independent permission scopes. A 403 on the code-scanning API does not mean workflow files are inaccessible.

The comment on the original code explicitly says "Return early without checking workflows since we can't verify they're actually running" — but this is incorrect. Workflow files in the repo tree are verifiable evidence of code scanning configuration.

Fix

  • Replace the three early return statements in the 403 handler with a boolean flag (apiGot403)
  • Always fall through to findCodeScanningWorkflows() regardless of API response
  • Only after workflow scanning finds nothing, use the flag to determine the appropriate error status (ghas-required, permission-denied, or not-configured)

Changes

Single file: packages/integration-platform/src/manifests/github/checks/sanitized-inputs.ts

  • ~23 lines added, ~19 lines removed
  • No new dependencies
  • Backwards compatible — repos with GHAS still get detected via the API path first

Testing

No test infrastructure exists for integration checks (CONTRIBUTING.md testing section says "Coming soon"). The change is minimal and the logic is straightforward: flag instead of early return, deferred status determination.

The getCodeScanningStatus function previously returned early with
ghas-required or permission-denied when the code-scanning API returned
403, skipping workflow file scanning entirely. This prevented detection
of third-party SAST tools (Semgrep, Snyk, Trivy) that upload SARIF
results via github/codeql-action/upload-sarif.

The code-scanning API requires GHAS for private repos, but reading
workflow file contents only requires contents:read — these are
independent permission scopes. A 403 on the API should not prevent
checking for code scanning workflows.

Now the 403 handler sets a flag instead of returning early, always
falls through to workflow scanning, and only returns the appropriate
error status if no workflows are found either.
@CLAassistant
Copy link

CLAassistant commented Mar 16, 2026

CLA assistant check
All committers have signed the CLA.

@vercel
Copy link

vercel bot commented Mar 16, 2026

@kline7 is attempting to deploy a commit to the Comp AI Team on Vercel.

A member of the Team first needs to authorize it.

@vercel vercel bot temporarily deployed to Preview – portal March 16, 2026 03:43 Inactive
@vercel
Copy link

vercel bot commented Mar 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app Ready Ready Preview, Comment Mar 16, 2026 6:38pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
portal Skipped Skipped Mar 16, 2026 6:38pm

Request Review

@vercel vercel bot temporarily deployed to Preview – portal March 16, 2026 18:36 Inactive
@Marfuen Marfuen merged commit 5a5fe85 into trycompai:main Mar 16, 2026
4 checks passed
claudfuen pushed a commit that referenced this pull request Mar 16, 2026
# [3.7.0](v3.6.0...v3.7.0) (2026-03-16)

### Bug Fixes

* **auth:** add rate limiting for admin endpoints ([f81148b](f81148b))
* fall back to workflow scanning when code scanning API returns 403 ([#2311](#2311)) ([5a5fe85](5a5fe85))

### Features

* **admin-organizations:** add admin dashboard ([e5318ec](e5318ec))
@claudfuen
Copy link
Contributor

🎉 This PR is included in version 3.7.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants