Cloud security 4 min read

GitHub AI Scan: automate the setting, verify the scan

On this page
  1. Change the intended setting, then read it back
  2. Follow policy and permissions through every level
  3. Separate eligibility from the scan bill
  4. Verify execution before reporting coverage

Two separate evidence trails: policy and settings permit AI Scan; a user then runs a scan and reviews its results and usage

GitHub’s new REST API support makes AI Scan for repositories easier to configure across an organization. It does not turn an enabled setting into evidence that a repository has been scanned. That distinction should shape the rollout: record the policy and configuration first, then track execution, findings and cost separately.

The 13 November announcement describes a public preview that adds repository_scan to the existing AI Scan enablement endpoints. This is a configuration change for GitHub.com; GitHub Enterprise Server is not supported. The preview should be evaluated with its documented limits before it becomes a broad organizational default.

Change the intended setting, then read it back

The REST API reference documents GET and PATCH operations at these paths:

ScopeEndpoint path
Organization/orgs/{org}/code-scanning/ai-scan
Repository/repos/{owner}/{repo}/code-scanning/ai-scan

The existing pr_scan field controls AI Scan on pull requests. The new repository_scan field controls full-repository AI Scan enablement. Both take enabled or disabled.

For an authorized change whose intended scope is repository scanning, the following is an illustrative PATCH body, not a command executed for this article:

{
  "repository_scan": "enabled"
}

Begin with GET, retain the two settings as the baseline, and make the smallest intended change. Read both values again afterwards. A successful configuration response belongs in the change record; a scan result belongs in a different record.

The announcement allows both fields in one request. If either requested change is blocked, the API returns 422 and neither setting changes. Do not count a rejected combined request as partial success. Read the response and inspect policy before retrying; 422 is not, by itself, a reason to keep sending the same request.

Follow policy and permissions through every level

Enterprise permission is a prerequisite, not an enablement action. GitHub’s enterprise policy documentation says the AI Scan policy is not allowed by default. An enterprise owner can permit it, after which the organization still needs to enable the feature.

At organization level, disabling repository scanning prevents repositories from opting in. Enabling it is inherited by repositories, which can opt out individually. That makes an organization-wide change materially different from a pilot on a selected repository: review the eligible population and existing exceptions before changing the parent setting.

Organization owners and security managers manage the organization setting; repository administrators manage the repository opt-out. The REST reference also distinguishes fine-grained token permissions:

OperationDocumented fine-grained permission
Read organization settingOrganization Administration: read
Update organization settingOrganization Administration: write
Read repository enablementRepository Code scanning alerts: read
Update repository enablementRepository Administration: write

Keep the credential’s repository or organization scope aligned with the task. A token that can inspect repository alerts is not thereby authorized to update repository administration settings. These are documented permission requirements, not permissions granted or tested here.

Separate eligibility from the scan bill

This article focuses on organization-owned repositories. Public repositories do not require an active-committer licence for AI Scan for repositories. Private and internal repositories require GitHub Code Security or GitHub Advanced Security. A GitHub Copilot licence is not a prerequisite. Check the current availability documentation against the repository owner and visibility before extending a rollout.

Licence eligibility and consumption are separate questions. GitHub’s billing documentation says AI Scan uses Code Security AI credits even in public repositories that do not require active-committer licences. For an organization-owned repository, the responsible billing account is the organization or enterprise paying for that organization’s usage.

Included AI credits, where the billing account has an applicable Copilot entitlement, are used before metered usage. Without an allowance, or after it is exhausted, usage is metered. Review that account’s allowance and a hard budget with the billing administrator before enabling the feature widely. This article supplies no fixed per-scan price or promised saving.

A setting that reads as enabled is not a budget check. The AI Scan documentation explains that a hard budget leaving no available credits prevents the scan from producing findings. Record budget availability with the pilot evidence rather than interpreting an empty backlog as proof of security.

Verify execution before reporting coverage

Enabling repository scanning does not start a scan. GitHub’s current procedure requires a user with write access to start it from Security and quality > Code scanning > AI Scan, using the control beside Standard scan. After completion, filter the alert list by the AI Scan tool and assess the findings.

Consider a hypothetical platform team introducing this to one eligible repository. Its suggested acceptance record would keep the approved policy, before-and-after settings, scan completion, reviewed findings and billing evidence together, while distinguishing what each proves. No API request or repository scan was run for this article.

The preview limitations remain important: default branch only, manual scans, no automatic scan on push or schedule, and no self-hosted runners. AI Scan selects code within a time budget; it does not exhaustively inspect every file. Findings can be inaccurate and duplicates can occur. It complements CodeQL rather than establishing complete coverage.

After a proposed fix reaches the default branch, run another scan through the documented process. Merging a fix does not trigger that verification automatically. Adopt the API to make configuration repeatable, and keep a named owner for the evidence that follows it.

Cheers,

Marcos Nogueira
Connect on LinkedIn

Search