Отправка зависимостей
Используйте 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.
Параметры
Заголовки | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Имя, Тип, Описание | ||||||||||||||||||||||||||||||||||||
accept stringSetting to | ||||||||||||||||||||||||||||||||||||
Параметры пути | ||||||||||||||||||||||||||||||||||||
Имя, Тип, Описание | ||||||||||||||||||||||||||||||||||||
owner stringОбязательноThe account owner of the repository. The name is not case sensitive. | ||||||||||||||||||||||||||||||||||||
repo stringОбязательноThe name of the repository. The name is not case sensitive. | ||||||||||||||||||||||||||||||||||||
Параметры запроса | ||||||||||||||||||||||||||||||||||||
Имя, Тип, Описание | ||||||||||||||||||||||||||||||||||||
version integerОбязательноThe version of the repository snapshot submission. | ||||||||||||||||||||||||||||||||||||
job objectОбязательно | ||||||||||||||||||||||||||||||||||||
Properties of |
Имя, Тип, Описание |
---|
id stringОбязательноThe external ID of the job. |
correlator stringОбязательноCorrelator 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
stringОбязательноThe commit SHA associated with this dependency snapshot. Maximum length: 40 characters.
ref
stringОбязательноThe repository branch that triggered this snapshot.
detector
objectОбязательноA description of the detector used.
Properties of detector
Имя, Тип, Описание |
---|
name stringОбязательноThe name of the detector used. |
version stringОбязательноThe version of the detector used. |
url stringОбязательноThe 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
Имя, Тип, Описание | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
key objectA user-defined key to represent an item in | ||||||||||||||||||||||||||||||
Properties of |
Имя, Тип, Описание | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
name stringОбязательноThe name of the manifest. | |||||||||||||||
file object | |||||||||||||||
Properties of |
Имя, Тип, Описание |
---|
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
Имя, Тип, Описание | |||||||||
---|---|---|---|---|---|---|---|---|---|
key objectA user-defined key to represent an item in | |||||||||
Properties of |
Имя, Тип, Описание |
---|
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. Может быть одним из: |
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. Может быть одним из: |
dependencies array of stringsArray of package-url (PURLs) of direct child dependencies. |
scanned
stringОбязательноThe time at which the snapshot was scanned.
Коды состояния HTTP-ответа
Код состояния | Описание |
---|---|
201 | Created |
Примеры кода
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"
}