Abhängigkeitsübermittlung
Verwende die REST-API, um Abhängigkeiten zu übermitteln.
Informationen zu Abhängigkeitsübermittlungen
Hinweis: Die Möglichkeit zur Verwendung der REST-API für die Übermittlung von Abhängigkeiten befindet sich derzeit in der öffentlichen Betaversion und kann noch geändert werden.
Du kannst die REST-API verwenden, um Abhängigkeiten für ein Projekt zu übermitteln. Dadurch kannst du Abhängigkeiten wie die, die beim Kompilieren oder Erstellen von Software aufgelöst werden, zum Abhängigkeitsdiagrammfeature von GitHub hinzufügen und ein vollständigeres Bild aller Abhängigkeiten deines Projekts bieten.
Das Abhängigkeitsdiagramm zeigt alle Abhängigkeiten, die du mithilfe der API übermittelst, zusätzlich zu allen Abhängigkeiten, die von Manifest- oder Sperrdateien im Repository aus identifiziert werden (z. B. eine package-lock.json
-Datei in einem JavaScript-Projekt). Weitere Informationen zum Anzeigen des Abhängigkeitsdiagramms findest du unter Erkunden der Abhängigkeiten eines Repositorys.
Übermittelte Abhängigkeiten erhalten Dependabot alerts und Dependabot security updates für alle bekannten Sicherheitsrisiken. Du empfängst Dependabot alerts nur für Abhängigkeiten, die von einem der unterstützten Ökosysteme von GitHub Advisory Database stammen. Übermittelte Abhängigkeiten werden nicht in Abhängigkeitsüberprüfungen oder den Abhängigkeitserkenntnissen deiner Organisation angezeigt.
Du kannst Abhängigkeiten in Form einer Momentaufnahme übermitteln. Eine Momentaufnahme ist eine Reihe von Abhängigkeiten, die einem Commit-SHA und anderen Metadaten zugeordnet sind, die den aktuellen Status deines Repositorys für einen Commit widerspiegeln. Du kannst dich entscheiden, vordefinierte Aktionen zu verwenden, oder eigene Aktionen zu erstellen, um jedes Mal, wenn dein Projekt erstellt wird, deine Abhängigkeiten im erforderlichen Format zu übermitteln. Weitere Informationen findest du unter Verwenden der Abhängigkeitsübermittlungs-API.
Du kannst mehrere Gruppen von Abhängigkeiten übermitteln, die in deinem Abhängigkeitsdiagramm enthalten sein sollen. Die REST-API verwendet die Eigenschaft job.correlator
und die Kategorie detector.name
der Momentaufnahme, um sicherzustellen, dass die neuesten Übermittlungen für jeden Workflow angezeigt werden. Die correlator
-Eigenschaft selbst ist das primäre Feld, mit dem du unabhängige Übermittlungen auseinander hältst. Ein Beispiel correlator
könnte eine einfache Kombination aus zwei Variablen sein, die in Aktionen verfügbar sind: <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.
Parameters
Headers | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Name, Type, BESCHREIBUNG | ||||||||||||||||||||||||||||||||||||
accept stringSetting to | ||||||||||||||||||||||||||||||||||||
Path parameters | ||||||||||||||||||||||||||||||||||||
Name, Type, BESCHREIBUNG | ||||||||||||||||||||||||||||||||||||
owner stringRequiredThe account owner of the repository. The name is not case sensitive. | ||||||||||||||||||||||||||||||||||||
repo stringRequiredThe name of the repository. The name is not case sensitive. | ||||||||||||||||||||||||||||||||||||
Body parameters | ||||||||||||||||||||||||||||||||||||
Name, Type, BESCHREIBUNG | ||||||||||||||||||||||||||||||||||||
version integerRequiredThe version of the repository snapshot submission. | ||||||||||||||||||||||||||||||||||||
job objectRequired | ||||||||||||||||||||||||||||||||||||
Properties of |
Name, Type, BESCHREIBUNG |
---|
id stringRequiredThe external ID of the job. |
correlator stringRequiredCorrelator provides a key that is used to group snapshots submitted over time. Only the "latest" submitted snapshot for a given combination of |
html_url stringThe url for the job. |
sha
stringRequiredThe commit SHA associated with this dependency snapshot. Maximum length: 40 characters.
ref
stringRequiredThe repository branch that triggered this snapshot.
detector
objectRequiredA description of the detector used.
Properties of detector
Name, Type, BESCHREIBUNG |
---|
name stringRequiredThe name of the detector used. |
version stringRequiredThe version of the detector used. |
url stringRequiredThe url of the detector used. |
metadata
objectUser-defined metadata to store domain-specific information limited to 8 keys with scalar values.
manifests
objectA collection of package manifests, which are a collection of related dependencies declared in a file or representing a logical group of dependencies.
Properties of manifests
Name, Type, BESCHREIBUNG | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
key objectA user-defined key to represent an item in | ||||||||||||||||||||||||||||||
Properties of |
Name, Type, BESCHREIBUNG | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name stringRequiredThe name of the manifest. | |||||||||||||||
file object | |||||||||||||||
Properties of |
Name, Type, BESCHREIBUNG |
---|
source_location stringThe path of the manifest file relative to the root of the Git repository. |
metadata
objectUser-defined metadata to store domain-specific information limited to 8 keys with scalar values.
resolved
objectA collection of resolved package dependencies.
Properties of resolved
Name, Type, BESCHREIBUNG | |||||||||
---|---|---|---|---|---|---|---|---|---|
key objectA user-defined key to represent an item in | |||||||||
Properties of |
Name, Type, BESCHREIBUNG |
---|
package_url stringPackage-url (PURL) of dependency. See https://github.com/package-url/purl-spec for more details. |
metadata objectUser-defined metadata to store domain-specific information limited to 8 keys with scalar values. |
relationship stringA notation of whether a dependency is requested directly by this manifest or is a dependency of another dependency. Can be one of: |
scope stringA 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: |
dependencies array of stringsArray of package-url (PURLs) of direct child dependencies. |
scanned
stringRequiredThe time at which the snapshot was scanned.
HTTP response status codes
Status code | BESCHREIBUNG |
---|---|
201 | Created |
Code samples
curl \
-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"
}