alerts
Creates, updates, deletes, gets or lists an alerts resource.
Overview
| Name | alerts |
| Type | Resource |
| Id | github.code_scanning.alerts |
Fields
The following fields are returned by SELECT queries:
- get_alert
Response
| Name | Datatype | Description |
|---|---|---|
assignees | array | |
created_at | string (date-time) | The time that the alert was created in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. |
dismissal_approved_by | object | A GitHub user. (title: Simple User) |
dismissed_at | string (date-time) | The time that the alert was dismissed in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. |
dismissed_by | object | A GitHub user. (title: Simple User) |
dismissed_comment | string | The dismissal comment associated with the dismissal of the alert. |
dismissed_reason | string | Required when the state is dismissed. The reason for dismissing or closing the alert. (false positive, won't fix, used in tests) |
fixed_at | string (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_url | string (uri) | The GitHub URL of the alert resource. |
instances_url | string (uri) | The REST API URL for fetching the list of instances for an alert. |
most_recent_instance | object | |
number | integer | The security alert number. |
rule | object | |
state | string | State of a code scanning alert. (open, dismissed, fixed) |
tool | object | |
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) | The REST API URL of the alert resource. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_alert | select | owner, repo, alert_number | 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. | |
update_alert | update | owner, repo, alert_number, state, assignees | 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. |
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.
| Name | Datatype | Description |
|---|---|---|
alert_number | integer | 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. |
owner | string | The account owner of the repository. The name is not case sensitive. |
repo | string | The name of the repository without the .git extension. The name is not case sensitive. |
SELECT examples
- get_alert
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
- update_alert
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;