Skip to main content

alerts

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

Overview

Namealerts
TypeResource
Idgithub.code_scanning.alerts

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
assigneesarray
created_atstring (date-time)The time that the alert was created in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
dismissal_approved_byobjectA GitHub user. (title: Simple User)
dismissed_atstring (date-time)The time that the alert was dismissed in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
dismissed_byobjectA GitHub user. (title: Simple User)
dismissed_commentstringThe dismissal comment associated with the dismissal of the alert.
dismissed_reasonstringRequired when the state is dismissed. The reason for dismissing or closing the alert. (false positive, won't fix, used in tests)
fixed_atstring (date-time)The time that the alert was no longer detected and was considered fixed in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
html_urlstring (uri)The GitHub URL of the alert resource.
instances_urlstring (uri)The REST API URL for fetching the list of instances for an alert.
most_recent_instanceobject
numberintegerThe security alert number.
ruleobject
statestringState of a code scanning alert. (open, dismissed, fixed)
toolobject
updated_atstring (date-time)The time that the alert was last updated in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
urlstring (uri)The REST API URL of the alert resource.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_alertselectowner, repo, alert_numberGets a single 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.
update_alertupdateowner, repo, alert_number, state, assigneesUpdates the status of a single 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/{owner}/{repo}/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.

SELECT examples

Gets a single 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
assignees,
created_at,
dismissal_approved_by,
dismissed_at,
dismissed_by,
dismissed_comment,
dismissed_reason,
fixed_at,
html_url,
instances_url,
most_recent_instance,
number,
rule,
state,
tool,
updated_at,
url
FROM github.code_scanning.alerts
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND alert_number = '{{ alert_number }}' -- required
;

UPDATE examples

Updates the status of a single 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.

UPDATE github.code_scanning.alerts
SET
state = '{{ state }}',
dismissed_reason = '{{ dismissed_reason }}',
dismissed_comment = '{{ dismissed_comment }}',
create_request = {{ create_request }},
assignees = '{{ assignees }}'
WHERE
owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND alert_number = '{{ alert_number }}' --required
AND state = '{{ state }}' --required
AND assignees = '{{ assignees }}' --required
RETURNING
assignees,
created_at,
dismissal_approved_by,
dismissed_at,
dismissed_by,
dismissed_comment,
dismissed_reason,
fixed_at,
html_url,
instances_url,
most_recent_instance,
number,
rule,
state,
tool,
updated_at,
url;