Skip to main content

Managing code scanning alerts for your repository

From the security view, you can view, fix, or dismiss alerts for potential vulnerabilities or errors in your project's code.

Who can use this feature

If you have write permission to a repository you can manage code scanning alerts for that repository.

Code scanning está disponible para todos los repositorios públicos en GitHub.com. Para utilizar code scanning en un repositorio privado que pertenece a una organización, debes tener una licencia para GitHub Advanced Security. Para más información, consulte "Acerca de GitHub Advanced Security".

Viewing the alerts for a repository

Anyone with read permission for a repository can see code scanning annotations on pull requests. For more information, see "Triaging code scanning alerts in pull requests."

You need write permission to view a summary of all the alerts for a repository on the Security tab.

By default, the code scanning alerts page is filtered to show alerts for the default branch of the repository only.

  1. On GitHub.com, navigate to the main page of the repository.

  2. En el nombre del repositorio, haz clic en Seguridad. Pestaña Seguridad

  3. En la barra lateral izquierda, haga clic en Code scanning alerts (Alertas de análisis de código). Pestaña "Code scanning alerts" (Alertas de análisis de código)

  4. Optionally, use the free text search box or the drop-down menus to filter alerts. For example, you can filter by the tool that was used to identify alerts. Filter by tool

  5. Debajo de "Code scanning", da clic en la alerta que quisieras explorar. Summary of alerts

    El estado y los detalles de la página de alertas solo reflejan el estado de la alerta en la rama predeterminada del repositorio, incluso si la alerta existe en otras ramas. Puede ver el estado de la alerta en ramas no predeterminadas en la sección Ramas afectadas del lado derecho de la página de alertas. Si una alerta no existe en la rama predeterminada, el estado de la alerta se mostrará como "en la solicitud de incorporación de cambios" o "en la rama", y tendrá un color gris. The "Affected branches" section in an alert

  6. Optionally, if the alert highlights a problem with data flow, click Show paths to display the path from the data source to the sink where it's used.

    The "Show paths" link on an alert

  7. Alerts from CodeQL analysis include a description of the problem. Click Show more for guidance on how to fix your code. Details for an alert

For more information, see "About code scanning alerts."

Note: For code scanning analysis with CodeQL, you can see information about the latest run in a header at the top of the list of code scanning alerts for the repository.

For example, you can see when the last scan ran, the number of lines of code analyzed compared to the total number of lines of code in your repository, and the total number of alerts that were generated. UI banner

Filtering code scanning alerts

You can filter the alerts shown in the code scanning alerts view. This is useful if there are many alerts as you can focus on a particular type of alert. There are some predefined filters and a range of keywords that you can use to refine the list of alerts displayed.

  • To use a predefined filter, click Filters, or a filter shown in the header of the list of alerts, and choose a filter from the drop-down list. Predefined filters
  • To use a keyword, either type directly in the filters text box, or:
    1. Click in the filters text box to show a list of all available filter keywords.
    2. Click the keyword you want to use and then choose a value from the drop-down list. Keyword filters list

The benefit of using keyword filters is that only values with results are shown in the drop-down lists. This makes it easy to avoid setting filters that find no results.

If you enter multiple filters, the view will show alerts matching all these filters. For example, is:closed severity:high branch:main will only display closed high-severity alerts that are present on the main branch. The exception is filters relating to refs (ref, branch and pr): is:open branch:main branch:next will show you open alerts from both the main branch and the next branch.

Tenga en cuenta que si ha filtrado las alertas en una rama no predeterminada, pero las mismas alertas existen en la rama predeterminada, en la página de alertas de cualquier alerta se seguirá reflejando el estado de la alerta en la rama predeterminada, incluso si ese estado entra en conflicto con el de una rama no predeterminada. Por ejemplo, una alerta que aparece en la lista "Abrir" en el resumen de alertas para branch-x podría mostrar un estado de "Corregido" en la página de alertas, si ya se ha corregido en la rama predeterminada. Puede ver el estado de la alerta de la rama filtrada en la sección Ramas afectadas del lado derecho de la página de alertas.

You can prefix the tag filter with - to exclude results with that tag. For example, -tag:style only shows alerts that do not have the style tag and -tag:experimental will omit all experimental alerts. For more information, see "About code scanning alerts."

Restricting results to application code only

You can use the "Only alerts in application code" filter or autofilter:true keyword and value to restrict results to alerts in application code. See "About labels for alerts not in application code" above for more information about the types of code that are not application code.

Searching code scanning alerts

You can search the list of alerts. This is useful if there is a large number of alerts in your repository, or if you don't know the exact name for an alert for example. GitHub Enterprise Cloud performs the free text search across:

  • The name of the alert

  • The alert details (this also includes the information hidden from view by default in the Show more collapsible section)

    The alert information used in searches

Supported searchSyntax exampleResults
Single word searchinjectionReturns all the alerts containing the word injection
Multiple word searchsql injectionReturns all the alerts containing sql or injection
Exact match search
(use double quotes)
"sql injection"Returns all the alerts containing the exact phrase sql injection
OR searchsql OR injectionReturns all the alerts containing sql or injection
AND searchsql AND injectionReturns all the alerts containing both words sql and injection

Tips:

  • The multiple word search is equivalent to an OR search.
  • The AND search will return results where the search terms are found anywhere, in any order in the alert name or details.
  1. On GitHub.com, navigate to the main page of the repository.
  2. En el nombre del repositorio, haz clic en Seguridad. Pestaña Seguridad
  3. En la barra lateral izquierda, haga clic en Code scanning alerts (Alertas de análisis de código). Pestaña "Code scanning alerts" (Alertas de análisis de código)
  4. To the right of the Filters drop-down menus, type the keywords to search for in the free text search box. The free text search box
  5. Press return. The alert listing will contain the open code scanning alerts matching your search criteria.

