Asking Conversation GitHub Copilot about code scanning alerts
With a GitHub Copilot Enterprise license, you can ask Discussion avec Copilot for help to better understand security alerts, including code scanning alerts, in repositories in your organization. For more information, see Poser des questions à GitHub Copilot dans GitHub.
Generating suggested fixes for code scanning alerts
Correctif automatique GitHub Copilot can generate fixes for alerts identified by code scanning analysis. Most CodeQL alert types are supported. For more information, see Utilisation responsable de Copilot Autofix pour l’analyse du code.
Remarque
Vous n’avez pas besoin d’un abonnement à GitHub Copilot pour utiliser Correctif automatique GitHub Copilot. Correctif automatique Copilot est disponible pour tous les référentiels publics sur GitHub.com, ainsi que pour les référentiels internes ou privés appartenant à des organisations et entreprises disposant d’une licence pour GitHub Code Security.
- Sur GitHub, accédez à la page principale du référentiel.
- Sous le nom du référentiel, cliquez sur Sécurité. Si vous ne voyez pas l’onglet « Sécurité », sélectionnez le menu déroulant et cliquez sur Sécurité.

- Dans la barre latérale gauche, cliquez sur Code scanning.
- Click the name of an alert.
- If Correctif automatique Copilot can suggest a fix, at the top of the page, click Generate fix.
- Once the suggested fix has been generated, at the bottom of the page, you can click Create PR with fix to automatically generate a pull request with the suggested fix. A new branch is created from the default branch, the generated fix is committed and a draft pull request is created. You can test and edit the suggested fix as you would with any other fix.
You can also use the Autofix API for historical alerts endpoints to generate, get, and commit suggested fixes.
- Create an autofix for a code scanning alert
- Get the status of an autofix for a code scanning alert
- Commit an autofix for a code scanning alert
Correctif automatique Copilot for code scanning alerts won't be able to generate a fix for every alert in every situation. The feature operates on a best-effort basis and is not guaranteed to succeed 100% of the time. For information about the limitations of automatically generated fixes, see Limitations of suggestions.
Assigning alerts to Agent de codage Copilot
Remarque
This option is currently in public preview and is subject to change. Agent de codage Copilot must be available in the repository.
You can assign Copilot to apply an autofix. Copilot analyzes the code scanning alert, creates a remediation plan, and implements the necessary code changes in a pull request.
- Sur GitHub, accédez à la page principale du référentiel.
- Sous le nom du référentiel, cliquez sur Sécurité. Si vous ne voyez pas l’onglet « Sécurité », sélectionnez le menu déroulant et cliquez sur Sécurité.

- Dans la barre latérale gauche, cliquez sur Code scanning.
- Click the name of an alert.
- If an autofix has not been generated and Correctif automatique Copilot can suggest a fix, at the top of the page, click Generate fix.
- In the right-side menu, click Assignees.
- Select "Copilot".
Within 30 seconds, Copilot will open a pull request to address the alert and will include a summary of the fixes and details of the changes made. Once created, the pull request is shown in the "Development" section.
Fixing an alert manually
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 Triaging code scanning alerts in pull requests.
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.

Veuillez noter que si vous avez filtré les alertes sur une branche autre que celle par défaut, mais que les mêmes alertes existent sur la branche par défaut, la page d’une alerte donnée reflétera uniquement l’état de l’alerte sur la branche par défaut, même si cet état est en conflit avec celui d’une branche autre que celle par défaut. Par exemple, une alerte qui apparaît dans la liste « Ouvertes » dans le résumé des alertes de la branch-x peut présenter l’état « Résolue » sur la page de l’alerte, si l’alerte est déjà résolue sur la branche par défaut. Vous pouvez consulter l’état de l’alerte pour la branche filtrée dans la section Branches affectées sur le côté droit de la page de l’alerte.
Remarque
If you run code scanning using multiple configurations, the same alert will sometimes be generated by more than one configuration. Unless you run all configurations regularly, you may see alerts that are fixed in one configuration but not in another. These stale configurations and alerts can be removed from a branch. For more information, see Removing stale configurations and alerts from a branch.
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. Par exemple, dans le cas d’une erreur présente dans du code utilisé uniquement à des fins de test, ou quand l’effort de correction de l’erreur est supérieur à l’avantage potentiel que représente l’amélioration du code. 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:
-
Sur GitHub, accédez à la page principale du référentiel.
-
Sous le nom du référentiel, cliquez sur Sécurité. Si vous ne voyez pas l’onglet « Sécurité », sélectionnez le menu déroulant et cliquez sur Sécurité.

-
Dans la barre latérale gauche, cliquez sur Code scanning.
-
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.
-
Review the alert, then click Dismiss alert and choose, or type, a reason for closing the alert.
Il est important de choisir le motif approprié dans le menu déroulant, car cela peut avoir une incidence sur l’inclusion ou non d’une requête dans une analyse future. Si vous le souhaitez, vous pouvez commenter un rejet pour enregistrer le contexte du rejet d’une alerte. Le commentaire sur le licenciement est ajouté à la chronologie des alertes et peut être utilisé comme justification lors de l’audit et de la création de rapports. Vous pouvez récupérer ou définir un commentaire à l’aide de l’API REST d’analyse du code. Le commentaire est contenu dans
dismissed_commentpour le point de terminaisonalerts/{alert_number}. Pour plus d’informations, consultez « Points de terminaison d’API REST pour l’analyse de codes ».Si vous ignorez une alerte CodeQL que vous considérez comme un résultat faux positif, par exemple parce que le code utilise une bibliothèque d’assainissement qui n’est pas prise en charge, envisagez de contribuer au dépôt CodeQL et d’améliorer l’analyse. Pour plus d’informations sur CodeQL, consultez Contribution à 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.
Re-opening dismissed alerts
If you dismiss an alert but later realize that you need to fix the alert, you can re-open it and fix the problem with the code. Display the list of closed alerts, find the alert, display it, and reopen it. You can then fix the alert in the same way as any other alert.
Removing stale configurations and alerts from a branch
You may have multiple code scanning configurations on a single repository. When run, multiple configurations can generate the same alert. Additionally, if the configurations are run on different schedules, the alert statuses may become out-of-date for infrequent or stale configurations. For more information on alerts from multiple configurations, see À propos des alertes d’analyse du code.
-
Sur GitHub, accédez à la page principale du référentiel.
-
Sous le nom du référentiel, cliquez sur Sécurité. Si vous ne voyez pas l’onglet « Sécurité », sélectionnez le menu déroulant et cliquez sur Sécurité.

-
Dans la barre latérale gauche, cliquez sur Code scanning.
-
Under "Code scanning", click a code scanning alert.
-
In the "Affected branches" section of the sidebar, click the desired branch.
-
In the "Configurations analyzing" dialog, review details of the configurations that reported this alert on the selected branch. To delete an unwanted configuration for the desired branch, click .
If you delete a configuration by mistake, click Cancel to avoid applying your changes.

-
Once you have removed any unwanted configurations and confirmed the expected configurations are displayed, click Save changes.
If you save your changes after accidentally deleting a configuration, re-run the configuration to update the alert. For more information on re-running configurations that use GitHub Actions, see Ré-exécution de workflows et de travaux.
Remarque
- If you remove all code scanning configurations for the default branch of your repository, the default branch will remain in the "Affected branches" sidebar, but it will not be analyzed by any configurations.
- If you remove all code scanning configurations for any branch other than the default branch of your repository, that branch will be removed from the "Affected branches" sidebar.