Skip to main content
The REST API is now versioned. For more information, see "About API versioning."

Проверка кода

API code scanning позволяет получать и обновлять оповещения code scanning из репозитория.

Сведения об API проверки кода

API code scanning позволяет получать и обновлять оповещения code scanning из репозитория. Для создания автоматических отчетов для оповещений code scanning о результатах проверки кода в организации или отправки результатов анализа, созданных с помощью автономных средств code scanning, можно использовать конечные точки. Дополнительные сведения см. в разделе Поиск уязвимостей системы безопасности и ошибок в коде.

Пользовательский тип носителя для code scanning

Для REST API code scanning поддерживается только один пользовательский тип носителя.

application/sarif+json

Этот тип носителя можно использовать с запросами GET, отправляемыми в конечную точку /analyses/{analysis_id}. Дополнительные сведения об этой операции см. в разделе Получение анализа code scanning для репозитория. При использовании этого типа мультимедиа с данной операцией ответ включает подмножество фактических данных, отправленных для указанного анализа, а не сводку анализа, возвращаемою при использовании типа мультимедиа по умолчанию. Ответ также содержит дополнительные данные, например свойства github/alertNumber и github/alertUrl. Для данных применяется формат SARIF версии 2.1.0.

Дополнительные сведения см. в разделе Типы носителей.

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.

Parameters

Headers
Name, Type, Description
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Name, Type, Description
enterprisestringRequired

The slug version of the enterprise name. You can also substitute this value with the enterprise id.

Query parameters
Name, Type, Description
tool_namestring

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_guidstringnull

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.

beforestring

A cursor, as given in the Link header. If specified, the query only searches for results before this cursor.

afterstring

A cursor, as given in the Link header. If specified, the query only searches for results after this cursor.

pageinteger

Page number of the results to fetch.

Default: 1

per_pageinteger

The number of results per page (max 100).

Default: 30

directionstring

The direction to sort the results by.

Default: desc

Can be one of: asc, desc

statestring

If specified, only code scanning alerts with this state will be returned.

Can be one of: open, closed, dismissed, fixed

sortstring

The property by which to sort the results.

Default: created

Can be one of: created, updated

HTTP response status codes

Status codeDescription
200

OK

404

Resource not found

503

Service unavailable

Code samples

get/enterprises/{enterprise}/code-scanning/alerts