Skip to main content

alert_instances

Creates, updates, deletes, gets or lists an alert_instances resource.

Overview

Namealert_instances
TypeResource
Idgithub.code_scanning.alert_instances

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
analysis_keystringIdentifies the configuration under which the analysis was executed. For example, in GitHub Actions this includes the workflow filename and job name.
categorystringIdentifies 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.
classificationsarrayClassifications that have been applied to the file that triggered the alert. For example identifying it as documentation, or a generated file.
commit_shastring
environmentstringIdentifies 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.
html_urlstring
locationobjectDescribe a region within a file for the alert.
messageobject
refstringThe Git reference, formatted as refs/pull/<number>/merge, refs/pull/<number>/head, refs/heads/<branch name> or simply <branch name>.
statestringState of a code scanning alert instance. (open, fixed)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_alert_instancesselectowner, repo, alert_numberpage, per_page, ref, prLists all instances of the specified code scanning alert.

OAuth app tokens and personal access tokens (classic) need the security_events scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
alert_numberintegerThe 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/&#123;owner&#125;/&#123;repo&#125;/code-scanning/alerts operation.
ownerstringThe account owner of the repository. The name is not case sensitive.
repostringThe name of the repository without the .git extension. The name is not case sensitive.
pageintegerThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pageintegerThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
printegerThe number of the pull request for the results you want to list.
refstringThe 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.

SELECT examples

Lists all instances of the specified code scanning alert.

OAuth app tokens and personal access tokens (classic) need the security_events scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.

SELECT
analysis_key,
category,
classifications,
commit_sha,
environment,
html_url,
location,
message,
ref,
state
FROM github.code_scanning.alert_instances
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND alert_number = '{{ alert_number }}' -- required
AND page = '{{ page }}'
AND per_page = '{{ per_page }}'
AND ref = '{{ ref }}'
AND pr = '{{ pr }}'
;