Skip to main content

Esta versão do GitHub Enterprise Server será descontinuada em 2026-04-09. Nenhum lançamento de patch será feito, mesmo para questões críticas de segurança. Para obter melhor desempenho, segurança aprimorada e novos recursos, atualize para a última versão do GitHub Enterprise Server. Para obter ajuda com a atualização, entre em contato com o suporte do GitHub Enterprise.

Configuring advanced setup for code scanning

You can configure advanced setup for a repository to find security vulnerabilities in your code using a highly customizable code scanning configuration.

Quem pode usar esse recurso?

Proprietários de repositórios, proprietários de organizações, gerentes de segurança e usuários com a função de administrador

O Code scanning está disponível para os seguintes tipos de repositório:

  • Repositórios públicos no GitHub.com
  • Repositórios de propriedade da organização em GitHub Team, GitHub Enterprise Cloudou GitHub Enterprise Server, com GitHub Advanced Security habilitados.

Observação

O administrador do site precisa habilitar a code scanning antes que você possa usar esse recurso. Se você desejar usar o GitHub Actions para fazer a varredura do seu código, o administrador do site também deverá habilitar o GitHub Actions e configurar a infraestrutura necessária. Para saber mais, confira Como configurar a verificação de código do seu dispositivo.

Observação

Este artigo descreve os recursos disponíveis na versão da ação do CodeQL e o pacote da CodeQL CLI associado incluído na versão inicial desta versão do GitHub Enterprise Server. Se sua empresa usa uma versão mais recente da ação CodeQL, confira a versão GitHub Enterprise Cloud deste artigo para obter informações sobre os recursos mais recentes. Para saber mais sobre como usar a versão mais recente, confira "Como configurar a verificação de código do seu dispositivo".

If you do not need a highly customizable code scanning configuration, consider using default setup for code scanning. For more information, see Sobre os tipos de instalação para verificação de código.

Prerequisites

Your repository is eligible for advanced setup if it meets these requirements.

  • It uses CodeQL-supported languages or you plan to generate code scanning results with a third-party tool.
  • GitHub Actions está habilitado.
  • GitHub Advanced Security está habilitado.

If the server on which you are running GitHub Enterprise Server is not connected to the internet, your site administrator can enable CodeQL code scanning by making the CodeQL analysis bundle available on the server. For more information, see Como configurar a verificação de código do seu dispositivo.

Configuring advanced setup for code scanning with CodeQL

You can customize your CodeQL analysis by creating and editing a workflow file. Selecting advanced setup generates a basic workflow file for you to customize using standard workflow syntax and specifying options for the CodeQL action. See Fluxos de trabalho and Opções de configuração de fluxo de trabalho para verificação de código.

  1. Em GitHub, acesse a página principal do repositório.

  2. No nome do repositório, clique em Settings. Caso não consiga ver a guia "Configurações", selecione o menu suspenso , clique em Configurações.

    Captura de tela de um cabeçalho de repositório que mostra as guias. A guia "Configurações" é realçada por um contorno laranja-escuro.

  3. Na seção "Security" da barra lateral, clique em Code security and analysis.

  4. Scroll down to "Code scanning", in the "CodeQL analysis" row select Set up , then click Advanced.

    Observação

    If you are switching from default setup to advanced setup, in the "CodeQL analysis" row, select , then click Switch to advanced. In the pop-up window that appears, click Disable CodeQL.

    Screenshot of the "Code scanning" section of "Code security and analysis" settings. The "Advanced setup" button is highlighted with an orange outline.

  5. To customize how code scanning scans your code, edit the workflow.

    Generally, you can commit the Fluxo de trabalho de análise do CodeQL without making any changes to it. However, many of the third-party workflows require additional configuration, so read the comments in the workflow before committing.

    For more information, see Opções de configuração de fluxo de trabalho para verificação de código and CodeQL code scanning for compiled languages.

  6. Click Commit changes... to display the commit changes form.

    Screenshot of the form to create a new file. To the right of the file name, a green button, labeled "Commit changes...", is outlined in dark orange.

  7. In the commit message field, type a commit message.

  8. Choose whether you'd like to commit directly to the default branch, or create a new branch and start a pull request.

  9. Click Commit new file to commit the workflow file to the default branch or click Propose new file to commit the file to a new branch.

  10. If you created a new branch, click Create pull request and open a pull request to merge your change into the default branch.

In the suggested Fluxo de trabalho de análise do CodeQL, code scanning is configured to analyze your code each time you either push a change to the default branch or any protected branches, or raise a pull request against the default branch. As a result, code scanning will now commence.

The on:pull_request and on:push triggers for code scanning are each useful for different purposes. See Opções de configuração de fluxo de trabalho para verificação de código and Acionando um fluxo de trabalho.

For information on bulk enablement, see Como definir a configuração avançada da verificação de código com CodeQL em escala.

Next steps

After your workflow runs successfully at least once, you are ready to start examining and resolving code scanning alerts. For more information on code scanning alerts, see Sobre alertas de digitalização de códigos and Avaliar alertas de varredura de código para seu repositório.

Learn how code scanning runs behave as checks on pull requests, see Alertas de varredura de código de triagem em pull requests.

You can find detailed information about your code scanning configuration, including timestamps for each scan and the percentage of files scanned, on the tool status page. For more information, see Use the tool status page for code scanning.

Further reading