Skip to main content
Publicamos atualizações frequentes em nossa documentação, e a tradução desta página ainda pode estar em andamento. Para obter as informações mais atualizadas, acesse a documentação em inglês.
O controle de versão da API REST já foi feito. Para obter mais informações, confira "Sobre o controle de versão da API".

Segurança e análise de código

Use a API REST para gerenciar os recursos de segurança e análise de código para sua empresa.

Esses pontos de extremidade só dão suporte à autenticação por meio de um personal access token (classic). Para obter mais informações, confira "Managing your personal access tokens".

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.

Parâmetros para "Get code security and analysis features for an enterprise"

Cabeçalhos
Name, Tipo, Descrição
accept string

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

Parâmetros de caminho
Name, Tipo, Descrição
enterprise string Obrigatório

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

Códigos de status de resposta HTTP para "Get code security and analysis features for an enterprise"

Código de statusDescrição
200

OK

404

Resource not found

Exemplos de código para "Get code security and analysis features for an enterprise"

get/enterprises/{enterprise}/code_security_and_analysis
curl -L \ -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

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. To use this endpoint, you must be an administrator of the enterprise, and you must use an access token with the admin:enterprise scope.

Parâmetros para "Update code security and analysis features for an enterprise"

Cabeçalhos
Name, Tipo, Descrição
accept string

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

Parâmetros de caminho
Name, Tipo, Descrição
enterprise string Obrigatório

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

Parâmetros do corpo
Name, Tipo, Descrição
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 null.

Códigos de status de resposta HTTP para "Update code security and analysis features for an enterprise"

Código de statusDescrição
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

Exemplos de código para "Update code security and analysis features for an enterprise"

patch/enterprises/{enterprise}/code_security_and_analysis
curl -L \ -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,"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.

To use this endpoint, you must be an administrator of the enterprise, and you must use an access token with the admin:enterprise scope.

Parâmetros para "Enable or disable a security feature"

Cabeçalhos
Name, Tipo, Descrição
accept string

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

Parâmetros de caminho
Name, Tipo, Descrição
enterprise string Obrigatório

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

security_product string Obrigatório

The security feature to enable or disable.

Pode ser um dos: advanced_security, dependabot_alerts, secret_scanning, secret_scanning_push_protection

enablement string Obrigatório

The action to take.

enable_all means to enable the specified security feature for all repositories in the enterprise. disable_all means to disable the specified security feature for all repositories in the enterprise.

Pode ser um dos: enable_all, disable_all

Códigos de status de resposta HTTP para "Enable or disable a security feature"

Código de statusDescrição
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

Exemplos de código para "Enable or disable a security feature"

post/enterprises/{enterprise}/{security_product}/{enablement}
curl -L \ -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/ENABLEMENT

Action started

Status: 204