此版本的 GitHub Enterprise Server 已于以下日期停止服务 2024-07-09. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持。
适用于企业代码安全性和分析的 REST API 终结点
使用 REST API 管理企业的代码安全性和分析功能。
Get code security and analysis features for an enterprise
Gets code security and analysis settings for the specified enterprise.
The authenticated user must be an administrator of the enterprise in order to use this endpoint.
OAuth app tokens and personal access tokens (classic) need the admin:enterprise
scope to use this endpoint.
“Get code security and analysis features for an enterprise”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
enterprise string 必须The slug version of the enterprise name. You can also substitute this value with the enterprise id. |
“Get code security and analysis features for an enterprise”的 HTTP 响应状态代码
状态代码 | 说明 |
---|---|
200 | OK |
404 | Resource not found |
“Get code security and analysis features for an enterprise”的示例代码
请求示例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/enterprises/ENTERPRISE/code_security_and_analysis
Response
Status: 200
{
"advanced_security_enabled_for_new_repositories": true,
"dependabot_alerts_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, Dependabot alerts, secret scanning, and push protection for new repositories in an enterprise.
The authenticated user must be an administrator of the enterprise to use this endpoint.
OAuth app tokens and personal access tokens (classic) need the admin:enterprise
scope to use this endpoint.
“Update code security and analysis features for an enterprise”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
enterprise string 必须The slug version of the enterprise name. You can also substitute this value with the enterprise id. |
名称, 类型, 说明 |
---|
advanced_security_enabled_for_new_repositories boolean Whether GitHub Advanced Security is automatically enabled for new repositories. For more information, see "About GitHub Advanced Security." |
dependabot_alerts_enabled_for_new_repositories boolean Whether Dependabot alerts are automatically enabled for new repositories. For more information, see "About Dependabot alerts." |
secret_scanning_enabled_for_new_repositories boolean Whether secret scanning is automatically enabled for new repositories. For more information, see "About secret scanning." |
secret_scanning_push_protection_enabled_for_new_repositories boolean Whether secret scanning push protection is automatically enabled for new repositories. For more information, see "Protecting pushes with secret scanning." |
secret_scanning_push_protection_custom_link string or null The 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 |
“Update code security and analysis features for an enterprise”的 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 |
“Update code security and analysis features for an enterprise”的示例代码
请求示例
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/enterprises/ENTERPRISE/code_security_and_analysis \
-d '{"advanced_security_enabled_for_new_repositories":true,"dependabot_alerts_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: 204
Enable or disable a security feature
Enables or disables the specified security feature for all repositories in an enterprise.
The authenticated user must be an administrator of the enterprise to use this endpoint.
OAuth app tokens and personal access tokens (classic) need the admin:enterprise
scope to use this endpoint.
“Enable or disable a security feature”的参数
名称, 类型, 说明 |
---|
accept string Setting to |
名称, 类型, 说明 |
---|
enterprise string 必须The slug version of the enterprise name. You can also substitute this value with the enterprise id. |
security_product string 必须The security feature to enable or disable. 可以是以下选项之一: |
enablement string 必须The action to take.
可以是以下选项之一: |
“Enable or disable a security feature”的 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 |
“Enable or disable a security feature”的示例代码
请求示例
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
http(s)://HOSTNAME/api/v3/enterprises/ENTERPRISE/SECURITY_PRODUCT/ENABLEMENT
Action started
Status: 204