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

코드 검사

code scanning API를 사용하면 리포지토리에서 code scanning 경고를 검색하고 업데이트할 수 있습니다.

코드 검사 API 정보

code scanning API를 사용하면 리포지토리에서 code scanning 경고를 검색하고 업데이트할 수 있습니다. 엔드포인트를 사용하여 조직의 code scanning 경고에 대한 자동화된 보고서를 만들거나 오프라인 code scanning 도구를 사용하여 생성된 분석 결과를 업로드할 수 있습니다. 자세한 내용은 “코드에서 보안 취약성 및 오류 찾기”를 참조하세요.

code scanning에 대한 사용자 지정 미디어 유형

code scanning REST API에 대해 지원되는 사용자 지정 미디어 유형이 하나 있습니다.

application/sarif+json

/analyses/{analysis_id} 엔드포인트로 전송된 GET 요청과 함께 이를 사용할 수 있습니다. 이 작업에 대한 자세한 내용은 “리포지토리에 대한 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
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/enterprises/ENTERPRISE/code-scanning/alerts

Response