Nota: El administrador del sitio debe habilitar code scanning para your GitHub Enterprise Server instance antes de que pueda utilizar esta característica. Si quieres utilizar GitHub Actions para escanear tu código, el administrador de sitio también puede habilitar las GitHub Actions y configurar la infraestructura que se requiera. Para más información, vea "Configuración de code scanning para el dispositivo".
You decide how to generate code scanning alerts, and which tools to use, at a repository level. GitHub Enterprise Server provides fully integrated support for CodeQL analysis, and also supports analysis using third-party tools. For more information, see "About code scanning."
|Opciones para generar alertas|
|CodeQL||Uso de GitHub Actions (vea "Configuración de code scanning mediante acciones") o ejecución del análisis de CodeQL en un sistema de integración continua (CI) de terceros (vea "Acerca de CodeQL code scanning en el sistema de CI").|
|Third‑party||Uso de GitHub Actions (vea "Configuración de code scanning mediante acciones") o generado de forma externa y cargado a GitHub Enterprise Server (vea "Carga de un archivo SARIF a GitHub").|
Si ejecuta el análisis de código mediante varias configuraciones, en ocasiones una alerta tendrá varios orígenes de análisis. Si una alerta tiene varios orígenes de análisis, puede ver el estado de la alerta para cada origen de análisis en la página de alertas. Para más información, vea "Acerca de los orígenes de análisis".
Note: If you want to use the CodeQL analysis, note that this article describes the features available with the version of the CodeQL action and associated CodeQL CLI bundle included in the initial release of this version of GitHub Enterprise Server. If your enterprise uses a more recent version of the CodeQL action, see the GitHub Enterprise Cloud article for information on the latest features. For information on using the latest version, see "Configuring code scanning for your appliance."
En your GitHub Enterprise Server instance, vaya a la página principal del repositorio.
En el nombre del repositorio, haga clic en Security.
To the right of "Code scanning alerts", click Set up code scanning. If code scanning is missing, you need to ask an organization owner or repository administrator to enable GitHub Advanced Security. For more information, see "Managing security and analysis settings for your organization" or "Managing security and analysis settings for your repository."
Under "Get started with code scanning", click Set up this workflow on the CodeQL analysis workflow or on a third-party workflow. Workflows are only displayed if they are relevant for the programming languages detected in the repository. The CodeQL analysis workflow is always displayed, but the "Set up this workflow" button is only enabled if CodeQL analysis supports the languages present in the repository.
To customize how code scanning scans your code, edit the workflow.
Generally you can commit the CodeQL analysis workflow 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 "Configuring code scanning."
Use the Start commit drop-down, and type a commit message.
Choose whether you'd like to commit directly to the default branch, or create a new branch and start a pull request.
Click Commit new file or Propose new file.
In the default CodeQL analysis workflow, 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.
You can set up code scanning in many repositories at once using a script. If you'd like to use a script to raise pull requests that add a GitHub Actions workflow to multiple repositories, see the
jhutchings1/Create-ActionsPRs repository for an example using PowerShell, or
nickliffen/ghas-enablement for teams who do not have PowerShell and instead would like to use NodeJS.
After setting up code scanning for your repository, you can watch the output of the actions as they run.
En el nombre del repositorio, haga clic en Acciones.
You'll see a list that includes an entry for running the code scanning workflow. The text of the entry is the title you gave your commit message.
Click the entry for the code scanning workflow.
Click the job name on the left. For example, Analyze (LANGUAGE).
Review the logging output from the actions in this workflow as they run.
Once all jobs are complete, you can view the details of any code scanning alerts that were identified. For more information, see "Managing code scanning alerts for your repository."
Note: If you raised a pull request to add the code scanning workflow to the repository, alerts from that pull request aren't displayed directly on the Code scanning page until the pull request is merged. If any alerts were found you can view these, before the pull request is merged, by clicking the n alerts found link in the banner on the Code scanning page.
Each code scanning workflow you set to run on pull requests always has at least two entries listed in the checks section of a pull request. There is one entry for each of the analysis jobs in the workflow, and a final one for the results of the analysis.
The names of the code scanning analysis checks take the form: "TOOL NAME / JOB NAME (TRIGGER)." For example, for CodeQL, analysis of C++ code has the entry "CodeQL / Analyze (cpp) (pull_request)." You can click Details on a code scanning analysis entry to see logging data. This allows you to debug a problem if the analysis job failed. For example, for code scanning analysis of compiled languages, this can happen if the action can't build the code.
When the code scanning jobs complete, GitHub works out whether any alerts were added by the pull request and adds the "Code scanning results / TOOL NAME" entry to the list of checks. After code scanning has been performed at least once, you can click Details to view the results of the analysis.
After setting up code scanning, and allowing its actions to complete, you can:
- View all of the code scanning alerts generated for this repository. For more information, see "Managing code scanning alerts for your repository."
- View any alerts generated for a pull request submitted after you set up code scanning. For more information, see "Triaging code scanning alerts in pull requests."
- Set up notifications for completed runs. For more information, see "Configuring notifications."
- View the logs generated by the code scanning analysis. For more information, see "Viewing code scanning logs."
- Investigate any problems that occur with the initial setup of CodeQL code scanning. For more information, see "Troubleshooting the CodeQL workflow."
- Customize how code scanning scans the code in your repository. For more information, see "Configuring code scanning."