Skip to main content
We publish frequent updates to our documentation, and translation of this page may still be in progress. For the most current information, please visit the English documentation.
The REST API is now versioned. For more information, see "About API versioning."

Envio de dependência

Use a API REST para enviar dependências.

Sobre os envios de dependências

Observação: a capacidade de usar a API REST para envio de dependência está atualmente em versão beta pública e sujeita a alterações.

Você pode usar a API REST para enviar dependências para um projeto. Isso permite que você adicione dependências, como aquelas resolvidas quando o software é compilado ou criado, ao recurso de gráfico de dependências do GitHub, fornecendo uma visão mais completa de todas as dependências do seu projeto.

O gráfico mostra todas as dependências que você envia usando a API, além de quaisquer dependências identificadas por meio de arquivos de manifesto ou de bloqueio no repositório (por exemplo, um arquivo package-lock.json em um projeto JavaScript). Para ver mais informações sobre como visualizar o gráfico de dependências, confira "Como explorar as dependências de um repositório".

As dependências enviadas receberão Dependabot alerts e Dependabot security updates para quaisquer vulnerabilidades conhecidas. Você só obterá Dependabot alerts para dependências que são de um dos ecossistemas com suporte do GitHub Advisory Database. As dependências enviadas não serão exibidas na revisão de dependência ou nas informações de dependência da sua organização.

É possível enviar dependências na forma de um instantâneo. Um instantâneo é um conjunto de dependências associadas a um SHA de commit e a outros metadados, que reflete o estado atual do repositório de um commit. É possível optar por usar ações predefinidas ou criar suas próprias ações para enviar suas dependências no formato necessário sempre que seu projeto for criado. Para obter mais informações, confira "Como usar a API de envio de dependência".

É possível enviar diversos conjuntos de dependências para serem incluídos em seu grafo de dependência. A API REST usa a propriedade job.correlator e a categoria detector.name do instantâneo para garantir que os envios mais recentes para cada fluxo de trabalho sejam exibidos. A propriedade correlator em si é o campo primário que você usará para diferenciar os envios independentes. Um correlator de exemplo pode ser uma combinação simples de duas variáveis disponíveis em execuções de ações: <GITHUB_WORKFLOW> <GITHUB_JOB>.

Create a snapshot of dependencies for a repository

Works with 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.

Parameters for "Create a snapshot of dependencies for a repository"

Headers
Name, Type, Description
acceptstring

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

Path parameters
Name, Type, Description
ownerstringRequired

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

repostringRequired

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

Body parameters
Name, Type, Description
versionintegerRequired

The version of the repository snapshot submission.

jobobjectRequired
Name, Type, Description
idstringRequired

The external ID of the job.

correlatorstringRequired

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.

shastringRequired

The commit SHA associated with this dependency snapshot. Maximum length: 40 characters.

refstringRequired

The repository branch that triggered this snapshot.

detectorobjectRequired

A description of the detector used.

Name, Type, Description
namestringRequired

The name of the detector used.

versionstringRequired

The version of the detector used.

urlstringRequired

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, which are a collection of related dependencies declared in a file or representing a logical group of dependencies.

Name, Type, Description
keyobject

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

Name, Type, Description
namestringRequired

The name of the manifest.

fileobject
Name, Type, Description
source_locationstring

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

metadataobject

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

resolvedobject

A collection of resolved package dependencies.

Name, Type, Description
keyobject

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

Name, Type, Description
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.

Can be one of: 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.

Can be one of: runtime, development

dependenciesarray of strings

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

scannedstringRequired

The time at which the snapshot was scanned.

HTTP response status codes for "Create a snapshot of dependencies for a repository"

Status codeDescription
201

Created

Code samples for "Create a snapshot of dependencies for a repository"

post/repos/{owner}/{repo}/dependency-graph/snapshots
curl -L \ -X POST \ -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/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" }