Envio de dependência
A API de envio de dependências permite que você envie dependências para projetos, como as dependências resolvidas quando um projeto é construído ou compilado.
Sobre a API de envio de dependência
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 Alertas do Dependabot and Atualizações de segurança do Dependabot for any known vulnerabilities. Você só obterá Alertas do Dependabot para dependências que são de um dos ecossistemas compatíveis do Banco de Dados Consultivo GitHub. Submitted dependencies will not be surfaced in dependency review or your organization's dependency insights.
As dependências são enviadas para a API de envio de dependência na forma de um instantâneo. Um instantâneo é um conjunto de dependências associadas a um commit SHA e outros metadados, que reflete o estado atual do seu repositório para um commit. Você pode optar por usar ações pré-criadas ou criar suas próprias ações para enviar suas dependências para a API de envio de dependências no formato exigido cada vez que o seu projeto for criado. Para obter mais informações sobre o uso da API de envio de dependências, consulte "Usando a API de envio de dependência".
Você pode enviar vários conjuntos de dependências para a API de submissão de dependências a ser incluídos no seu gráfico de dependências. A API usa a propriedade job.correlator e a categoria detector.name do instantâneo para garantir que as submissões mais recentes para cada fluxo de trabalho sejam exibidas. A propriedade correlator é o campo primário que você usará para manter os envios independentes distintos. Um exemplo de correlator pode ser uma combinação simples de duas variáveis disponíveis em ações executadas: <GITHUB_WORKFLOW> <GITHUB_JOB>.
Create a snapshot of dependencies for a repository
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
| Headers | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Nome, Tipo, Descrição | ||||||||||||||||||||
acceptstringSetting to | ||||||||||||||||||||
| Path parameters | ||||||||||||||||||||
| Nome, Tipo, Descrição | ||||||||||||||||||||
ownerstringObrigatórioThe account owner of the repository. The name is not case sensitive. | ||||||||||||||||||||
repostringObrigatórioThe name of the repository. The name is not case sensitive. | ||||||||||||||||||||
| Body parameters | ||||||||||||||||||||
| Nome, Tipo, Descrição | ||||||||||||||||||||
versionintegerObrigatórioThe version of the repository snapshot submission. | ||||||||||||||||||||
jobobjectObrigatório | ||||||||||||||||||||
Properties of the | ||||||||||||||||||||
| Nome, Tipo, Descrição |
|---|
idstringObrigatórioThe external ID of the job. |
correlatorstringObrigatórioCorrelator provides a key that is used to group snapshots submitted over time. Only the "latest" submitted snapshot for a given combination of |
html_urlstringThe url for the job. |
shastringObrigatórioThe commit SHA associated with this dependency snapshot.
refstringObrigatórioThe repository branch that triggered this snapshot.
detectorobjectObrigatórioA description of the detector used.
Properties of thedetectorobject
| Nome, Tipo, Descrição |
|---|
namestringObrigatórioThe name of the detector used. |
versionstringObrigatórioThe version of the detector used. |
urlstringObrigatórioThe url of the detector used. |
metadataobjectUser-defined metadata to store domain-specific information limited to 8 keys with scalar values.
manifestsobjectA collection of package manifests
Properties of themanifestsobject
| Nome, Tipo, Descrição |
|---|
keystringA user-defined key to represent an item in |
Properties of thekeyobject
| Nome, Tipo, Descrição |
|---|
namestringObrigatórioThe name of the manifest. |
fileobject |
metadataobjectUser-defined metadata to store domain-specific information limited to 8 keys with scalar values. |
resolved |
Properties of thefileobject
| Nome, Tipo, Descrição |
|---|
source_locationstringThe path of the manifest file relative to the root of the Git repository. |
Properties of theresolved
| Nome, Tipo, Descrição |
|---|
keystringA user-defined key to represent an item in |
Properties of thekeyobject
| Nome, Tipo, Descrição |
|---|
package_urlstringPackage-url (PURL) of dependency. See https://github.com/package-url/purl-spec for more details. |
metadataobjectUser-defined metadata to store domain-specific information limited to 8 keys with scalar values. |
relationshipstringA notation of whether a dependency is requested directly by this manifest or is a dependency of another dependency. Pode ser uma das ações a seguir: |
scopestringA 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. Pode ser uma das ações a seguir: |
dependenciesarray of stringsArray of package-url (PURLs) of direct child dependencies. |
scannedstringObrigatórioThe time at which the snapshot was scanned.
HTTP response status codes
| Status code | Descrição |
|---|---|
201 | Created |
Amostras de código
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"
}