| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Use the REST API to retrieve and update code scanning alerts from a repository.
You can retrieve and update code scanning alerts from a repository. You can use the endpoints to create automated reports for the code scanning alerts in an organization or upload analysis results generated using offline code scanning tools. For more information, see Find and fix code vulnerabilities.
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."
The authenticated user must be an owner or security manager for the organization to use this endpoint.
OAuth app tokens and personal access tokens (classic) need the security_events or repos cope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
org string Required The organization name. The name is not case sensitive. |
| Name, Type, Description |
|---|
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. For more information, see "Using pagination in the REST API." |
after string A cursor, as given in the Link header. If specified, the query only searches for results after this cursor. For more information, see "Using pagination in the REST API." |
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Default: 1 |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Default: 30 |
direction string The direction to sort the results by. Default: desc Can be one of: asc, desc |
state string If specified, only code scanning alerts with this state will be returned. Can be one of: open, closed, dismissed, fixed |
sort string The property by which to sort the results. Default: created Can be one of: created, updated |
severity string If specified, only code scanning alerts with this severity will be returned. Can be one of: critical, high, medium, low, warning, note, error |
assignees string Filter alerts by assignees. Provide a comma-separated list of user handles (e.g., octocat or octocat,hubot). Use * to list alerts with at least one assignee or none to list alerts with no assignees. |
| Status code | Description |
|---|---|
| 200 | OK |
| 404 | Resource not found |
| 503 | Service unavailable |
Response
Lists code scanning alerts.
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).
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.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
| Name, Type, Description |
|---|
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 integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Default: 1 |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." 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. |
pr integer The number of the pull request for the results you want to list. |
direction string The direction to sort the results by. Default: desc Can be one of: asc, desc |
before string A cursor, as given in the Link header. If specified, the query only searches for results before this cursor. For more information, see "Using pagination in the REST API." |
after string A cursor, as given in the Link header. If specified, the query only searches for results after this cursor. For more information, see "Using pagination in the REST API." |
sort string The property by which to sort the results. Default: created Can be one of: created, updated |
state string If specified, only code scanning alerts with this state will be returned. Can be one of: open, closed, dismissed, fixed |
severity string If specified, only code scanning alerts with this severity will be returned. Can be one of: critical, high, medium, low, warning, note, error |
assignees string Filter alerts by assignees. Provide a comma-separated list of user handles (e.g., octocat or octocat,hubot). Use * to list alerts with at least one assignee or none to list alerts with no assignees. |
| Status code | Description |
|---|---|
| 200 | OK |
| 304 | Not modified |
| 403 | Response if GitHub Advanced Security is not enabled for this repository |
| 404 | Resource not found |
| 503 | Service unavailable |
Response
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.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
alert_number integer 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. |
| Status code | Description |
|---|---|
| 200 | OK |
| 304 | Not modified |
| 403 | Response if GitHub Advanced Security is not enabled for this repository |
| 404 | Resource not found |
| 503 | Service unavailable |
Response
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.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
alert_number integer 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. |
| Name, Type, Description |
|---|
state string Sets the state of the code scanning alert. You must provide dismissed_reason when you set the state to dismissed. Can be one of: open, dismissed |
dismissed_reason string or null Required when the state is dismissed. The reason for dismissing or closing the alert. Can be one of: false positive, won't fix, used in tests, mitigated, null |
dismissed_comment string or null The dismissal comment associated with the dismissal of the alert. |
create_request boolean If true, attempt to create an alert dismissal request. |
assignees array of strings The list of users to assign to the code scanning alert. An empty array unassigns all previous assignees from the alert. |
| Status code | Description |
|---|---|
| 200 | OK |
| 400 | Bad Request |
| 403 | Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository |
| 404 | Resource not found |
| 503 | Service unavailable |
Response
Gets the status and description of an autofix for a code scanning alert on the repository's default branch.
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.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
alert_number integer 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. |
| Status code | Description |
|---|---|
| 200 | OK |
| 400 | Bad Request |
| 403 | Response if GitHub Advanced Security is not enabled for this repository |
| 404 | Resource not found |
| 500 | Internal Error |
Response
Creates an autofix for a code scanning alert from the repository's default branch.
If a new autofix is to be created as a result of this request or is currently being generated, then this endpoint will return a 202 Accepted response.
If an autofix already exists for a given alert, then this endpoint will return a 200 OK response.
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.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
alert_number integer 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. |
| Status code | Description |
|---|---|
| 200 | OK |
| 202 | Accepted |
| 400 | Bad Request |
| 403 | Response if the repository is archived, if GitHub Advanced Security is not enabled for this repository or if rate limit is exceeded |
| 404 | Resource not found |
| 422 | Unprocessable Entity |
| 500 | Internal Error |
OK
Commits an autofix for a code scanning alert from the repository's default branch.
If an autofix is committed as a result of this request, then this endpoint will return a 201 Created response.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
alert_number integer 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. |
| Name, Type, Description |
|---|
target_ref string The Git reference of target branch for the commit. Branch needs to already exist. For more information, see "Git References" in the Git documentation. |
message string Commit message to be used. |
| Status code | Description |
|---|---|
| 201 | Created |
| 400 | Bad Request |
| 403 | Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository |
| 404 | Resource not found |
| 422 | Unprocessable Entity |
| 503 | Service unavailable |
Created
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.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
alert_number integer 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. |
| Name, Type, Description |
|---|
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Default: 1 |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." 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. |
pr integer The number of the pull request for the results you want to list. |
| Status code | Description |
|---|---|
| 200 | OK |
| 403 | Response if GitHub Advanced Security is not enabled for this repository |
| 404 | Resource not found |
| 503 | Service unavailable |
Response
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.
Warning
Closing down notice: The tool_name field is closing down 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.
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.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
| Name, Type, Description |
|---|
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 integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Default: 1 |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Default: 30 |
pr integer The number of the pull request for the results you want to list. |
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. |
direction string The direction to sort the results by. Default: desc Can be one of: asc, desc |
sort string The property by which to sort the results. Default: created Value: created |
| Status code | Description |
|---|---|
| 200 | OK |
| 403 | Response if GitHub Advanced Security is not enabled for this repository |
| 404 | Resource not found |
| 503 | Service unavailable |
Response
Gets a specified code scanning analysis for a repository.
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.
This endpoint supports the following custom media types. For more information, see "Media types."
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.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
analysis_id integer Required The ID of the analysis, as returned from the GET /repos/{owner}/{repo}/code-scanning/analyses operation. |
| Status code | Description |
|---|---|
| 200 | OK |
| 403 | Response if GitHub Advanced Security is not enabled for this repository |
| 404 | Resource not found |
| 422 | Response if analysis could not be processed |
| 503 | Service unavailable |
application/json response
Deletes a specified code scanning analysis from a repository.
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:
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:
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.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
analysis_id integer Required The ID of the analysis, as returned from the GET /repos/{owner}/{repo}/code-scanning/analyses operation. |
| Name, Type, Description |
|---|
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. |
| Status code | Description |
|---|---|
| 200 | OK |
| 400 | Bad Request |
| 403 | Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository |
| 404 | Resource not found |
| 503 | Service unavailable |
Default response
Lists the CodeQL databases that are available in a repository.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested.
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
| Status code | Description |
|---|---|
| 200 | OK |
| 403 | Response if GitHub Advanced Security is not enabled for this repository |
| 404 | Resource not found |
| 503 | Service unavailable |
Response
Gets a CodeQL database for a language in a repository.
By default this endpoint returns JSON metadata about the CodeQL database. To download the CodeQL database binary content, set the Accept header of the request to application/zip, and make sure your HTTP client is configured to follow redirects or use the Location header to make a second request to get the redirect URL.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested.
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
language string Required The language of the CodeQL database. |
| Status code | Description |
|---|---|
| 200 | OK |
| 302 | Found |
| 403 | Response if GitHub Advanced Security is not enabled for this repository |
| 404 | Resource not found |
| 503 | Service unavailable |
Response
Deletes a CodeQL database for a language in a repository.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
language string Required The language of the CodeQL database. |
| Status code | Description |
|---|---|
| 204 | No Content |
| 403 | Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository |
| 404 | Resource not found |
| 503 | Service unavailable |
Response
Creates a new CodeQL variant analysis, which will run a CodeQL query against one or more repositories.
Get started by learning more about running CodeQL queries at scale with Multi-Repository Variant Analysis.
Use the owner and repo parameters in the URL to specify the controller repository that will be used for running GitHub Actions workflows and storing the results of the CodeQL variant analysis.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
| Status code | Description |
|---|---|
| 201 | Variant analysis submitted for processing |
| 404 | Resource not found |
| 422 | Unable to process variant analysis submission |
| 503 | Service unavailable |
Response for a successful variant analysis submission
Gets the summary of a CodeQL variant analysis.
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.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
This endpoint can be used without authentication or the aforementioned permissions if only public resources are requested.
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
codeql_variant_analysis_id integer Required The unique identifier of the variant analysis. |
| Status code | Description |
|---|---|
| 200 | OK |
| 404 | Resource not found |
| 503 | Service unavailable |
Default response
Gets the analysis status of a repository in a CodeQL variant analysis.
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.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the controller repository. |
codeql_variant_analysis_id integer Required The ID of the variant analysis. |
repo_owner string Required The account owner of the variant analysis repository. The name is not case sensitive. |
repo_name string Required The name of the variant analysis repository. |
| Status code | Description |
|---|---|
| 200 | OK |
| 404 | Resource not found |
| 503 | Service unavailable |
Default response
Gets a code scanning default setup configuration.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
| Status code | Description |
|---|---|
| 200 | OK |
| 403 | Response if GitHub Advanced Security is not enabled for this repository |
| 404 | Resource not found |
| 503 | Service unavailable |
Response
Updates a code scanning default setup configuration.
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint with private or public repositories, or the public_repo scope to use this endpoint with only public repositories.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
| Name, Type, Description |
|---|
state string The desired state of code scanning default setup. Can be one of: configured, not-configured |
runner_type string Runner type to be used. Can be one of: standard, labeled |
runner_label string or null Runner label to be used if the runner type is labeled. |
query_suite string CodeQL query suite to be used. Can be one of: default, extended |
threat_model string Threat model to be used for code scanning analysis. Use remote to analyze only network sources and remote_and_local to include local sources like filesystem access, command-line arguments, database reads, environment variable and standard input. Can be one of: remote, remote_and_local |
languages array of strings CodeQL languages to be analyzed. Supported values are: actions, c-cpp, csharp, go, java-kotlin, javascript-typescript, python, ruby, swift |
| Status code | Description |
|---|---|
| 200 | OK |
| 202 | Accepted |
| 403 | Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository |
| 404 | Resource not found |
| 409 | Response if there is already a validation run in progress with a different default setup configuration |
| 422 | Response if the configuration change cannot be made because the repository is not in the required state |
| 503 | Service unavailable |
Response
Uploads SARIF data containing the results of a code scanning analysis to make the results available in a repository. For troubleshooting information, see "Troubleshooting SARIF uploads."
There are two places where you can upload code scanning results.
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. For more information, see "SARIF results exceed one or more limits."
| SARIF data | Maximum values | Additional limits |
|---|---|---|
| Runs per file | 20 | |
| Results per run | 25,000 | Only the top 5,000 results will be included, prioritized by severity. |
| Rules per run | 25,000 | |
| Tool extensions per run | 100 | |
| Thread Flow Locations per result | 10,000 | Only the top 1,000 Thread Flow Locations will be included, using prioritization. |
| Location per result | 1,000 | Only 100 locations will be included. |
| Tags per rule | 20 | Only 10 tags will be included. |
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."
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.
This endpoint is limited to 1,000 requests per hour for each user or app installation calling it.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
| Name, Type, Description |
|---|
commit_sha string Required The SHA of the commit to which the analysis you are uploading relates. |
ref string Required The full Git reference, formatted as refs/heads/<branch name>, refs/tags/<tag>, 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 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. |
started_at string 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. |
validate boolean Whether the SARIF file will be validated according to the code scanning specifications. This parameter is intended to help integrators ensure that the uploaded SARIF files are correctly rendered by code scanning. |
| Status code | Description |
|---|---|
| 202 | Accepted |
| 400 | Bad Request if the sarif field is invalid |
| 403 | Response if the repository is archived or if GitHub Advanced Security is not enabled for this repository |
| 404 | Resource not found |
| 413 | Payload Too Large if the sarif field is too large |
| 503 | Service unavailable |
Default response
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." 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.
This endpoint works with the following fine-grained token types:
The fine-grained token must have the following permission set:
| Name, Type, Description |
|---|
accept string Setting to application/vnd.github+json is recommended. |
| Name, Type, Description |
|---|
owner string Required The account owner of the repository. The name is not case sensitive. |
repo string Required The name of the repository without the .git extension. The name is not case sensitive. |
sarif_id string Required The SARIF ID obtained after uploading. |
| Status code | Description |
|---|---|
| 200 | OK |
| 403 | Response if GitHub Advanced Security is not enabled for this repository |
| 404 | Not Found if the sarif id does not match any upload |
| 503 | Service unavailable |
Default response
| Back | FazBrowse Home | New Git URL |