Code Scanning
Download SpecRetrieve code scanning alerts from a repository.
List code scanning alerts for an enterprise
Lists code scanning alerts for the default branch for all eligible repositories in an enterprise. Eligible repositories are repositories that are owned by organizations that you own or for which you are a security manager. For more information, see "Managing security managers in your organization."
To use this endpoint, you must be a member of the enterprise,
and you must use an access token with the repo
scope or security_events
scope.
tool_name
string
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
string or null
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.
before
string
A cursor, as given in the Link header. If specified, the query only searches for results before this cursor.
after
string
A cursor, as given in the Link header. If specified, the query only searches for results after this cursor.
page
int
Page number of the results to fetch.
- Default
- 1
per_page
int
The number of results per page (max 100).
- Default
- 30
direction
string
The direction to sort the results by.
- Default
- "desc"
- Enum
-
- asc
- desc
state
string
If specified, only code scanning alerts with this state will be returned.
- Enum
-
- open
- closed
- dismissed
- fixed
sort
string
The property by which to sort the results.
- Default
- "created"
- Enum
-
- created
- updated
enterprise
string
required
The slug version of the enterprise name. You can also substitute this value with the enterprise id.
Response
Response
[
{
"number": 4,
"created_at": "2020-02-13T12:29:18Z",
"url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/4",
"html_url": "https://github.com/octocat/hello-world/code-scanning/4",
"state": "open",
"dismissed_by": null,
"dismissed_at": null,
"dismissed_reason": null,
"dismissed_comment": null,
"rule": {
"id": "js/zipslip",
"severity": "error",
"tags": [
"Security",
"external/cwe/cwe-022"
],
"description": "Arbitrary file write during zip extraction",
"name": "js/zipslip"
},
"tool": {
"name": "CodeQL",
"guid": null,
"version": "2.4.0"
},
"most_recent_instance": {
"ref": "refs/heads/main",
"analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"category": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"environment": "{}",
"state": "open",
"commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930",
"message": {
"text": "This path depends on a user-provided value."
},
"location": {
"path": "spec-main/api-session-spec.ts",
"start_line": 917,
"end_line": 917,
"start_column": 7,
"end_column": 18
},
"classifications": [
"test"
]
},
"instances_url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/4/instances",
"repository": {
"id": 1296269,
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
"name": "Hello-World",
"full_name": "octocat/Hello-World",
"owner": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/octocat/Hello-World",
"description": "This your first repo!",
"fork": false,
"url": "https://api.github.com/repos/octocat/Hello-World",
"archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
"assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}",
"blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}",
"collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}",
"commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}",
"compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}",
"contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors",
"deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments",
"downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads",
"events_url": "https://api.github.com/repos/octocat/Hello-World/events",
"forks_url": "https://api.github.com/repos/octocat/Hello-World/forks",
"git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
"issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
"issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}",
"keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
"labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}",
"languages_url": "https://api.github.com/repos/octocat/Hello-World/languages",
"merges_url": "https://api.github.com/repos/octocat/Hello-World/merges",
"milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}",
"notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
"pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}",
"releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}",
"stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers",
"statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers",
"subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription",
"tags_url": "https://api.github.com/repos/octocat/Hello-World/tags",
"teams_url": "https://api.github.com/repos/octocat/Hello-World/teams",
"trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
"hooks_url": "https://api.github.com/repos/octocat/Hello-World/hooks"
}
},
{
"number": 3,
"created_at": "2020-02-13T12:29:18Z",
"url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/3",
"html_url": "https://github.com/octocat/hello-world/code-scanning/3",
"state": "dismissed",
"dismissed_by": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"dismissed_at": "2020-02-14T12:29:18Z",
"dismissed_reason": "false positive",
"dismissed_comment": "This alert is not actually correct, because there's a sanitizer included in the library.",
"rule": {
"id": "js/zipslip",
"severity": "error",
"tags": [
"Security",
"external/cwe/cwe-022"
],
"description": "Arbitrary file write during zip extraction",
"name": "js/zipslip"
},
"tool": {
"name": "CodeQL",
"guid": null,
"version": "2.4.0"
},
"most_recent_instance": {
"ref": "refs/heads/main",
"analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"category": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"environment": "{}",
"state": "open",
"commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930",
"message": {
"text": "This path depends on a user-provided value."
},
"location": {
"path": "lib/ab12-gen.js",
"start_line": 917,
"end_line": 917,
"start_column": 7,
"end_column": 18
},
"classifications": []
},
"instances_url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/3/instances",
"repository": {
"id": 1296269,
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
"name": "Hello-World",
"full_name": "octocat/Hello-World",
"owner": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/octocat/Hello-World",
"description": "This your first repo!",
"fork": false,
"url": "https://api.github.com/repos/octocat/Hello-World",
"archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
"assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}",
"blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}",
"collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}",
"commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}",
"compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}",
"contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors",
"deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments",
"downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads",
"events_url": "https://api.github.com/repos/octocat/Hello-World/events",
"forks_url": "https://api.github.com/repos/octocat/Hello-World/forks",
"git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
"issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
"issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}",
"keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
"labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}",
"languages_url": "https://api.github.com/repos/octocat/Hello-World/languages",
"merges_url": "https://api.github.com/repos/octocat/Hello-World/merges",
"milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}",
"notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
"pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}",
"releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}",
"stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers",
"statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers",
"subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription",
"tags_url": "https://api.github.com/repos/octocat/Hello-World/tags",
"teams_url": "https://api.github.com/repos/octocat/Hello-World/teams",
"trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
"hooks_url": "https://api.github.com/repos/octocat/Hello-World/hooks"
}
}
]
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
code
string
message
string
documentation_url
string
message
string
documentation_url
string
url
string
status
string
Resource not found
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Service unavailable
{
"code": "string",
"message": "string",
"documentation_url": "string"
}
array[object]
- Content Type
- application/json
object
number
int
required
The security alert number.
created_at
string
date-time
required
The time that the alert was created in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
updated_at
string
date-time
The time that the alert was last updated in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
url
string
uri
required
The REST API URL of the alert resource.
html_url
string
uri
required
The GitHub URL of the alert resource.
instances_url
string
uri
required
The REST API URL for fetching the list of instances for an alert.
state
string
required
State of a code scanning alert.
- Enum
-
- open
- closed
- dismissed
- fixed
fixed_at
string or null
date-time
The time that the alert was no longer detected and was considered fixed in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
dismissed_by
object (dismissed_by) or null
required
A GitHub user.
name
string or null
string or null
login
string
required
- Example
- "octocat"
id
int
required
- Example
- 1
node_id
string
required
- Example
- "MDQ6VXNlcjE="
avatar_url
string
uri
required
- Example
- "https://github.com/images/error/octocat_happy.gif"
gravatar_id
string or null
required
- Example
- "41d064eb2195891e12d0413f63227ea7"
url
string
uri
required
- Example
- "https://api.github.com/users/octocat"
html_url
string
uri
required
- Example
- "https://github.com/octocat"
followers_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/followers"
following_url
string
required
- Example
- "https://api.github.com/users/octocat/following{/other_user}"
gists_url
string
required
- Example
- "https://api.github.com/users/octocat/gists{/gist_id}"
starred_url
string
required
- Example
- "https://api.github.com/users/octocat/starred{/owner}{/repo}"
subscriptions_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/subscriptions"
organizations_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/orgs"
repos_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/repos"
events_url
string
required
- Example
- "https://api.github.com/users/octocat/events{/privacy}"
received_events_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/received_events"
type
string
required
- Example
- "User"
site_admin
boolean
required
starred_at
string
- Example
- "\"2020-07-09T00:17:55Z\""
dismissed_at
string or null
date-time
required
The time that the alert was dismissed in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
dismissed_reason
string or null
required
Required when the state is dismissed. The reason for dismissing or closing the alert.
- Enum
-
- null
- false positive
- won't fix
- used in tests
dismissed_comment
string or null
The dismissal comment associated with the dismissal of the alert.
- Max Length
- 280
rule
object (rule)
required
id
string or null
A unique identifier for the rule used to detect the alert.
name
string
The name of the rule used to detect the alert.
severity
string or null
The severity of the alert.
- Enum
-
- none
- note
- warning
- error
security_severity_level
string or null
The security severity of the alert.
- Enum
-
- low
- medium
- high
- critical
description
string
A short description of the rule used to detect the alert.
full_description
string
description of the rule used to detect the alert.
tags
array[string] or null
A set of tags applicable for the rule.
string
help
string or null
Detailed documentation for the rule as GitHub Flavored Markdown.
help_uri
string or null
A link to the documentation for the rule used to detect the alert.
tool
object (tool)
required
name
string
The name of the tool used to generate the code scanning analysis.
version
string or null
The version of the tool used to generate the code scanning analysis.
guid
string or null
The GUID of the tool used to generate the code scanning analysis, if provided in the uploaded SARIF data.
most_recent_instance
object (most_recent_instance)
required
ref
string
The full Git reference, formatted as refs/heads/<branch name>
,
refs/pull/<number>/merge
, or refs/pull/<number>/head
.
analysis_key
string
Identifies the configuration under which the analysis was executed. For example, in GitHub Actions this includes the workflow filename and job name.
environment
string
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.
category
string
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.
state
string
State of a code scanning alert.
- Enum
-
- open
- closed
- dismissed
- fixed
commit_sha
string
message
object (message)
text
string
location
object (location)
Describe a region within a file for the alert.
path
string
start_line
int
end_line
int
start_column
int
end_column
int
html_url
string
classifications
array[string or null]
Classifications that have been applied to the file that triggered the alert. For example identifying it as documentation, or a generated file.
string or null
A classification of the file. For example to identify it as generated.
- Enum
-
- source
- generated
- test
- library
repository
object (repository)
required
A GitHub repository.
id
int
required
A unique identifier of the repository.
- Example
- 1296269
node_id
string
required
The GraphQL identifier of the repository.
- Example
- "MDEwOlJlcG9zaXRvcnkxMjk2MjY5"
name
string
required
The name of the repository.
- Example
- "Hello-World"
full_name
string
required
The full, globally unique, name of the repository.
- Example
- "octocat/Hello-World"
owner
object (owner)
required
A GitHub user.
name
string or null
string or null
login
string
required
- Example
- "octocat"
id
int
required
- Example
- 1
node_id
string
required
- Example
- "MDQ6VXNlcjE="
avatar_url
string
uri
required
- Example
- "https://github.com/images/error/octocat_happy.gif"
gravatar_id
string or null
required
- Example
- "41d064eb2195891e12d0413f63227ea7"
url
string
uri
required
- Example
- "https://api.github.com/users/octocat"
html_url
string
uri
required
- Example
- "https://github.com/octocat"
followers_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/followers"
following_url
string
required
- Example
- "https://api.github.com/users/octocat/following{/other_user}"
gists_url
string
required
- Example
- "https://api.github.com/users/octocat/gists{/gist_id}"
starred_url
string
required
- Example
- "https://api.github.com/users/octocat/starred{/owner}{/repo}"
subscriptions_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/subscriptions"
organizations_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/orgs"
repos_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/repos"
events_url
string
required
- Example
- "https://api.github.com/users/octocat/events{/privacy}"
received_events_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/received_events"
type
string
required
- Example
- "User"
site_admin
boolean
required
starred_at
string
- Example
- "\"2020-07-09T00:17:55Z\""
private
boolean
required
Whether the repository is private.
html_url
string
uri
required
The URL to view the repository on GitHub.com.
- Example
- "https://github.com/octocat/Hello-World"
description
string or null
required
The repository description.
- Example
- "This your first repo!"
fork
boolean
required
Whether the repository is a fork.
url
string
uri
required
The URL to get more information about the repository from the GitHub API.
- Example
- "https://api.github.com/repos/octocat/Hello-World"
archive_url
string
required
A template for the API URL to download the repository as an archive.
- Example
- "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}"
assignees_url
string
required
A template for the API URL to list the available assignees for issues in the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/assignees{/user}"
blobs_url
string
required
A template for the API URL to create or retrieve a raw Git blob in the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}"
branches_url
string
required
A template for the API URL to get information about branches in the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/branches{/branch}"
collaborators_url
string
required
A template for the API URL to get information about collaborators of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}"
comments_url
string
required
A template for the API URL to get information about comments on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/comments{/number}"
commits_url
string
required
A template for the API URL to get information about commits on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/commits{/sha}"
compare_url
string
required
A template for the API URL to compare two commits or refs.
- Example
- "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}"
contents_url
string
required
A template for the API URL to get the contents of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/contents/{+path}"
contributors_url
string
uri
required
A template for the API URL to list the contributors to the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/contributors"
deployments_url
string
uri
required
The API URL to list the deployments of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/deployments"
downloads_url
string
uri
required
The API URL to list the downloads on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/downloads"
events_url
string
uri
required
The API URL to list the events of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/events"
forks_url
string
uri
required
The API URL to list the forks of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/forks"
git_commits_url
string
required
A template for the API URL to get information about Git commits of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}"
git_refs_url
string
required
A template for the API URL to get information about Git refs of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}"
git_tags_url
string
required
A template for the API URL to get information about Git tags of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}"
issue_comment_url
string
required
A template for the API URL to get information about issue comments on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}"
issue_events_url
string
required
A template for the API URL to get information about issue events on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}"
issues_url
string
required
A template for the API URL to get information about issues on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/issues{/number}"
keys_url
string
required
A template for the API URL to get information about deploy keys on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}"
labels_url
string
required
A template for the API URL to get information about labels of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/labels{/name}"
languages_url
string
uri
required
The API URL to get information about the languages of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/languages"
merges_url
string
uri
required
The API URL to merge branches in the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/merges"
milestones_url
string
required
A template for the API URL to get information about milestones of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/milestones{/number}"
notifications_url
string
required
A template for the API URL to get information about notifications on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}"
pulls_url
string
required
A template for the API URL to get information about pull requests on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/pulls{/number}"
releases_url
string
required
A template for the API URL to get information about releases on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/releases{/id}"
stargazers_url
string
uri
required
The API URL to list the stargazers on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/stargazers"
statuses_url
string
required
A template for the API URL to get information about statuses of a commit.
- Example
- "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}"
subscribers_url
string
uri
required
The API URL to list the subscribers on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/subscribers"
subscription_url
string
uri
required
The API URL to subscribe to notifications for this repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/subscription"
tags_url
string
uri
required
The API URL to get information about tags on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/tags"
teams_url
string
uri
required
The API URL to list the teams on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/teams"
trees_url
string
required
A template for the API URL to create or retrieve a raw Git tree of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}"
hooks_url
string
uri
required
The API URL to list the hooks on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/hooks"
Link
string
List code scanning alerts for an organization
Lists code scanning alerts for the default branch for all eligible repositories in an organization. Eligible repositories are repositories that are owned by organizations that you own or for which you are a security manager. For more information, see "Managing security managers in your organization."
To use this endpoint, you must be an owner or security manager for the organization, and you must use an access token with the repo
scope or security_events
scope.
For public repositories, you may instead use the public_repo
scope.
GitHub Apps must have the security_events
read permission to use this endpoint.
tool_name
string
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
string or null
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.
before
string
A cursor, as given in the Link header. If specified, the query only searches for results before this cursor.
after
string
A cursor, as given in the Link header. If specified, the query only searches for results after this cursor.
page
int
Page number of the results to fetch.
- Default
- 1
per_page
int
The number of results per page (max 100).
- Default
- 30
direction
string
The direction to sort the results by.
- Default
- "desc"
- Enum
-
- asc
- desc
state
string
If specified, only code scanning alerts with this state will be returned.
- Enum
-
- open
- closed
- dismissed
- fixed
sort
string
The property by which to sort the results.
- Default
- "created"
- Enum
-
- created
- updated
severity
string
If specified, only code scanning alerts with this severity will be returned.
- Enum
-
- critical
- high
- medium
- low
- warning
- note
- error
org
string
required
The organization name. The name is not case sensitive.
Response
Response
[
{
"number": 4,
"created_at": "2020-02-13T12:29:18Z",
"url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/4",
"html_url": "https://github.com/octocat/hello-world/code-scanning/4",
"state": "open",
"dismissed_by": null,
"dismissed_at": null,
"dismissed_reason": null,
"dismissed_comment": null,
"rule": {
"id": "js/zipslip",
"severity": "error",
"tags": [
"Security",
"external/cwe/cwe-022"
],
"description": "Arbitrary file write during zip extraction",
"name": "js/zipslip"
},
"tool": {
"name": "CodeQL",
"guid": null,
"version": "2.4.0"
},
"most_recent_instance": {
"ref": "refs/heads/main",
"analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"category": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"environment": "{}",
"state": "open",
"commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930",
"message": {
"text": "This path depends on a user-provided value."
},
"location": {
"path": "spec-main/api-session-spec.ts",
"start_line": 917,
"end_line": 917,
"start_column": 7,
"end_column": 18
},
"classifications": [
"test"
]
},
"instances_url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/4/instances",
"repository": {
"id": 1296269,
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
"name": "Hello-World",
"full_name": "octocat/Hello-World",
"owner": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/octocat/Hello-World",
"description": "This your first repo!",
"fork": false,
"url": "https://api.github.com/repos/octocat/Hello-World",
"archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
"assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}",
"blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}",
"collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}",
"commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}",
"compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}",
"contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors",
"deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments",
"downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads",
"events_url": "https://api.github.com/repos/octocat/Hello-World/events",
"forks_url": "https://api.github.com/repos/octocat/Hello-World/forks",
"git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
"issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
"issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}",
"keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
"labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}",
"languages_url": "https://api.github.com/repos/octocat/Hello-World/languages",
"merges_url": "https://api.github.com/repos/octocat/Hello-World/merges",
"milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}",
"notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
"pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}",
"releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}",
"stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers",
"statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers",
"subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription",
"tags_url": "https://api.github.com/repos/octocat/Hello-World/tags",
"teams_url": "https://api.github.com/repos/octocat/Hello-World/teams",
"trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
"hooks_url": "https://api.github.com/repos/octocat/Hello-World/hooks"
}
},
{
"number": 3,
"created_at": "2020-02-13T12:29:18Z",
"url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/3",
"html_url": "https://github.com/octocat/hello-world/code-scanning/3",
"state": "dismissed",
"dismissed_by": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"dismissed_at": "2020-02-14T12:29:18Z",
"dismissed_reason": "false positive",
"dismissed_comment": "This alert is not actually correct, because there's a sanitizer included in the library.",
"rule": {
"id": "js/zipslip",
"severity": "error",
"tags": [
"Security",
"external/cwe/cwe-022"
],
"description": "Arbitrary file write during zip extraction",
"name": "js/zipslip"
},
"tool": {
"name": "CodeQL",
"guid": null,
"version": "2.4.0"
},
"most_recent_instance": {
"ref": "refs/heads/main",
"analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"category": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"environment": "{}",
"state": "open",
"commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930",
"message": {
"text": "This path depends on a user-provided value."
},
"location": {
"path": "lib/ab12-gen.js",
"start_line": 917,
"end_line": 917,
"start_column": 7,
"end_column": 18
},
"classifications": []
},
"instances_url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/3/instances",
"repository": {
"id": 1296269,
"node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5",
"name": "Hello-World",
"full_name": "octocat/Hello-World",
"owner": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/octocat/Hello-World",
"description": "This your first repo!",
"fork": false,
"url": "https://api.github.com/repos/octocat/Hello-World",
"archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}",
"assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}",
"blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}",
"collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}",
"commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}",
"compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}",
"contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors",
"deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments",
"downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads",
"events_url": "https://api.github.com/repos/octocat/Hello-World/events",
"forks_url": "https://api.github.com/repos/octocat/Hello-World/forks",
"git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}",
"issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}",
"issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}",
"keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}",
"labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}",
"languages_url": "https://api.github.com/repos/octocat/Hello-World/languages",
"merges_url": "https://api.github.com/repos/octocat/Hello-World/merges",
"milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}",
"notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}",
"pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}",
"releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}",
"stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers",
"statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers",
"subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription",
"tags_url": "https://api.github.com/repos/octocat/Hello-World/tags",
"teams_url": "https://api.github.com/repos/octocat/Hello-World/teams",
"trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}",
"hooks_url": "https://api.github.com/repos/octocat/Hello-World/hooks"
}
}
]
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
code
string
message
string
documentation_url
string
message
string
documentation_url
string
url
string
status
string
Resource not found
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Service unavailable
{
"code": "string",
"message": "string",
"documentation_url": "string"
}
array[object]
- Content Type
- application/json
object
number
int
required
The security alert number.
created_at
string
date-time
required
The time that the alert was created in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
updated_at
string
date-time
The time that the alert was last updated in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
url
string
uri
required
The REST API URL of the alert resource.
html_url
string
uri
required
The GitHub URL of the alert resource.
instances_url
string
uri
required
The REST API URL for fetching the list of instances for an alert.
state
string
required
State of a code scanning alert.
- Enum
-
- open
- closed
- dismissed
- fixed
fixed_at
string or null
date-time
The time that the alert was no longer detected and was considered fixed in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
dismissed_by
object (dismissed_by) or null
required
A GitHub user.
name
string or null
string or null
login
string
required
- Example
- "octocat"
id
int
required
- Example
- 1
node_id
string
required
- Example
- "MDQ6VXNlcjE="
avatar_url
string
uri
required
- Example
- "https://github.com/images/error/octocat_happy.gif"
gravatar_id
string or null
required
- Example
- "41d064eb2195891e12d0413f63227ea7"
url
string
uri
required
- Example
- "https://api.github.com/users/octocat"
html_url
string
uri
required
- Example
- "https://github.com/octocat"
followers_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/followers"
following_url
string
required
- Example
- "https://api.github.com/users/octocat/following{/other_user}"
gists_url
string
required
- Example
- "https://api.github.com/users/octocat/gists{/gist_id}"
starred_url
string
required
- Example
- "https://api.github.com/users/octocat/starred{/owner}{/repo}"
subscriptions_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/subscriptions"
organizations_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/orgs"
repos_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/repos"
events_url
string
required
- Example
- "https://api.github.com/users/octocat/events{/privacy}"
received_events_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/received_events"
type
string
required
- Example
- "User"
site_admin
boolean
required
starred_at
string
- Example
- "\"2020-07-09T00:17:55Z\""
dismissed_at
string or null
date-time
required
The time that the alert was dismissed in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
dismissed_reason
string or null
required
Required when the state is dismissed. The reason for dismissing or closing the alert.
- Enum
-
- null
- false positive
- won't fix
- used in tests
dismissed_comment
string or null
The dismissal comment associated with the dismissal of the alert.
- Max Length
- 280
rule
object (rule)
required
id
string or null
A unique identifier for the rule used to detect the alert.
name
string
The name of the rule used to detect the alert.
severity
string or null
The severity of the alert.
- Enum
-
- none
- note
- warning
- error
security_severity_level
string or null
The security severity of the alert.
- Enum
-
- low
- medium
- high
- critical
description
string
A short description of the rule used to detect the alert.
full_description
string
description of the rule used to detect the alert.
tags
array[string] or null
A set of tags applicable for the rule.
string
help
string or null
Detailed documentation for the rule as GitHub Flavored Markdown.
help_uri
string or null
A link to the documentation for the rule used to detect the alert.
tool
object (tool)
required
name
string
The name of the tool used to generate the code scanning analysis.
version
string or null
The version of the tool used to generate the code scanning analysis.
guid
string or null
The GUID of the tool used to generate the code scanning analysis, if provided in the uploaded SARIF data.
most_recent_instance
object (most_recent_instance)
required
ref
string
The full Git reference, formatted as refs/heads/<branch name>
,
refs/pull/<number>/merge
, or refs/pull/<number>/head
.
analysis_key
string
Identifies the configuration under which the analysis was executed. For example, in GitHub Actions this includes the workflow filename and job name.
environment
string
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.
category
string
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.
state
string
State of a code scanning alert.
- Enum
-
- open
- closed
- dismissed
- fixed
commit_sha
string
message
object (message)
text
string
location
object (location)
Describe a region within a file for the alert.
path
string
start_line
int
end_line
int
start_column
int
end_column
int
html_url
string
classifications
array[string or null]
Classifications that have been applied to the file that triggered the alert. For example identifying it as documentation, or a generated file.
string or null
A classification of the file. For example to identify it as generated.
- Enum
-
- source
- generated
- test
- library
repository
object (repository)
required
A GitHub repository.
id
int
required
A unique identifier of the repository.
- Example
- 1296269
node_id
string
required
The GraphQL identifier of the repository.
- Example
- "MDEwOlJlcG9zaXRvcnkxMjk2MjY5"
name
string
required
The name of the repository.
- Example
- "Hello-World"
full_name
string
required
The full, globally unique, name of the repository.
- Example
- "octocat/Hello-World"
owner
object (owner)
required
A GitHub user.
name
string or null
string or null
login
string
required
- Example
- "octocat"
id
int
required
- Example
- 1
node_id
string
required
- Example
- "MDQ6VXNlcjE="
avatar_url
string
uri
required
- Example
- "https://github.com/images/error/octocat_happy.gif"
gravatar_id
string or null
required
- Example
- "41d064eb2195891e12d0413f63227ea7"
url
string
uri
required
- Example
- "https://api.github.com/users/octocat"
html_url
string
uri
required
- Example
- "https://github.com/octocat"
followers_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/followers"
following_url
string
required
- Example
- "https://api.github.com/users/octocat/following{/other_user}"
gists_url
string
required
- Example
- "https://api.github.com/users/octocat/gists{/gist_id}"
starred_url
string
required
- Example
- "https://api.github.com/users/octocat/starred{/owner}{/repo}"
subscriptions_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/subscriptions"
organizations_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/orgs"
repos_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/repos"
events_url
string
required
- Example
- "https://api.github.com/users/octocat/events{/privacy}"
received_events_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/received_events"
type
string
required
- Example
- "User"
site_admin
boolean
required
starred_at
string
- Example
- "\"2020-07-09T00:17:55Z\""
private
boolean
required
Whether the repository is private.
html_url
string
uri
required
The URL to view the repository on GitHub.com.
- Example
- "https://github.com/octocat/Hello-World"
description
string or null
required
The repository description.
- Example
- "This your first repo!"
fork
boolean
required
Whether the repository is a fork.
url
string
uri
required
The URL to get more information about the repository from the GitHub API.
- Example
- "https://api.github.com/repos/octocat/Hello-World"
archive_url
string
required
A template for the API URL to download the repository as an archive.
- Example
- "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}"
assignees_url
string
required
A template for the API URL to list the available assignees for issues in the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/assignees{/user}"
blobs_url
string
required
A template for the API URL to create or retrieve a raw Git blob in the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}"
branches_url
string
required
A template for the API URL to get information about branches in the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/branches{/branch}"
collaborators_url
string
required
A template for the API URL to get information about collaborators of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}"
comments_url
string
required
A template for the API URL to get information about comments on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/comments{/number}"
commits_url
string
required
A template for the API URL to get information about commits on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/commits{/sha}"
compare_url
string
required
A template for the API URL to compare two commits or refs.
- Example
- "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}"
contents_url
string
required
A template for the API URL to get the contents of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/contents/{+path}"
contributors_url
string
uri
required
A template for the API URL to list the contributors to the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/contributors"
deployments_url
string
uri
required
The API URL to list the deployments of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/deployments"
downloads_url
string
uri
required
The API URL to list the downloads on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/downloads"
events_url
string
uri
required
The API URL to list the events of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/events"
forks_url
string
uri
required
The API URL to list the forks of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/forks"
git_commits_url
string
required
A template for the API URL to get information about Git commits of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}"
git_refs_url
string
required
A template for the API URL to get information about Git refs of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}"
git_tags_url
string
required
A template for the API URL to get information about Git tags of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}"
issue_comment_url
string
required
A template for the API URL to get information about issue comments on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}"
issue_events_url
string
required
A template for the API URL to get information about issue events on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}"
issues_url
string
required
A template for the API URL to get information about issues on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/issues{/number}"
keys_url
string
required
A template for the API URL to get information about deploy keys on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}"
labels_url
string
required
A template for the API URL to get information about labels of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/labels{/name}"
languages_url
string
uri
required
The API URL to get information about the languages of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/languages"
merges_url
string
uri
required
The API URL to merge branches in the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/merges"
milestones_url
string
required
A template for the API URL to get information about milestones of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/milestones{/number}"
notifications_url
string
required
A template for the API URL to get information about notifications on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}"
pulls_url
string
required
A template for the API URL to get information about pull requests on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/pulls{/number}"
releases_url
string
required
A template for the API URL to get information about releases on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/releases{/id}"
stargazers_url
string
uri
required
The API URL to list the stargazers on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/stargazers"
statuses_url
string
required
A template for the API URL to get information about statuses of a commit.
- Example
- "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}"
subscribers_url
string
uri
required
The API URL to list the subscribers on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/subscribers"
subscription_url
string
uri
required
The API URL to subscribe to notifications for this repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/subscription"
tags_url
string
uri
required
The API URL to get information about tags on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/tags"
teams_url
string
uri
required
The API URL to list the teams on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/teams"
trees_url
string
required
A template for the API URL to create or retrieve a raw Git tree of the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}"
hooks_url
string
uri
required
The API URL to list the hooks on the repository.
- Example
- "https://api.github.com/repos/octocat/Hello-World/hooks"
Link
string
List code scanning alerts for a repository
Lists code scanning alerts.
To use this endpoint, you must use an access token with the security_events
scope or, for alerts from public repositories only, an access token with the public_repo
scope.
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).
tool_name
string
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
string or null
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
int
Page number of the results to fetch.
- Default
- 1
per_page
int
The number of results per page (max 100).
- Default
- 30
ref
string
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
.
direction
string
The direction to sort the results by.
- Default
- "desc"
- Enum
-
- asc
- desc
sort
string
The property by which to sort the results.
- Default
- "created"
- Enum
-
- created
- updated
state
string
If specified, only code scanning alerts with this state will be returned.
- Enum
-
- open
- closed
- dismissed
- fixed
severity
string
If specified, only code scanning alerts with this severity will be returned.
- Enum
-
- critical
- high
- medium
- low
- warning
- note
- error
owner
string
required
The account owner of the repository. The name is not case sensitive.
repo
string
required
The name of the repository. The name is not case sensitive.
Response
Response
[
{
"number": 4,
"created_at": "2020-02-13T12:29:18Z",
"url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/4",
"html_url": "https://github.com/octocat/hello-world/code-scanning/4",
"state": "open",
"fixed_at": null,
"dismissed_by": null,
"dismissed_at": null,
"dismissed_reason": null,
"dismissed_comment": null,
"rule": {
"id": "js/zipslip",
"severity": "error",
"tags": [
"Security",
"external/cwe/cwe-022"
],
"description": "Arbitrary file write during zip extraction",
"name": "js/zipslip"
},
"tool": {
"name": "CodeQL",
"guid": null,
"version": "2.4.0"
},
"most_recent_instance": {
"ref": "refs/heads/main",
"analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"category": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"environment": "{}",
"state": "open",
"commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930",
"message": {
"text": "This path depends on a user-provided value."
},
"location": {
"path": "spec-main/api-session-spec.ts",
"start_line": 917,
"end_line": 917,
"start_column": 7,
"end_column": 18
},
"classifications": [
"test"
]
},
"instances_url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/4/instances"
},
{
"number": 3,
"created_at": "2020-02-13T12:29:18Z",
"url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/3",
"html_url": "https://github.com/octocat/hello-world/code-scanning/3",
"state": "dismissed",
"fixed_at": null,
"dismissed_by": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"dismissed_at": "2020-02-14T12:29:18Z",
"dismissed_reason": "false positive",
"dismissed_comment": "This alert is not actually correct, because there's a sanitizer included in the library.",
"rule": {
"id": "js/zipslip",
"severity": "error",
"tags": [
"Security",
"external/cwe/cwe-022"
],
"description": "Arbitrary file write during zip extraction",
"name": "js/zipslip"
},
"tool": {
"name": "CodeQL",
"guid": null,
"version": "2.4.0"
},
"most_recent_instance": {
"ref": "refs/heads/main",
"analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"category": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"environment": "{}",
"state": "open",
"commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930",
"message": {
"text": "This path depends on a user-provided value."
},
"location": {
"path": "lib/ab12-gen.js",
"start_line": 917,
"end_line": 917,
"start_column": 7,
"end_column": 18
},
"classifications": []
},
"instances_url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/3/instances"
}
]
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
No schema
code
string
message
string
documentation_url
string
message
string
documentation_url
string
url
string
status
string
message
string
documentation_url
string
url
string
status
string
Not modified
Empty response
Response if GitHub Advanced Security is not enabled for this repository
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Resource not found
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Service unavailable
{
"code": "string",
"message": "string",
"documentation_url": "string"
}
array[object]
- Content Type
- application/json
object
number
int
required
The security alert number.
created_at
string
date-time
required
The time that the alert was created in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
updated_at
string
date-time
The time that the alert was last updated in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
url
string
uri
required
The REST API URL of the alert resource.
html_url
string
uri
required
The GitHub URL of the alert resource.
instances_url
string
uri
required
The REST API URL for fetching the list of instances for an alert.
state
string
required
State of a code scanning alert.
- Enum
-
- open
- closed
- dismissed
- fixed
fixed_at
string or null
date-time
The time that the alert was no longer detected and was considered fixed in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
dismissed_by
object (dismissed_by) or null
required
A GitHub user.
name
string or null
string or null
login
string
required
- Example
- "octocat"
id
int
required
- Example
- 1
node_id
string
required
- Example
- "MDQ6VXNlcjE="
avatar_url
string
uri
required
- Example
- "https://github.com/images/error/octocat_happy.gif"
gravatar_id
string or null
required
- Example
- "41d064eb2195891e12d0413f63227ea7"
url
string
uri
required
- Example
- "https://api.github.com/users/octocat"
html_url
string
uri
required
- Example
- "https://github.com/octocat"
followers_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/followers"
following_url
string
required
- Example
- "https://api.github.com/users/octocat/following{/other_user}"
gists_url
string
required
- Example
- "https://api.github.com/users/octocat/gists{/gist_id}"
starred_url
string
required
- Example
- "https://api.github.com/users/octocat/starred{/owner}{/repo}"
subscriptions_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/subscriptions"
organizations_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/orgs"
repos_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/repos"
events_url
string
required
- Example
- "https://api.github.com/users/octocat/events{/privacy}"
received_events_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/received_events"
type
string
required
- Example
- "User"
site_admin
boolean
required
starred_at
string
- Example
- "\"2020-07-09T00:17:55Z\""
dismissed_at
string or null
date-time
required
The time that the alert was dismissed in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
dismissed_reason
string or null
required
Required when the state is dismissed. The reason for dismissing or closing the alert.
- Enum
-
- null
- false positive
- won't fix
- used in tests
dismissed_comment
string or null
The dismissal comment associated with the dismissal of the alert.
- Max Length
- 280
rule
object (rule)
required
id
string or null
A unique identifier for the rule used to detect the alert.
name
string
The name of the rule used to detect the alert.
tags
array[string] or null
A set of tags applicable for the rule.
string
severity
string or null
The severity of the alert.
- Enum
-
- none
- note
- warning
- error
description
string
A short description of the rule used to detect the alert.
tool
object (tool)
required
name
string
The name of the tool used to generate the code scanning analysis.
version
string or null
The version of the tool used to generate the code scanning analysis.
guid
string or null
The GUID of the tool used to generate the code scanning analysis, if provided in the uploaded SARIF data.
most_recent_instance
object (most_recent_instance)
required
ref
string
The full Git reference, formatted as refs/heads/<branch name>
,
refs/pull/<number>/merge
, or refs/pull/<number>/head
.
analysis_key
string
Identifies the configuration under which the analysis was executed. For example, in GitHub Actions this includes the workflow filename and job name.
environment
string
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.
category
string
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.
state
string
State of a code scanning alert.
- Enum
-
- open
- closed
- dismissed
- fixed
commit_sha
string
message
object (message)
text
string
location
object (location)
Describe a region within a file for the alert.
path
string
start_line
int
end_line
int
start_column
int
end_column
int
html_url
string
classifications
array[string or null]
Classifications that have been applied to the file that triggered the alert. For example identifying it as documentation, or a generated file.
string or null
A classification of the file. For example to identify it as generated.
- Enum
-
- source
- generated
- test
- library
Get a code scanning alert
Gets a single code scanning alert. You must use an access token with the security_events
scope to use this endpoint with private repos, the public_repo
scope also grants permission to read security events on public repos only. GitHub Apps must have the security_events
read permission to use this endpoint.
owner
string
required
The account owner of the repository. The name is not case sensitive.
repo
string
required
The name of the repository. The name is not case sensitive.
alert_number
int
required
The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the number
field in the response from the GET /repos/{owner}/{repo}/code-scanning/alerts
operation.
Response
Response
{
"number": 42,
"created_at": "2020-06-19T11:21:34Z",
"url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/42",
"html_url": "https://github.com/octocat/hello-world/code-scanning/42",
"state": "dismissed",
"fixed_at": null,
"dismissed_by": {
"login": "octocat",
"id": 54933897,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"dismissed_at": "2020-02-14T12:29:18Z",
"dismissed_reason": "false positive",
"dismissed_comment": "This alert is not actually correct, because there's a sanitizer included in the library.",
"rule": {
"id": "js/zipslip",
"severity": "error",
"security_severity_level": "high",
"description": "Arbitrary file write during zip extraction (\"Zip Slip\")",
"name": "js/zipslip",
"full_description": "Extracting files from a malicious zip archive without validating that the destination file path is within the destination directory can cause files outside the destination directory to be overwritten.",
"tags": [
"Security",
"external/cwe/cwe-022"
],
"help": "# Arbitrary file write during zip extraction (\"Zip Slip\")\\nExtracting files from a malicious zip archive without validating that the destination file path is within the destination directory can cause files outside the destination directory to be overwritten ...",
"help_uri": "https://codeql.github.com/"
},
"tool": {
"name": "CodeQL",
"guid": null,
"version": "2.4.0"
},
"most_recent_instance": {
"ref": "refs/heads/main",
"analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"category": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"environment": "{}",
"state": "dismissed",
"commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930",
"message": {
"text": "This path depends on a user-provided value."
},
"location": {
"path": "spec-main/api-session-spec.ts",
"start_line": 917,
"end_line": 917,
"start_column": 7,
"end_column": 18
},
"classifications": [
"test"
]
},
"instances_url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/42/instances"
}
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
No schema
code
string
message
string
documentation_url
string
message
string
documentation_url
string
url
string
status
string
message
string
documentation_url
string
url
string
status
string
Not modified
Empty response
Response if GitHub Advanced Security is not enabled for this repository
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Resource not found
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Service unavailable
{
"code": "string",
"message": "string",
"documentation_url": "string"
}
number
int
required
The security alert number.
created_at
string
date-time
required
The time that the alert was created in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
updated_at
string
date-time
The time that the alert was last updated in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
url
string
uri
required
The REST API URL of the alert resource.
html_url
string
uri
required
The GitHub URL of the alert resource.
instances_url
string
uri
required
The REST API URL for fetching the list of instances for an alert.
state
string
required
State of a code scanning alert.
- Enum
-
- open
- closed
- dismissed
- fixed
fixed_at
string or null
date-time
The time that the alert was no longer detected and was considered fixed in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
dismissed_by
object (dismissed_by) or null
required
A GitHub user.
name
string or null
string or null
login
string
required
- Example
- "octocat"
id
int
required
- Example
- 1
node_id
string
required
- Example
- "MDQ6VXNlcjE="
avatar_url
string
uri
required
- Example
- "https://github.com/images/error/octocat_happy.gif"
gravatar_id
string or null
required
- Example
- "41d064eb2195891e12d0413f63227ea7"
url
string
uri
required
- Example
- "https://api.github.com/users/octocat"
html_url
string
uri
required
- Example
- "https://github.com/octocat"
followers_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/followers"
following_url
string
required
- Example
- "https://api.github.com/users/octocat/following{/other_user}"
gists_url
string
required
- Example
- "https://api.github.com/users/octocat/gists{/gist_id}"
starred_url
string
required
- Example
- "https://api.github.com/users/octocat/starred{/owner}{/repo}"
subscriptions_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/subscriptions"
organizations_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/orgs"
repos_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/repos"
events_url
string
required
- Example
- "https://api.github.com/users/octocat/events{/privacy}"
received_events_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/received_events"
type
string
required
- Example
- "User"
site_admin
boolean
required
starred_at
string
- Example
- "\"2020-07-09T00:17:55Z\""
dismissed_at
string or null
date-time
required
The time that the alert was dismissed in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
dismissed_reason
string or null
required
Required when the state is dismissed. The reason for dismissing or closing the alert.
- Enum
-
- null
- false positive
- won't fix
- used in tests
dismissed_comment
string or null
The dismissal comment associated with the dismissal of the alert.
- Max Length
- 280
rule
object (rule)
required
id
string or null
A unique identifier for the rule used to detect the alert.
name
string
The name of the rule used to detect the alert.
severity
string or null
The severity of the alert.
- Enum
-
- none
- note
- warning
- error
security_severity_level
string or null
The security severity of the alert.
- Enum
-
- low
- medium
- high
- critical
description
string
A short description of the rule used to detect the alert.
full_description
string
description of the rule used to detect the alert.
tags
array[string] or null
A set of tags applicable for the rule.
string
help
string or null
Detailed documentation for the rule as GitHub Flavored Markdown.
help_uri
string or null
A link to the documentation for the rule used to detect the alert.
tool
object (tool)
required
name
string
The name of the tool used to generate the code scanning analysis.
version
string or null
The version of the tool used to generate the code scanning analysis.
guid
string or null
The GUID of the tool used to generate the code scanning analysis, if provided in the uploaded SARIF data.
most_recent_instance
object (most_recent_instance)
required
ref
string
The full Git reference, formatted as refs/heads/<branch name>
,
refs/pull/<number>/merge
, or refs/pull/<number>/head
.
analysis_key
string
Identifies the configuration under which the analysis was executed. For example, in GitHub Actions this includes the workflow filename and job name.
environment
string
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.
category
string
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.
state
string
State of a code scanning alert.
- Enum
-
- open
- closed
- dismissed
- fixed
commit_sha
string
message
object (message)
text
string
location
object (location)
Describe a region within a file for the alert.
path
string
start_line
int
end_line
int
start_column
int
end_column
int
html_url
string
classifications
array[string or null]
Classifications that have been applied to the file that triggered the alert. For example identifying it as documentation, or a generated file.
string or null
A classification of the file. For example to identify it as generated.
- Enum
-
- source
- generated
- test
- library
Update a code scanning alert
Updates the status of a single code scanning alert. You must use an access token with the security_events
scope to use this endpoint with private repositories. You can also use tokens with the public_repo
scope for public repositories only. GitHub Apps must have the security_events
write permission to use this endpoint.
state
string
required
Sets the state of the code scanning alert. You must provide dismissed_reason
when you set the state to dismissed
.
- Enum
-
- open
- dismissed
dismissed_reason
string or null
Required when the state is dismissed. The reason for dismissing or closing the alert.
- Enum
-
- null
- false positive
- won't fix
- used in tests
dismissed_comment
string or null
The dismissal comment associated with the dismissal of the alert.
- Max Length
- 280
owner
string
required
The account owner of the repository. The name is not case sensitive.
repo
string
required
The name of the repository. The name is not case sensitive.
alert_number
int
required
The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the number
field in the response from the GET /repos/{owner}/{repo}/code-scanning/alerts
operation.
Request
{
"state": "dismissed",
"dismissed_reason": "false positive",
"dismissed_comment": "This alert is not actually correct, because there's a sanitizer included in the library."
}
Response
Response
{
"number": 42,
"created_at": "2020-08-25T21:28:36Z",
"url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/42",
"html_url": "https://github.com/octocat/hello-world/code-scanning/42",
"state": "dismissed",
"fixed_at": null,
"dismissed_by": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"dismissed_at": "2020-09-02T22:34:56Z",
"dismissed_reason": "false positive",
"dismissed_comment": "This alert is not actually correct, because there's a sanitizer included in the library.",
"rule": {
"id": "js/zipslip",
"severity": "error",
"security_severity_level": "high",
"description": "Arbitrary file write during zip extraction (\"Zip Slip\")",
"name": "js/zipslip",
"full_description": "Extracting files from a malicious zip archive without validating that the destination file path is within the destination directory can cause files outside the destination directory to be overwritten.",
"tags": [
"Security",
"external/cwe/cwe-022"
],
"help": "# Arbitrary file write during zip extraction (\"Zip Slip\")\\nExtracting files from a malicious zip archive without validating that the destination file path is within the destination directory can cause files outside the destination directory to be overwritten ...",
"help_uri": "https://codeql.github.com/"
},
"tool": {
"name": "CodeQL",
"guid": null,
"version": "2.4.0"
},
"most_recent_instance": {
"ref": "refs/heads/main",
"analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"category": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"environment": "{}",
"state": "dismissed",
"commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930",
"message": {
"text": "This path depends on a user-provided value."
},
"location": {
"path": "spec-main/api-session-spec.ts",
"start_line": 917,
"end_line": 917,
"start_column": 7,
"end_column": 18
},
"classifications": [
"test"
]
},
"instances_url": "https://api.github.com/repos/octocat/hello-world/code-scanning/alerts/42/instances"
}
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
code
string
message
string
documentation_url
string
message
string
documentation_url
string
url
string
status
string
message
string
documentation_url
string
url
string
status
string
Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Resource not found
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Service unavailable
{
"code": "string",
"message": "string",
"documentation_url": "string"
}
number
int
required
The security alert number.
created_at
string
date-time
required
The time that the alert was created in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
updated_at
string
date-time
The time that the alert was last updated in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
url
string
uri
required
The REST API URL of the alert resource.
html_url
string
uri
required
The GitHub URL of the alert resource.
instances_url
string
uri
required
The REST API URL for fetching the list of instances for an alert.
state
string
required
State of a code scanning alert.
- Enum
-
- open
- closed
- dismissed
- fixed
fixed_at
string or null
date-time
The time that the alert was no longer detected and was considered fixed in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
dismissed_by
object (dismissed_by) or null
required
A GitHub user.
name
string or null
string or null
login
string
required
- Example
- "octocat"
id
int
required
- Example
- 1
node_id
string
required
- Example
- "MDQ6VXNlcjE="
avatar_url
string
uri
required
- Example
- "https://github.com/images/error/octocat_happy.gif"
gravatar_id
string or null
required
- Example
- "41d064eb2195891e12d0413f63227ea7"
url
string
uri
required
- Example
- "https://api.github.com/users/octocat"
html_url
string
uri
required
- Example
- "https://github.com/octocat"
followers_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/followers"
following_url
string
required
- Example
- "https://api.github.com/users/octocat/following{/other_user}"
gists_url
string
required
- Example
- "https://api.github.com/users/octocat/gists{/gist_id}"
starred_url
string
required
- Example
- "https://api.github.com/users/octocat/starred{/owner}{/repo}"
subscriptions_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/subscriptions"
organizations_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/orgs"
repos_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/repos"
events_url
string
required
- Example
- "https://api.github.com/users/octocat/events{/privacy}"
received_events_url
string
uri
required
- Example
- "https://api.github.com/users/octocat/received_events"
type
string
required
- Example
- "User"
site_admin
boolean
required
starred_at
string
- Example
- "\"2020-07-09T00:17:55Z\""
dismissed_at
string or null
date-time
required
The time that the alert was dismissed in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
dismissed_reason
string or null
required
Required when the state is dismissed. The reason for dismissing or closing the alert.
- Enum
-
- null
- false positive
- won't fix
- used in tests
dismissed_comment
string or null
The dismissal comment associated with the dismissal of the alert.
- Max Length
- 280
rule
object (rule)
required
id
string or null
A unique identifier for the rule used to detect the alert.
name
string
The name of the rule used to detect the alert.
severity
string or null
The severity of the alert.
- Enum
-
- none
- note
- warning
- error
security_severity_level
string or null
The security severity of the alert.
- Enum
-
- low
- medium
- high
- critical
description
string
A short description of the rule used to detect the alert.
full_description
string
description of the rule used to detect the alert.
tags
array[string] or null
A set of tags applicable for the rule.
string
help
string or null
Detailed documentation for the rule as GitHub Flavored Markdown.
help_uri
string or null
A link to the documentation for the rule used to detect the alert.
tool
object (tool)
required
name
string
The name of the tool used to generate the code scanning analysis.
version
string or null
The version of the tool used to generate the code scanning analysis.
guid
string or null
The GUID of the tool used to generate the code scanning analysis, if provided in the uploaded SARIF data.
most_recent_instance
object (most_recent_instance)
required
ref
string
The full Git reference, formatted as refs/heads/<branch name>
,
refs/pull/<number>/merge
, or refs/pull/<number>/head
.
analysis_key
string
Identifies the configuration under which the analysis was executed. For example, in GitHub Actions this includes the workflow filename and job name.
environment
string
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.
category
string
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.
state
string
State of a code scanning alert.
- Enum
-
- open
- closed
- dismissed
- fixed
commit_sha
string
message
object (message)
text
string
location
object (location)
Describe a region within a file for the alert.
path
string
start_line
int
end_line
int
start_column
int
end_column
int
html_url
string
classifications
array[string or null]
Classifications that have been applied to the file that triggered the alert. For example identifying it as documentation, or a generated file.
string or null
A classification of the file. For example to identify it as generated.
- Enum
-
- source
- generated
- test
- library
List instances of a code scanning alert
Lists all instances of the specified code scanning alert.
You must use an access token with the security_events
scope to use this endpoint with private repos,
the public_repo
scope also grants permission to read security events on public repos only.
GitHub Apps must have the security_events
read permission to use this endpoint.
page
int
Page number of the results to fetch.
- Default
- 1
per_page
int
The number of results per page (max 100).
- Default
- 30
ref
string
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
.
owner
string
required
The account owner of the repository. The name is not case sensitive.
repo
string
required
The name of the repository. The name is not case sensitive.
alert_number
int
required
The number that identifies an alert. You can find this at the end of the URL for a code scanning alert within GitHub, and in the number
field in the response from the GET /repos/{owner}/{repo}/code-scanning/alerts
operation.
Response
Response
[
{
"ref": "refs/heads/main",
"analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"environment": "",
"category": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"state": "open",
"fixed_at": null,
"commit_sha": "39406e42cb832f683daa691dd652a8dc36ee8930",
"message": {
"text": "This path depends on a user-provided value."
},
"location": {
"path": "lib/ab12-gen.js",
"start_line": 917,
"end_line": 917,
"start_column": 7,
"end_column": 18
},
"classifications": [
"library"
]
},
{
"ref": "refs/pull/3740/merge",
"analysis_key": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"environment": "",
"category": ".github/workflows/codeql-analysis.yml:CodeQL-Build",
"state": "fixed",
"fixed_at": "2020-02-14T12:29:18Z",
"commit_sha": "b09da05606e27f463a2b49287684b4ae777092f2",
"message": {
"text": "This suffix check is missing a length comparison to correctly handle lastIndexOf returning -1."
},
"location": {
"path": "app/script.js",
"start_line": 2,
"end_line": 2,
"start_column": 10,
"end_column": 50
},
"classifications": [
"source"
]
}
]
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
code
string
message
string
documentation_url
string
message
string
documentation_url
string
url
string
status
string
message
string
documentation_url
string
url
string
status
string
Response if GitHub Advanced Security is not enabled for this repository
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Resource not found
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Service unavailable
{
"code": "string",
"message": "string",
"documentation_url": "string"
}
array[object]
- Content Type
- application/json
object
ref
string
The full Git reference, formatted as refs/heads/<branch name>
,
refs/pull/<number>/merge
, or refs/pull/<number>/head
.
analysis_key
string
Identifies the configuration under which the analysis was executed. For example, in GitHub Actions this includes the workflow filename and job name.
environment
string
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.
category
string
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.
state
string
State of a code scanning alert.
- Enum
-
- open
- closed
- dismissed
- fixed
commit_sha
string
message
object (message)
text
string
location
object (location)
Describe a region within a file for the alert.
path
string
start_line
int
end_line
int
start_column
int
end_column
int
html_url
string
classifications
array[string or null]
Classifications that have been applied to the file that triggered the alert. For example identifying it as documentation, or a generated file.
string or null
A classification of the file. For example to identify it as generated.
- Enum
-
- source
- generated
- test
- library
List code scanning analyses for a repository
Lists the details of all code scanning analyses for a repository,
starting with the most recent.
The response is paginated and you can use the page
and per_page
parameters
to list the analyses you're interested in.
By default 30 analyses are listed per page.
The rules_count
field in the response give the number of rules
that were run in the analysis.
For very old analyses this data is not available,
and 0
is returned in this field.
You must use an access token with the security_events
scope to use this endpoint with private repos,
the public_repo
scope also grants permission to read security events on public repos only.
GitHub Apps must have the security_events
read permission to use this endpoint.
Deprecation notice:
The tool_name
field is deprecated and will, in future, not be included in the response for this endpoint. The example response reflects this change. The tool name can now be found inside the tool
field.
tool_name
string
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
string or null
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
int
Page number of the results to fetch.
- Default
- 1
per_page
int
The number of results per page (max 100).
- Default
- 30
ref
string
The Git reference for the analyses 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
.
sarif_id
string
Filter analyses belonging to the same SARIF upload.
- Example
- "6c81cd8e-b078-4ac3-a3be-1dad7dbd0b53"
direction
string
The direction to sort the results by.
- Default
- "desc"
- Enum
-
- asc
- desc
sort
string
The property by which to sort the results.
- Default
- "created"
- Enum
-
- created
owner
string
required
The account owner of the repository. The name is not case sensitive.
repo
string
required
The name of the repository. The name is not case sensitive.
Response
Response
[
{
"ref": "refs/heads/main",
"commit_sha": "d99612c3e1f2970085cfbaeadf8f010ef69bad83",
"analysis_key": ".github/workflows/codeql-analysis.yml:analyze",
"environment": "{\"language\":\"python\"}",
"error": "",
"category": ".github/workflows/codeql-analysis.yml:analyze/language:python",
"created_at": "2020-08-27T15:05:21Z",
"results_count": 17,
"rules_count": 49,
"id": 201,
"url": "https://api.github.com/repos/octocat/hello-world/code-scanning/analyses/201",
"sarif_id": "6c81cd8e-b078-4ac3-a3be-1dad7dbd0b53",
"tool": {
"name": "CodeQL",
"guid": null,
"version": "2.4.0"
},
"deletable": true,
"warning": ""
},
{
"ref": "refs/heads/my-branch",
"commit_sha": "c8cff6510d4d084fb1b4aa13b64b97ca12b07321",
"analysis_key": ".github/workflows/shiftleft.yml:build",
"environment": "{}",
"error": "",
"category": ".github/workflows/shiftleft.yml:build/",
"created_at": "2020-08-31T22:46:44Z",
"results_count": 17,
"rules_count": 32,
"id": 200,
"url": "https://api.github.com/repos/octocat/hello-world/code-scanning/analyses/200",
"sarif_id": "8981cd8e-b078-4ac3-a3be-1dad7dbd0b582",
"tool": {
"name": "Python Security Analysis",
"guid": null,
"version": "1.2.0"
},
"deletable": true,
"warning": ""
}
]
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
code
string
message
string
documentation_url
string
message
string
documentation_url
string
url
string
status
string
message
string
documentation_url
string
url
string
status
string
Response if GitHub Advanced Security is not enabled for this repository
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Resource not found
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Service unavailable
{
"code": "string",
"message": "string",
"documentation_url": "string"
}
array[object]
- Content Type
- application/json
object
ref
string
required
The full Git reference, formatted as refs/heads/<branch name>
,
refs/pull/<number>/merge
, or refs/pull/<number>/head
.
commit_sha
string
^[0-9a-fA-F]+$
required
The SHA of the commit to which the analysis you are uploading relates.
- Min Length
- 40
- Max Length
- 40
analysis_key
string
required
Identifies the configuration under which the analysis was executed. For example, in GitHub Actions this includes the workflow filename and job name.
environment
string
required
Identifies the variable values associated with the environment in which this analysis was performed.
category
string
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.
error
string
required
- Example
- "error reading field xyz"
created_at
string
date-time
required
The time that the analysis was created in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
results_count
int
required
The total number of results in the analysis.
rules_count
int
required
The total number of rules used in the analysis.
id
int
required
Unique identifier for this analysis.
url
string
uri
required
The REST API URL of the analysis resource.
sarif_id
string
required
An identifier for the upload.
- Example
- "6c81cd8e-b078-4ac3-a3be-1dad7dbd0b53"
tool
object (tool)
required
name
string
The name of the tool used to generate the code scanning analysis.
version
string or null
The version of the tool used to generate the code scanning analysis.
guid
string or null
The GUID of the tool used to generate the code scanning analysis, if provided in the uploaded SARIF data.
deletable
boolean
required
warning
string
required
Warning generated when processing the analysis
- Example
- "123 results were ignored"
Get a code scanning analysis for a repository
Gets a specified code scanning analysis for a repository.
You must use an access token with the security_events
scope to use this endpoint with private repos,
the public_repo
scope also grants permission to read security events on public repos only.
GitHub Apps must have the security_events
read permission to use this endpoint.
The default JSON response contains fields that describe the analysis. This includes the Git reference and commit SHA to which the analysis relates, the datetime of the analysis, the name of the code scanning tool, and the number of alerts.
The rules_count
field in the default response give the number of rules
that were run in the analysis.
For very old analyses this data is not available,
and 0
is returned in this field.
If you use the Accept header application/sarif+json
,
the response contains the analysis data that was uploaded.
This is formatted as
SARIF version 2.1.0.
owner
string
required
The account owner of the repository. The name is not case sensitive.
repo
string
required
The name of the repository. The name is not case sensitive.
analysis_id
int
required
The ID of the analysis, as returned from the GET /repos/{owner}/{repo}/code-scanning/analyses
operation.
Response
Response
{
"ref": "refs/heads/main",
"commit_sha": "c18c69115654ff0166991962832dc2bd7756e655",
"analysis_key": ".github/workflows/codeql-analysis.yml:analyze",
"environment": "{\"language\":\"javascript\"}",
"error": "",
"category": ".github/workflows/codeql-analysis.yml:analyze/language:javascript",
"created_at": "2021-01-13T11:55:49Z",
"results_count": 3,
"rules_count": 67,
"id": 3602840,
"url": "https://api.github.com/repos/octocat/hello-world/code-scanning/analyses/201",
"sarif_id": "47177e22-5596-11eb-80a1-c1e54ef945c6",
"tool": {
"name": "CodeQL",
"guid": null,
"version": "2.4.0"
},
"deletable": true,
"warning": ""
}
{
"runs": [
{
"tool": {
"driver": {
"name": "CodeQL",
"organization": "GitHub",
"semanticVersion": "1.0.0",
"rules": [
{
"id": "js/unused-local-variable",
"name": "js/unused-local-variable"
}
]
}
},
"results": [
{
"guid": "326aa09f-9af8-13cf-9851-3d0e5183ec38",
"message": {
"text": "Unused variable foo."
},
"locations": [
{
"physicalLocation": {
"artifactLocation": {
"uri": "file1.js"
},
"region": {
"startLine": 1
}
}
}
],
"ruleId": "js/unused-local-variable",
"properties": [
{
"github/alertNumber": 2
},
{
"github/alertUrl": "https://api.github.com/repos/monalisa/monalisa/code-scanning/alerts/2"
}
]
}
]
}
]
}
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
code
string
message
string
documentation_url
string
message
string
documentation_url
string
url
string
status
string
message
string
documentation_url
string
url
string
status
string
Response if GitHub Advanced Security is not enabled for this repository
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Resource not found
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Service unavailable
{
"code": "string",
"message": "string",
"documentation_url": "string"
}
ref
string
required
The full Git reference, formatted as refs/heads/<branch name>
,
refs/pull/<number>/merge
, or refs/pull/<number>/head
.
commit_sha
string
^[0-9a-fA-F]+$
required
The SHA of the commit to which the analysis you are uploading relates.
- Min Length
- 40
- Max Length
- 40
analysis_key
string
required
Identifies the configuration under which the analysis was executed. For example, in GitHub Actions this includes the workflow filename and job name.
environment
string
required
Identifies the variable values associated with the environment in which this analysis was performed.
category
string
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.
error
string
required
- Example
- "error reading field xyz"
created_at
string
date-time
required
The time that the analysis was created in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
results_count
int
required
The total number of results in the analysis.
rules_count
int
required
The total number of rules used in the analysis.
id
int
required
Unique identifier for this analysis.
url
string
uri
required
The REST API URL of the analysis resource.
sarif_id
string
required
An identifier for the upload.
- Example
- "6c81cd8e-b078-4ac3-a3be-1dad7dbd0b53"
tool
object (tool)
required
name
string
The name of the tool used to generate the code scanning analysis.
version
string or null
The version of the tool used to generate the code scanning analysis.
guid
string or null
The GUID of the tool used to generate the code scanning analysis, if provided in the uploaded SARIF data.
deletable
boolean
required
warning
string
required
Warning generated when processing the analysis
- Example
- "123 results were ignored"
No schema
Delete a code scanning analysis from a repository
Deletes a specified code scanning analysis from a repository. For
private repositories, you must use an access token with the repo
scope. For public repositories,
you must use an access token with public_repo
scope.
GitHub Apps must have the security_events
write permission to use this endpoint.
You can delete one analysis at a time. To delete a series of analyses, start with the most recent analysis and work backwards. Conceptually, the process is similar to the undo function in a text editor.
When you list the analyses for a repository, one or more will be identified as deletable in the response:
"deletable": true
An analysis is deletable when it's the most recent in a set of analyses. Typically, a repository will have multiple sets of analyses for each enabled code scanning tool, where a set is determined by a unique combination of analysis values:
ref
tool
category
If you attempt to delete an analysis that is not the most recent in a set, you'll get a 400 response with the message:
Analysis specified is not deletable.
The response from a successful DELETE
operation provides you with
two alternative URLs for deleting the next analysis in the set:
next_analysis_url
and confirm_delete_url
.
Use the next_analysis_url
URL if you want to avoid accidentally deleting the final analysis
in a set. This is a useful option if you want to preserve at least one analysis
for the specified tool in your repository.
Use the confirm_delete_url
URL if you are content to remove all analyses for a tool.
When you delete the last analysis in a set, the value of next_analysis_url
and confirm_delete_url
in the 200 response is null
.
As an example of the deletion process, let's imagine that you added a workflow that configured a particular code scanning tool to analyze the code in a repository. This tool has added 15 analyses: 10 on the default branch, and another 5 on a topic branch. You therefore have two separate sets of analyses for this tool. You've now decided that you want to remove all of the analyses for the tool. To do this you must make 15 separate deletion requests. To start, you must find an analysis that's identified as deletable. Each set of analyses always has one that's identified as deletable. Having found the deletable analysis for one of the two sets, delete this analysis and then continue deleting the next analysis in the set until they're all deleted. Then repeat the process for the second set. The procedure therefore consists of a nested loop:
Outer loop:
List the analyses for the repository, filtered by tool.
Parse this list to find a deletable analysis. If found:
Inner loop:
- Delete the identified analysis.
- Parse the response for the value of
confirm_delete_url
and, if found, use this in the next iteration.
The above process assumes that you want to remove all trace of the tool's analyses from the GitHub user interface, for the specified repository, and it therefore uses the confirm_delete_url
value. Alternatively, you could use the next_analysis_url
value, which would leave the last analysis in each set undeleted to avoid removing a tool's analysis entirely.
confirm_delete
string or null
Allow deletion if the specified analysis is the last in a set. If you attempt to delete the final analysis in a set without setting this parameter to true
, you'll get a 400 response with the message: Analysis is last of its type and deletion may result in the loss of historical alert data. Please specify confirm_delete.
owner
string
required
The account owner of the repository. The name is not case sensitive.
repo
string
required
The name of the repository. The name is not case sensitive.
analysis_id
int
required
The ID of the analysis, as returned from the GET /repos/{owner}/{repo}/code-scanning/analyses
operation.
Response
Response
{
"next_analysis_url": "https://api.github.com/repos/octocat/hello-world/code-scanning/analyses/41",
"confirm_delete_url": "https://api.github.com/repos/octocat/hello-world/code-scanning/analyses/41?confirm_delete"
}
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
code
string
message
string
documentation_url
string
message
string
documentation_url
string
url
string
status
string
message
string
documentation_url
string
url
string
status
string
message
string
documentation_url
string
url
string
status
string
message
string or null
documentation_url
string or null
detail
string or null
status
int
scimType
string or null
schemas
array[string]
string
Bad Request
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Resource not found
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Service unavailable
{
"code": "string",
"message": "string",
"documentation_url": "string"
}
next_analysis_url
string or null
uri
required
Next deletable analysis in chain, without last analysis deletion confirmation
confirm_delete_url
string or null
uri
required
Next deletable analysis in chain, with last analysis deletion confirmation
Get a code scanning default setup configuration
Gets a code scanning default setup configuration.
You must use an access token with the repo
scope to use this endpoint with private repos or the public_repo
scope for public repos. GitHub Apps must have the repo
write permission to use this endpoint.
owner
string
required
The account owner of the repository. The name is not case sensitive.
repo
string
required
The name of the repository. The name is not case sensitive.
Response
Response
{
"state": "configured",
"languages": [
"ruby",
"javascript",
"python"
],
"query_suite": "default",
"updated_at": "2023-01-19T11:21:34Z"
}
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
code
string
message
string
documentation_url
string
message
string
documentation_url
string
url
string
status
string
message
string
documentation_url
string
url
string
status
string
Response if GitHub Advanced Security is not enabled for this repository
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Resource not found
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Service unavailable
{
"code": "string",
"message": "string",
"documentation_url": "string"
}
state
string
Code scanning default setup has been configured or not.
- Enum
-
- configured
- not-configured
languages
array[string]
Languages to be analysed.
string
- Enum
-
- c
- cpp
- csharp
- go
- java
- javascript
- kotlin
- python
- ruby
- typescript
query_suite
string
CodeQL query suite to be used.
- Enum
-
- default
- extended
updated_at
string or null
date-time
Timestamp of latest configuration update.
- Example
- "2023-12-06T14:20:20.000Z"
Update a code scanning default setup configuration
Updates a code scanning default setup configuration.
You must use an access token with the repo
scope to use this endpoint with private repos or the public_repo
scope for public repos. GitHub Apps must have the repo
write permission to use this endpoint.
state
string
required
Whether code scanning default setup has been configured or not.
- Enum
-
- configured
- not-configured
query_suite
string
CodeQL query suite to be used.
- Enum
-
- default
- extended
owner
string
required
The account owner of the repository. The name is not case sensitive.
repo
string
required
The name of the repository. The name is not case sensitive.
Request
{
"state": "configured"
}
Response
Response
{}
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
No schema
code
string
message
string
documentation_url
string
message
string
documentation_url
string
url
string
status
string
message
string
documentation_url
string
url
string
status
string
message
string
documentation_url
string
url
string
status
string
Response
{
"run_id": 42,
"run_url": "https://api.github.com/repos/octoorg/octocat/actions/runs/42"
}
Response if GitHub Advanced Security is not enabled for this repository
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Resource not found
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Response if there is already a validation run in progress with a different default setup configuration
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Service unavailable
{
"code": "string",
"message": "string",
"documentation_url": "string"
}
run_id
int
ID of the corresponding run.
run_url
string
URL of the corresponding run.
Upload an analysis as SARIF data
Uploads SARIF data containing the results of a code scanning analysis to make the results available in a repository. You must use an access token with the security_events
scope to use this endpoint for private repositories. You can also use tokens with the public_repo
scope for public repositories only. GitHub Apps must have the security_events
write permission to use this endpoint.
There are two places where you can upload code scanning results.
- If you upload to a pull request, for example
--ref refs/pull/42/merge
or--ref refs/pull/42/head
, then the results appear as alerts in a pull request check. For more information, see "Triaging code scanning alerts in pull requests." - If you upload to a branch, for example
--ref refs/heads/my-branch
, then the results appear in the Security tab for your repository. For more information, see "Managing code scanning alerts for your repository."
You must compress the SARIF-formatted analysis data that you want to upload, using gzip
, and then encode it as a Base64 format string. For example:
gzip -c analysis-data.sarif | base64 -w0
SARIF upload supports a maximum number of entries per the following data objects, and an analysis will be rejected if any of these objects is above its maximum value. For some objects, there are additional values over which the entries will be ignored while keeping the most important entries whenever applicable. To get the most out of your analysis when it includes data above the supported limits, try to optimize the analysis configuration. For example, for the CodeQL tool, identify and remove the most noisy queries.
The 202 Accepted
response includes an id
value.
You can use this ID to check the status of the upload by using it in the /sarifs/{sarif_id}
endpoint.
For more information, see "Get information about a SARIF upload."
commit_sha
string
^[0-9a-fA-F]+$
required
The SHA of the commit to which the analysis you are uploading relates.
- Min Length
- 40
- Max Length
- 40
ref
string
required
The full Git reference, formatted as refs/heads/<branch name>
,
refs/pull/<number>/merge
, or refs/pull/<number>/head
.
sarif
string
required
A Base64 string representing the SARIF file to upload. You must first compress your SARIF file using gzip
and then translate the contents of the file into a Base64 encoding string. For more information, see "SARIF support for code scanning."
checkout_uri
string
uri
The base directory used in the analysis, as it appears in the SARIF file. This property is used to convert file paths from absolute to relative, so that alerts can be mapped to their correct location in the repository.
- Example
- "file:///github/workspace/"
started_at
string
date-time
The time that the analysis run began. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
.
tool_name
string
The name of the tool used to generate the code scanning analysis. If this parameter is not used, the tool name defaults to "API". If the uploaded SARIF contains a tool GUID, this will be available for filtering using the tool_guid
parameter of operations such as GET /repos/{owner}/{repo}/code-scanning/alerts
.
owner
string
required
The account owner of the repository. The name is not case sensitive.
repo
string
required
The name of the repository. The name is not case sensitive.
Request
{
"commit_sha": "4b6472266afd7b471e86085a6659e8c7f2b119da",
"ref": "refs/heads/master",
"sarif": "H4sICMLGdF4AA2V4YW1wbGUuc2FyaWYAvVjdbts2FL7PUxDCijaA/CM7iRNfLkPXYgHSNstumlzQ0pHFVCI1korjFgH2ONtr7Ul2KFmy/mOn6QIkjsjDw0/nfN85NL8dEGL9pNwAImqRObECrWM1H40kXQ2XTAfJIlEgXcE1cD10RTQSVDE10K4aKSqZP1AxuKOIKg1ydJU60jSfSh8Hk6EzHA/vlOCWbfa7B6kYPpj90rlsWCZcmbHP5Bs+4oAWIjQD2SMOeJLh2vIQDnIaQerqXHjw8YIgxohybxAyDsS4cAPKsp03K4RcUs6+Up2D+JXpd8mibKIQN9fM/aMCdbyBujGSSQgVxJtx5qX2d2qUcIweQhEuDQf3GBO6CKHkogx/N3MVCKl/AeVKFuf4y5ubsMGDTj1ep+5I7sgmLIpxtU38hLtmMRGSuCFVyip5eKzs5ydh+LztVL6f2m6oih1BkYiuyQIIJWodxVpERPj4sEiWBNNH8EWT0DMG8EAjzKVHXCrB4FkPu/F64NMk1OeC+2yZSNoBOoR7CC0EzYWGbm+xFDFIzbI011+cLjfZtyJkmMZfumAh02uL3NpV2y+MZ6RAjxibyKrNxxJcVjANSb4eBGwZ1M0KsuyR2poLr5rMl8vaDSeVn6eTWEO2j2xIEcmhwlTKNOi4GMOI8gfuZYkvJ7b4v5Tiumyz7RnHeodFzpS8ASIZCH/AYdWi2z3sG8JtFxJ6fF9yR9CdifBr9Pd6d5V2+zbJKjjCFGGmsHuYFy2ytJq9tUxcLSRSQecppOGKrpUxYfxefMEFK+wOGa4hudQByBVT0L+EKtyACxnRsABhEx1QjVDs1KNI9MbpnhqfE45B6FJvu3hRu5VRU9MhZLmK7fqkKyQSTHNoyMqUFMqXCV3CwAeqEwmVokraK8IuBaGvHjQ0gMYrKjnjyw7uk9uD8tgmsBbFMPnU1bV2ZhkJNkuolUiWys3UPWzs5aaIUz9TBe8zMb+6+nT+6fLy91dlE3xzeDDT4zYszb0bW6NjJd0Rvn2EnLvWLFSdKPpBzInzfRgu8ETyMcH8nIfMnJCeC2PyfTA+UKngcnGH7Hw2hGkVQs5YlIRCtdWZYQ4/73es2JlxkfViOEIhoWJq5Oo6UBBfiKIqFBWhiE3jJGbFwVoxBHTRSuIS67sMeplei24X20shLjG+8gqbKC/bESiNMC+wd5q5id0yeS7CJEqXzmrTWNq3k05l84P6f4/bEmXFJjI0fIt1BGQssUnUDkBYeVhE5TqPnMH3jqogDcP0zKcTgLPTMSzOjhbjuVOmW23l1fYNStulfo6sXlFsGLhbDy5RECPRYGCTgOj2bd4nUQEivEd0H7KKYxqnEhFohuur3a3UPskbH/+Yg0+M5P2MHRJu3ziHh3Z2NCrWt3XF1rWTw8Ne/pfbWYXnDSE0SNZQQt1i18q7te2vOhu7ehWuvVyeu0wbLZi24mhoo6aOOTltzG/lgdVvVoXQq5V+pewkFIzL8fjEcadT55jOjpzFzHuOTtDNrMkJPMVQDd7F09RID72O/UPZ0tmctqZ7kWX6EmSZnDpP8GU67SXM8XE3YSrxbKsx6UReZ4y6n/FVZfJjs9Z7stma75W5yQtkzjk5eSJxk1lv4o7+j8TlhaJ2lsKWZO6lruDPBLib3x5ZN/KGWzZ+pn///evv7OOf4iIBv3oY9L/l1wiJ9p0Tc+F1zZnOE9NxXWEus6IQhr5pMfoqxi8WPsuu0azsns4UC6WzNzHIzbeEx4P/AJ3SefgcFAAA"
}
Response
Response
{
"id": "47177e22-5596-11eb-80a1-c1e54ef945c6",
"url": "https://api.github.com/repos/octocat/hello-world/code-scanning/sarifs/47177e22-5596-11eb-80a1-c1e54ef945c6"
}
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
No schema
No schema
code
string
message
string
documentation_url
string
message
string
documentation_url
string
url
string
status
string
message
string
documentation_url
string
url
string
status
string
Bad Request if the sarif field is invalid
Empty response
Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Resource not found
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Payload Too Large if the sarif field is too large
Empty response
Service unavailable
{
"code": "string",
"message": "string",
"documentation_url": "string"
}
id
string
An identifier for the upload.
- Example
- "6c81cd8e-b078-4ac3-a3be-1dad7dbd0b53"
url
string
uri
The REST API URL for checking the status of the upload.
Get information about a SARIF upload
Gets information about a SARIF upload, including the status and the URL of the analysis that was uploaded so that you can retrieve details of the analysis. For more information, see "Get a code scanning analysis for a repository." You must use an access token with the security_events
scope to use this endpoint with private repos, the public_repo
scope also grants permission to read security events on public repos only. GitHub Apps must have the security_events
read permission to use this endpoint.
owner
string
required
The account owner of the repository. The name is not case sensitive.
repo
string
required
The name of the repository. The name is not case sensitive.
sarif_id
string
required
The SARIF ID obtained after uploading.
Response
Response
{
"processing_status": "complete",
"analyses_url": "https://api.github.com/repos/octocat/hello-world/code-scanning/analyses?sarif_id=47177e22-5596-11eb-80a1-c1e54ef945c6"
}
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
Empty response
No schema
code
string
message
string
documentation_url
string
message
string
documentation_url
string
url
string
status
string
Response if GitHub Advanced Security is not enabled for this repository
{
"message": "string",
"documentation_url": "string",
"url": "string",
"status": "string"
}
Not Found if the sarif id does not match any upload
Empty response
Service unavailable
{
"code": "string",
"message": "string",
"documentation_url": "string"
}
processing_status
string
pending
files have not yet been processed, while complete
means results from the SARIF have been stored. failed
files have either not been processed at all, or could only be partially processed.
- Enum
-
- pending
- complete
- failed
analyses_url
string or null
uri
The REST API URL for getting the analyses associated with the upload.
errors
array[string] or null
Any errors that ocurred during processing of the delivery.
string
Was this page helpful?