Tracking code scanning alerts in issues

Nota: El seguimiento de las alertas de code scanning se encuentra en beta y está sujeto a cambios.

Esta característica es compatible con la ejecución nativa de análisis mediante GitHub Actions o de forma externa mediante la infraestructura de CI/CD existente, así como herramientas de code scanning de terceros, pero no herramientas de seguimiento de terceros.

Las alertas del Code scanning se integran con listas de tareas en GitHub Issues para facilitarte el priorizar y rastrear alertas con todo tu trabajo de desarrollo. Para más información sobre las incidencias, vea "[Acerca de las incidencias](/issues/tracking-your-work-with-issues/about-issues)".

Para rastrear una alerta de escaneo de código en una propuesta, agrega la URL para la alerta como un elemento de la lista de tareas en la propuesta. Para más información sobre las listas de tareas incidencias, vea "Acerca de las listas de tareas". Para obtener más información sobre cómo crear incidencias para seguir alertas de code scanning, consulta Seguimiento de alertas de code scanning en problemas usando listas de tareas.

Fixing an alert

Anyone with write permission for a repository can fix an alert by committing a correction to the code. If the repository has code scanning scheduled to run on pull requests, it's best to raise a pull request with your correction. This will trigger code scanning analysis of the changes and test that your fix doesn't introduce any new problems. For more information, see "Configuring code scanning" and "Triaging code scanning alerts in pull requests."

If you have write permission for a repository, you can view fixed alerts by viewing the summary of alerts and clicking Closed. For more information, see "Viewing the alerts for a repository." The "Closed" list shows fixed alerts and alerts that users have dismissed.

You can use the free text search or the filters to display a subset of alerts and then in turn mark all matching alerts as closed.

Alerts may be fixed in one branch but not in another. You can use the "Branch" filter, on the summary of alerts, to check whether an alert is fixed in a particular branch.

Filtering alerts by branch

Tenga en cuenta que si ha filtrado las alertas en una rama no predeterminada, pero las mismas alertas existen en la rama predeterminada, en la página de alertas de cualquier alerta se seguirá reflejando el estado de la alerta en la rama predeterminada, incluso si ese estado entra en conflicto con el de una rama no predeterminada. Por ejemplo, una alerta que aparece en la lista "Abrir" en el resumen de alertas para branch-x podría mostrar un estado de "Corregido" en la página de alertas, si ya se ha corregido en la rama predeterminada. Puede ver el estado de la alerta de la rama filtrada en la sección Ramas afectadas del lado derecho de la página de alertas.

Note: If you run code scanning using multiple configurations, then sometimes an alert will have multiple analysis origins. Unless you run all configurations regularly, you may see alerts that are fixed in one analysis origin but not in another. For more information, see "About analysis origins."

Dismissing alerts

There are two ways of closing an alert. You can fix the problem in the code, or you can dismiss the alert.

Dismissing an alert is a way of closing an alert that you don't think needs to be fixed. Por ejemplo, un error en el código que se utiliza únicamente para hacer pruebas, o cuando el esfuerzo de areglar el error es mayor que el beneficio potencial de mejorar el código. You can dismiss alerts from code scanning annotations in code, or from the summary list within the Security tab.

When you dismiss an alert:

  • It's dismissed in all branches.
  • The alert is removed from the number of current alerts for your project.
  • The alert is moved to the "Closed" list in the summary of alerts, from where you can reopen it, if required.
  • The reason why you closed the alert is recorded.
  • Optionally, you can comment on a dismissal to record the context of an alert dismissal.
  • Next time code scanning runs, the same code won't generate an alert.

To dismiss alerts:

  1. On GitHub.com, navigate to the main page of the repository.

  2. En el nombre del repositorio, haz clic en Seguridad. Pestaña Seguridad

  3. En la barra lateral izquierda, haga clic en Code scanning alerts (Alertas de análisis de código). Pestaña "Code scanning alerts" (Alertas de análisis de código)

  4. If you want to dismiss an alert, it's important to explore the alert first, so that you can choose the correct dismissal reason. Click the alert you'd like to explore. Open an alert from the summary list

  5. Review the alert, then click Dismiss alert and choose, or type, a reason for closing the alert. Screenshot of code scanning alert with dropdown to choose dismissal reason emphasized Es importante elegir la razón adecuada del menú desplegable, ya que esto puede afectar si la consulta continuará incluyéndose en los análisis futuros. Opcionalmente, puedes comentar un descarte para registrar el contexto del descarte de una alerta. El comentario de descarte se agrega a la escala de tiempo de la alerta y se puede usar como justificación durante el proceso de auditoría y creación de informes. Puedes recuperar o establecer un comentario mediante la API REST de examen de código. El comentario se incluye en dismissed_comment para el punto de conexión alerts/{alert_number}. Para obtener más información, consulta "Examen de código".

    Si descartas una alerta de CodeQL como consecuencia de un resultado de falso positivo, por ejemplo, porque el código utiliza una biblioteca de sanitización que no es compatible, considera contribuir con el repositorio de CodeQL y mejorar el análisis. Para más información sobre CodeQL, vea "Contribución a CodeQL".

Dismissing multiple alerts at once

If a project has multiple alerts that you want to dismiss for the same reason, you can bulk dismiss them from the summary of alerts. Typically, you'll want to filter the list and then dismiss all of the matching alerts. For example, you might want to dismiss all of the current alerts in the project that have been tagged for a particular Common Weakness Enumeration (CWE) vulnerability.

Further reading