Отправка зависимостей
Используйте REST API для отправки зависимостей.
Сведения об отправке зависимостей
Примечание: Возможность использования REST API для отправки зависимостей в настоящее время находится в общедоступной бета-версии и может быть изменена.
Для отправки зависимостей для проекта можно использовать REST API. Так вы сможете добавлять зависимости, например разрешаемые при компиляции или сборке программного обеспечения, в функцию графа зависимостей GitHub, чтобы создать более полную картину всех зависимостей проекта.
На графе зависимостей отображаются все зависимости, которые вы отправили через этот API, а также те, которые определены в файлах манифеста или блокировки, размещенных в репозитории (например, файл package-lock.json
в проекте JavaScript). Дополнительные сведения о просмотре графа зависимостей см. в статье Изучение зависимостей репозитория.
Отправленные зависимости будут получать Dependabot alerts и Dependabot security updates по всем известным уязвимостям. Вы будете получать Dependabot alerts только для тех зависимостей, которые относятся к одной из поддерживаемых экосистем GitHub Advisory Database. Отправленные зависимости не будут отображаться при проверке зависимостей или в аналитических сведениях о зависимостях в вашей организации.
Зависимости можно отправлять в виде моментального снимка. Моментальный снимок — это набор зависимостей, связанных с SHA фиксации и другими метаданными, которые отражают текущее состояние репозитория для фиксации. Вы можете использовать готовые действия или создавать собственные действия для отправки зависимостей в требуемом формате при каждой сборке проекта. Дополнительные сведения см. в разделе Использование API отправки зависимостей.
Вы можете отправить несколько наборов зависимостей, которые будут включены в граф зависимостей. REST API использует job.correlator
свойство и категорию detector.name
моментального снимка, чтобы обеспечить отображения последних отправок для каждого рабочего процесса. Само свойство correlator
является основным полем, которое будет использоваться для различения независимых отправок. Например, в качестве correlator
можно использовать простое сочетание двух переменных, доступных в выполнениях действий: <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 | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Имя, Type, Описание | ||||||||||||||||||||||||||||||||||||
accept stringSetting to | ||||||||||||||||||||||||||||||||||||
Path parameters | ||||||||||||||||||||||||||||||||||||
Имя, Type, Описание | ||||||||||||||||||||||||||||||||||||
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 | ||||||||||||||||||||||||||||||||||||
Имя, Type, Описание | ||||||||||||||||||||||||||||||||||||
version integerRequiredThe version of the repository snapshot submission. | ||||||||||||||||||||||||||||||||||||
job objectRequired | ||||||||||||||||||||||||||||||||||||
Properties of |
Имя, Type, Описание |
---|
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
Имя, Type, Описание |
---|
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
Имя, Type, Описание | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
key objectA user-defined key to represent an item in | ||||||||||||||||||||||||||||||
Properties of |
Имя, Type, Описание | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name stringRequiredThe name of the manifest. | |||||||||||||||
file object | |||||||||||||||
Properties of |
Имя, Type, Описание |
---|
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
Имя, Type, Описание | |||||||||
---|---|---|---|---|---|---|---|---|---|
key objectA user-defined key to represent an item in | |||||||||
Properties of |
Имя, Type, Описание |
---|
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 | Описание |
---|---|
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"
}