List code scanning alerts for a repository
Lists all open code scanning alerts for the default branch (usually `main` or `master`). You must use an access token with the `security_events` scope to use this endpoint. GitHub Apps must have the `security_events` read permission to use this endpoint. The response includes a `most_recent_instance` object. This provides details of the most recent instance of this alert for the default branch or for the specified Git reference (if you used `ref` in the request).
/repos/{owner}/{repo}/code-scanning/alerts- Source
github-v3-rest.json- Revision
f5f067c1e6f6- Active snapshot
85e53e3d0d65
Request
Path Parameters
- owner stringrequired
- repo stringrequired
Query Parameters
- tool_name code-scanning-analysis-tool-name stringoptional
The name of a code scanning tool. Only results by this tool will be listed. You can specify the tool by using either `tool_name` or `tool_guid`, but not both.
- tool_guid code-scanning-analysis-tool-guid stringoptional
The GUID of a code scanning tool. Only results by this tool will be listed. Note that some code scanning tools may not include a GUID in their analysis data. You can specify the tool by using either `tool_guid` or `tool_name`, but not both.
- page integeroptional
Page number of the results to fetch.
- per_page integeroptional
Results per page (max 100)
- ref code-scanning-ref stringoptional
The Git reference for the results you want to list. The `ref` for a branch can be formatted either as `refs/heads/<branch name>` or simply `<branch name>`. To reference a pull request use `refs/pull/<number>/merge`.
- state string<code-scanning-alert-state>optional
Set to `open`, `fixed`, or `dismissed` to list code scanning alerts in a specific state.
Responses
Response
items code-scanning-alert-items object
The time that the alert was created in ISO 8601 format: `YYYY-MM-DDTHH:MM:SSZ`.
The time that the alert was dismissed in ISO 8601 format: `YYYY-MM-DDTHH:MM:SSZ`.
dismissed_by Simple User objectrequirednullable Simple User
Simple User
Example: https://github.com/images/error/octocat_happy.gif
Example: https://api.github.com/users/octocat/events{/privacy}
Example: https://api.github.com/users/octocat/followers
Example: https://api.github.com/users/octocat/following{/other_user}
Example: https://api.github.com/users/octocat/gists{/gist_id}
Example: 41d064eb2195891e12d0413f63227ea7
Example: https://github.com/octocat
Example: 1
Example: octocat
Example: MDQ6VXNlcjE=
Example: https://api.github.com/users/octocat/orgs
Example: https://api.github.com/users/octocat/received_events
Example: https://api.github.com/users/octocat/repos
Example: "2020-07-09T00:17:55Z"
Example: https://api.github.com/users/octocat/starred{/owner}{/repo}
Example: https://api.github.com/users/octocat/subscriptions
Example: User
Example: https://api.github.com/users/octocat
Allowed: null, "false positive", "won't fix", "used in tests"
**Required when the state is dismissed.** The reason for dismissing or closing the alert. Can be one of: `false positive`, `won't fix`, and `used in tests`.
The GitHub URL of the alert resource.
The REST API URL for fetching the list of instances for an alert.
most_recent_instance code-scanning-alert-instance objectrequired
Identifies the configuration under which the analysis was executed. For example, in GitHub Actions this includes the workflow filename and job name.
Identifies the configuration under which the analysis was executed. Used to distinguish between multiple analyses for the same tool and commit, but performed on different languages or different parts of the code.
Classifications that have been applied to the file that triggered the alert. For example identifying it as documentation, or a generated file.
Identifies the variable values associated with the environment in which the analysis that generated this alert instance was performed, such as the language that was analyzed.
location code-scanning-alert-location objectoptionalDescribe a region within a file for the alert.
Describe a region within a file for the alert.
message objectoptional
The full Git reference, formatted as `refs/heads/<branch name>`, `refs/pull/<number>/merge`, or `refs/pull/<number>/head`.
Allowed: "open", "closed", "dismissed", "fixed"
State of a code scanning alert.
The security alert number.
rule code-scanning-alert-rule-summary objectrequired
A short description of the rule used to detect the alert.
A unique identifier for the rule used to detect the alert.
The name of the rule used to detect the alert.
The severity of the alert.
Allowed: "open", "closed", "dismissed", "fixed"
State of a code scanning alert.
tool code-scanning-analysis-tool objectrequired
The GUID of the tool used to generate the code scanning analysis, if provided in the uploaded SARIF data.
The name of the tool used to generate the code scanning analysis.
The version of the tool used to generate the code scanning analysis.
The REST API URL of the alert resource.
Response if GitHub Advanced Security is not enabled for this repository
Resource not found
Service unavailable