Skip to main content

Dependency submission

The Dependency submission API allows you to submit dependencies for projects, such as the dependencies resolved when a project is built or compiled.

About the Dependency submission API

Note: The Dependency submission API is currently in public beta and subject to change.

The Dependency submission API lets you submit dependencies for a project. This enables you to add dependencies, such as those resolved when software is compiled or built, to GitHub's dependency graph feature, providing a more complete picture of all of your project's dependencies.

The dependency graph shows any dependencies you submit using the API in addition to any dependencies that are identified from manifest or lock files in the repository (for example, a package-lock.json file in a JavaScript project). For more information about viewing the dependency graph, see "Exploring the dependencies of a repository."

Submitted dependencies will receive Las alertas del dependabot and Actualizaciones de seguridad del dependabot for any known vulnerabilities. Solo obtendrás Las alertas del dependabot para las dependencias que sean de uno de los ecosistemas compatibles de la GitHub Advisory Database. Submitted dependencies will not be surfaced in dependency review or your organization's dependency insights.

Dependencies are submitted to the dependency submission API in the form of a snapshot. A snapshot is a set of dependencies associated with a commit SHA and other metadata, that reflects the current state of your repository for a commit. You can choose to use pre-made actions or create your own actions to submit your dependencies to the dependency submission API in the required format each time your project is built. For more information about using the Dependency submission API, see "Using the Dependency submission API."

You can submit multiple sets of dependencies to the Dependency submission API to be included in your dependency graph. The API uses the job.correlator property and the detector.name category of the snapshot to ensure the latest submissions for each workflow get shown. The correlator property itself is the primary field you will use to keep independent submissions distinct. An example correlator could be a simple combination of two variables available in actions runs: <GITHUB_WORKFLOW> <GITHUB_JOB>.

Create a snapshot of dependencies for a repository

Funciona con GitHub Apps

Create a new snapshot of a repository's dependencies. You must authenticate using an access token with the repo scope to use this endpoint for a repository that the requesting user has access to.

Parámetros

Encabezados
Nombre, Tipo, Descripción
acceptstring

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

Parámetros de ruta
Nombre, Tipo, Descripción
ownerstringRequerido

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

repostringRequerido

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

Parámetros de cuerpo
Nombre, Tipo, Descripción
versionintegerRequerido

The version of the repository snapshot submission.

jobobjectRequerido
Nombre, Tipo, Descripción
idstringRequerido

The external ID of the job.

correlatorstringRequerido

Correlator provides a key that is used to group snapshots submitted over time. Only the "latest" submitted snapshot for a given combination of job.correlator and detector.name will be considered when calculating a repository's current dependencies. Correlator should be as unique as it takes to distinguish all detection runs for a given "wave" of CI workflow you run. If you're using GitHub Actions, a good default value for this could be the environment variables GITHUB_WORKFLOW and GITHUB_JOB concatenated together. If you're using a build matrix, then you'll also need to add additional key(s) to distinguish between each submission inside a matrix variation.

html_urlstring

The url for the job.

shastringRequerido

The commit SHA associated with this dependency snapshot.

refstringRequerido

The repository branch that triggered this snapshot.

detectorobjectRequerido

A description of the detector used.

Nombre, Tipo, Descripción
namestringRequerido

The name of the detector used.

versionstringRequerido

The version of the detector used.

urlstringRequerido

The url of the detector used.

metadataobject

User-defined metadata to store domain-specific information limited to 8 keys with scalar values.

manifestsobject

A collection of package manifests

Nombre, Tipo, Descripción
keystring

A user-defined key to represent an item in manifests.

Nombre, Tipo, Descripción
namestringRequerido

The name of the manifest.

fileobject
metadataobject

User-defined metadata to store domain-specific information limited to 8 keys with scalar values.

resolved
Nombre, Tipo, Descripción
source_locationstring

The path of the manifest file relative to the root of the Git repository.

Nombre, Tipo, Descripción
keystring

A user-defined key to represent an item in resolved.

Nombre, Tipo, Descripción
package_urlstring

Package-url (PURL) of dependency. See https://github.com/package-url/purl-spec for more details.

metadataobject

User-defined metadata to store domain-specific information limited to 8 keys with scalar values.

relationshipstring

A notation of whether a dependency is requested directly by this manifest or is a dependency of another dependency.

Puede ser una de las siguientes: direct, indirect

scopestring

A notation of whether the dependency is required for the primary build artifact (runtime) or is only used for development. Future versions of this specification may allow for more granular scopes.

Puede ser una de las siguientes: runtime, development

dependenciesarray of strings

Array of package-url (PURLs) of direct child dependencies.

scannedstringRequerido

The time at which the snapshot was scanned.

Códigos de estado de respuesta HTTP

Código de estadoDescripción
201

Created

Ejemplos de código

post/repos/{owner}/{repo}/dependency-graph/snapshots
curl \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: token <TOKEN>" \ https://api.github.com/repos/OWNER/REPO/dependency-graph/snapshots \ -d '{"version":0,"sha":"ce587453ced02b1526dfb4cb910479d431683101","ref":"refs/heads/main","job":{"correlator":"yourworkflowname_youractionname","id":"yourrunid"},"detector":{"name":"octo-detector","version":"0.0.1","url":"https://github.com/octo-org/octo-repo"},"scanned":"2022-06-14T20:25:00Z","manifests":{"package-lock.json":{"name":"package-lock.json","file":{"source_location":"src/package-lock.json"},"resolved":{"@actions/core":{"package_url":"pkg:/npm/%40actions/core@1.1.9","dependencies":["@actions/http-client"]},"@actions/http-client":{"package_url":"pkg:/npm/%40actions/http-client@1.0.7","dependencies":["tunnel"]},"tunnel":{"package_url":"pkg:/npm/tunnel@0.0.6"}}}}}'

Response

Status: 201
{ "id": 12345, "created_at": "2018-05-04T01:14:52Z", "message": "Dependency results for the repo have been successfully updated.", "result": "SUCCESS" }