Analyse du code
Utilisez l’API REST pour récupérer et mettre à jour les alertes code scanning d’un dépôt.
À propos de l’analyse du code
Vous pouvez récupérer et mettre à jour les alertes code scanning d’un dépôt. Vous pouvez utiliser les points de terminaison pour créer des rapports automatisés pour les alertes code scanning dans une organisation ou charger les résultats d’analyse générés à l’aide d’outils code scanning hors connexion. Pour plus d’informations, consultez « Recherche de vulnérabilités et d’erreurs de sécurité dans votre code ».
Type de média personnalisé pour code scanning
Il existe un type de média personnalisé pris en charge pour les points de terminaison code scanning.
application/sarif+json
Vous pouvez l’utiliser avec les demandes GET envoyées au point de terminaison /analyses/{analysis_id}. Pour plus d’informations sur cette opération, consultez « Obtenir une analyse de code scanning pour un référentiel ». Lorsque vous utilisez ce type média avec cette opération, la réponse comprend un sous-ensemble des données réelles qui ont été chargées pour l’analyse spécifiée, plutôt que le résumé de l’analyse qui est retourné lorsque vous utilisez le type média par défaut. La réponse comprend également des données supplémentaires, telles que les propriétés github/alertNumber et github/alertUrl. Les données sont mises en forme en tant que SARIF version 2.1.0.
Pour plus d’informations, consultez « Types de médias ».
List code scanning alerts for an organization
Lists code scanning alerts for the default branch for all eligible repositories in an organization. Eligible repositories are repositories that are owned by organizations that you own or for which you are a security manager. For more information, see "Managing security managers in your organization."
To use this endpoint, you must be an owner or security manager for the organization, and you must use an access token with the repo scope or security_events scope.
For public repositories, you may instead use the public_repo scope.
GitHub Apps must have the security_events read permission to use this endpoint.
Parameters
| Headers |
|---|
| Nom, Type, Description |
acceptstringSetting to |
| Path parameters |
| Nom, Type, Description |
orgstringRequiredThe organization name. The name is not case sensitive. |
| Query parameters |
| Nom, Type, Description |
tool_namestringThe name of a code scanning tool. Only results by this tool will be listed. You can specify the tool by using either |
tool_guidstringnullThe GUID of a code scanning tool. Only results by this tool will be listed. Note that some code scanning tools may not include a GUID in their analysis data. You can specify the tool by using either |
beforestringA cursor, as given in the Link header. If specified, the query only searches for results before this cursor. |
afterstringA cursor, as given in the Link header. If specified, the query only searches for results after this cursor. |
pageintegerPage number of the results to fetch. Default: |
per_pageintegerThe number of results per page (max 100). Default: |
directionstringThe direction to sort the results by. Default: Can be one of: |
statestringIf specified, only code scanning alerts with this state will be returned. Can be one of: |
sortstringThe property by which to sort the results. Default: Can be one of: |
severitystringIf specified, only code scanning alerts with this severity will be returned. Can be one of: |
HTTP response status codes
| Status code | Description |
|---|---|
200 | OK |
404 | Resource not found |
503 | Service unavailable |