Code security and analysis
Use the REST API to manage code security and analysis features for your enterprise.
엔터프라이즈 관리자용 REST API는 personal access token (classic)을(를) 사용하는 인증만 지원합니다. 자세한 내용은 "personal access token 만들기"를 참조하세요 .
Get code security and analysis features for an enterprise
Gets code security and analysis settings for the specified enterprise.
To use this endpoint, you must be an administrator of the enterprise, and you must use an access token with the admin:enterprise scope.
매개 변수
| Headers |
|---|
| Name, Type, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
enterprisestringRequiredThe slug version of the enterprise name. You can also substitute this value with the enterprise id. |
HTTP 응답 상태 코드
| 상태 코드 | 설명 |
|---|---|
200 | OK |
404 | Resource not found |
코드 샘플
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_security_and_analysisResponse
Status: 200{
"advanced_security_enabled_for_new_repositories": true,
"secret_scanning_enabled_for_new_repositories": true,
"secret_scanning_push_protection_enabled_for_new_repositories": true,
"secret_scanning_push_protection_custom_link": "https://github.com/test-org/test-repo/blob/main/README.md"
}Update code security and analysis features for an enterprise
Updates the settings for advanced security, secret scanning, and push protection for new repositories in an enterprise.
To use this endpoint, you must be an administrator of the enterprise, and you must use an access token with the admin:enterprise scope.
매개 변수
| Headers |
|---|
| Name, Type, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
enterprisestringRequiredThe slug version of the enterprise name. You can also substitute this value with the enterprise id. |
| Body parameters |
| Name, Type, Description |
advanced_security_enabled_for_new_repositoriesbooleanWhether GitHub Advanced Security is automatically enabled for new repositories. For more information, see "About GitHub Advanced Security." |
secret_scanning_enabled_for_new_repositoriesbooleanWhether secret scanning is automatically enabled for new repositories. For more information, see "About secret scanning." |
secret_scanning_push_protection_enabled_for_new_repositoriesbooleanWhether secret scanning push protection is automatically enabled for new repositories. For more information, see "Protecting pushes with secret scanning." |
secret_scanning_push_protection_custom_linkstring or nullThe URL that will be displayed to contributors who are blocked from pushing a secret. For more information, see "Protecting pushes with secret scanning."
To disable this functionality, set this field to |
HTTP 응답 상태 코드
| 상태 코드 | 설명 |
|---|---|
204 | Action started |
404 | Resource not found |
422 | The action could not be taken due to an in progress enablement, or a policy is preventing enablement |
코드 샘플
curl \
-X PATCH \
-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_security_and_analysis \
-d '{"advanced_security_enabled_for_new_repositories":true,"secret_scanning_enabled_for_new_repositories":true,"secret_scanning_push_protection_enabled_for_new_repositories":true,"secret_scanning_push_protection_custom_link":"https://github.com/test-org/test-repo/blob/main/README.md"}'Action started
Status: 204Enable or disable a security feature
Enables or disables the specified security feature for all repositories in an enterprise.
To use this endpoint, you must be an administrator of the enterprise, and you must use an access token with the admin:enterprise scope.
매개 변수
| Headers |
|---|
| Name, Type, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
enterprisestringRequiredThe slug version of the enterprise name. You can also substitute this value with the enterprise id. |
security_productstringRequiredThe security feature to enable or disable. Can be one of: |
enablementstringRequiredThe action to take.
Can be one of: |
HTTP 응답 상태 코드
| 상태 코드 | 설명 |
|---|---|
204 | Action started |
404 | Resource not found |
422 | The action could not be taken due to an in progress enablement, or a policy is preventing enablement |
코드 샘플
curl \
-X POST \
-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/SECURITY_PRODUCT/ENABLEMENTAction started
Status: 204
