Skip to main content
The REST API is now versioned. For more information, see "About API versioning."

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

Works with GitHub Apps

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
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Nom, Type, Description
orgstringRequired

The organization name. The name is not case sensitive.

Query parameters
Nom, Type, Description
tool_namestring

The name of a code scanning tool. Only results by this tool will be listed. You can specify the tool by using either tool_name or tool_guid, but not both.

tool_guidstringnull

The 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 tool_guid or tool_name, but not both.

beforestring

A cursor, as given in the Link header. If specified, the query only searches for results before this cursor.

afterstring

A cursor, as given in the Link header. If specified, the query only searches for results after this cursor.

pageinteger

Page number of the results to fetch.

Default: 1

per_pageinteger

The number of results per page (max 100).

Default: 30

directionstring

The direction to sort the results by.

Default: desc

Can be one of: asc, desc

statestring

If specified, only code scanning alerts with this state will be returned.

Can be one of: open, closed, dismissed, fixed

sortstring

The property by which to sort the results.

Default: created

Can be one of: created, updated

severitystring

If specified, only code scanning alerts with this severity will be returned.

Can be one of: critical, high, medium, low, warning, note, error

HTTP response status codes

Status codeDescription
200

OK

404

Resource not found

503

Service unavailable

Code samples

get/orgs/{org}/code-scanning/alerts