Skip to main content
L’API REST est maintenant versionnée. Pour plus d’informations, consultez « À propos des versions de l’API ».

Points de terminaison d’API REST pour la nomenclature logicielle (SBOM)

Utilisez l’API REST pour exporter la nomenclature logicielle (SBOM) d’un référentiel.

Si vous disposez au moins d’un accès en lecture au dépôt, vous pouvez exporter les graphe des dépendances pour le dépôt en tant que nomenclature logicielle compatible SPDX (SBOM), via l’interface utilisateur de GitHub ou l’API REST GitHub. Pour plus d’informations, consultez « Exportation d’une nomenclature logicielle pour votre dépôt ».

Cet article fournit des détails sur le point de terminaison de l’API REST.

Export a software bill of materials (SBOM) for a repository.

Exports the software bill of materials (SBOM) for a repository in SPDX JSON format.

Jetons d’accès affinés pour « Export a software bill of materials (SBOM) for a repository. »

Ce point de terminaison fonctionne avec les types de jetons suivants:

Le jeton doit avoir l’ensemble d’autorisations suivant:

  • contents:read

Ce point de terminaison peut être utilisé sans authentification ou sans les autorisations mentionnées ci-dessus si seules les ressources publiques sont demandées.

Paramètres pour « Export a software bill of materials (SBOM) for a repository. »

En-têtes
Nom, Type, Description
accept string

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

Paramètres de chemin d’accès
Nom, Type, Description
owner string Obligatoire

The account owner of the repository. The name is not case sensitive.

repo string Obligatoire

The name of the repository without the .git extension. The name is not case sensitive.

Codes d’état de la réponse HTTP pour « Export a software bill of materials (SBOM) for a repository. »

Code d’étatDescription
200

OK

403

Forbidden

404

Resource not found

Exemples de code pour « Export a software bill of materials (SBOM) for a repository. »

Exemple de requête

get/repos/{owner}/{repo}/dependency-graph/sbom
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/OWNER/REPO/dependency-graph/sbom

Response

Status: 200
{ "sbom": { "SPDXID": "SPDXRef-DOCUMENT", "spdxVersion": "SPDX-2.3", "creationInfo": { "created": "2021-09-01T00:00:00Z", "creators": [ "Tool: GitHub.com-Dependency-Graph" ] }, "name": "github/example", "dataLicense": "CC0-1.0", "documentDescribes": [ "github/example" ], "documentNamespace": "https://github.com/github/example/dependency_graph/sbom-abcdef123456", "packages": [ { "SPDXID": "SPDXRef-Package", "name": "rubygems:rails", "versionInfo": "1.0.0", "downloadLocation": "NOASSERTION", "filesAnalyzed": false, "licenseConcluded": "MIT", "licenseDeclared": "MIT" } ] } }