Skip to content

Commit b4be9fc

Browse files
authored
Merge pull request github#27653 from github/ske-dep-api
[2022-06-16] Dependency submission API - new article + new subcategory
2 parents 55d6ed9 + bbf856c commit b4be9fc

File tree

14 files changed

+1759
-1
lines changed

14 files changed

+1759
-1
lines changed

content/code-security/guides.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ includeGuides:
8484
- /code-security/supply-chain-security/managing-vulnerabilities-in-your-projects-dependencies/viewing-and-updating-vulnerable-dependencies-in-your-repository
8585
- /code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review
8686
- /code-security/supply-chain-security/understanding-your-software-supply-chain/about-the-dependency-graph
87+
- /code-security/supply-chain-security/understanding-your-software-supply-chain/using-the-dependency-submission-api
8788
- /code-security/supply-chain-security/understanding-your-software-supply-chain/exploring-the-dependencies-of-a-repository
8889
---
8990

content/code-security/supply-chain-security/understanding-your-software-supply-chain/exploring-the-dependencies-of-a-repository.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ Enterprise owners can configure the dependency graph at an enterprise level. For
4242
{% ifversion fpt or ghec %}
4343
Dependencies are grouped by ecosystem. You can expand a dependency to view its dependencies. Dependencies on private repositories, private packages, or unrecognized files are shown in plain text. If the package manager for the dependency is in a public repository, {% data variables.product.product_name %} will display a link to that repository.
4444

45+
{% ifversion dependency-submission-api %}
46+
Dependencies submitted to a project using the Dependency submission API (beta), although also grouped by ecosystem, are shown separately from dependencies identified through manifest or lock files in the repository. These submitted dependencies appear in the dependency graph as "Snapshot dependencies" because they are submitted as a snapshot, or set, of dependencies. For more information on using the dependency submission API, see "[Using the Dependency submission API](/code-security/supply-chain-security/understanding-your-software-supply-chain/using-the-dependency-submission-api)."
47+
{% endif %}
48+
4549
If vulnerabilities have been detected in the repository, these are shown at the top of the view for users with access to {% data variables.product.prodname_dependabot_alerts %}.
4650

4751
![Dependencies graph](/assets/images/help/graphs/dependencies_graph.png)

content/code-security/supply-chain-security/understanding-your-software-supply-chain/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ children:
1414
- /about-supply-chain-security
1515
- /about-the-dependency-graph
1616
- /configuring-the-dependency-graph
17+
- /using-the-dependency-submission-api
1718
- /about-dependency-review
1819
- /configuring-dependency-review
1920
- /exploring-the-dependencies-of-a-repository
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
title: Using the Dependency submission API
3+
intro: 'You can use the Dependency submission API to submit dependencies for projects, such as the dependencies resolved when a project is built or compiled.'
4+
shortTitle: Dependency submission API
5+
topics:
6+
- API
7+
- Dependency graph
8+
- Dependencies
9+
- REST
10+
versions:
11+
feature: dependency-submission-api
12+
---
13+
14+
{% data reusables.dependency-submission.dependency-submission-api-beta %}
15+
16+
## About the Dependency submission API
17+
18+
{% data reusables.dependency-submission.about-dependency-submission %}
19+
20+
Dependencies are submitted to the dependency submission API in the form of a snapshot. A snapshot is a set of dependencies associated with a commit SHA and other metadata, that reflects the current state of your repository for a commit. For more information about the Dependency submission API, see the [Dependency submission REST API documentation](/rest/dependency-graph/dependency-submission).
21+
22+
## Submitting dependencies at build-time
23+
24+
You can use the Dependency submission API in a {% data variables.product.prodname_actions %} workflow to submit dependencies for your project when your project is built.
25+
26+
### Using pre-made actions
27+
28+
The simplest way to use the Dependency submission API is by adding a pre-made action to your repository that will gather and convert the list of dependencies to the required snapshot format and submit the list to the API. Actions that complete these steps for various ecosystems are available on {% data variables.product.prodname_marketplace %} and more actions will be created during the course of the beta and beyond. You can find links to the currently available actions in the table below:
29+
30+
Ecosystem | Action |
31+
--- | --- |
32+
Go | [Go Dependency Submission](https://github.com/actions/go-dependency-submission)
33+
34+
For example, the following [Go Dependency Submission](https://github.com/actions/go-dependency-submission) workflow calculates the dependencies for a Go build-target (a Go file with a `main` function) and submits the list to the Dependency Submission API.
35+
36+
```yaml
37+
38+
name: Go Dependency Submission
39+
on:
40+
push:
41+
branches:
42+
- main
43+
44+
# The API requires write permission on the repository to submit dependencies
45+
permissions:
46+
contents: write
47+
48+
# Envionment variables to configure Go and Go modules. Customize as necessary
49+
env:
50+
GOPROXY: '' # A Go Proxy server to be used
51+
GOPRIVATE: '' # A list of modules are considered private and not requested from GOPROXY
52+
jobs:
53+
go-action-detection:
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: 'Checkout Repository'
57+
uses: {% data reusables.actions.action-checkout %}
58+
59+
- uses: {% data reusables.actions.action-setup-go %}
60+
with:
61+
go-version: ">=1.18.0"
62+
63+
- name: Run snapshot action
64+
uses: @actions/go-dependency-submission@v1
65+
with:
66+
# Required: Define the repo path to the go.mod file used by the
67+
# build target
68+
go-mod-path: go-example/go.mod
69+
#
70+
# Optional. Define the repo path of a build target,
71+
# a file with a `main()` function.
72+
# If undefined, this action will collect all dependencies
73+
# used by all build targets for the module. This may
74+
# include Go dependencies used by tests and tooling.
75+
go-build-target: go-example/cmd/octocat.go
76+
77+
```
78+
### Creating your own action
79+
80+
Alternatively, you can write your own action to submit dependencies for your project at build-time. Your workflow should:
81+
82+
1. Generate a list of dependencies for your project.
83+
2. Translate the list of dependencies into the snapshot format accepted by the Dependency submission API. For more information about the format, see the body parameters for the "Create a repository snapshot" API operation in the [Dependency submission REST API documentation](/rest/dependency-graph/dependency-submission).
84+
3. Submit the formatted list of dependencies to the Dependency submission API.
85+
86+
{% data variables.product.product_name %} maintains the [Dependency Submission Toolkit](https://github.com/github/dependency-submission-toolkit), a TypeScript library to help you build your own GitHub Action for submitting dependencies to the Dependency submission API. For more information about writing an action, see "[Creating actions](/actions/creating-actions)".
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: Dependency submission
3+
intro: 'The Dependency submission API allows you to submit dependencies for projects, such as the dependencies resolved when a project is built or compiled.'
4+
versions:
5+
feature: dependency-submission-api
6+
miniTocMaxHeadingLevel: 3
7+
---
8+
9+
## About the Dependency submission API
10+
11+
{% data reusables.dependency-submission.dependency-submission-api-beta %}
12+
13+
{% data reusables.dependency-submission.about-dependency-submission %}
14+
15+
Dependencies are submitted to the dependency submission API in the form of a snapshot. A snapshot is a set of dependencies associated with a commit SHA and other metadata, that reflects the current state of your repository for a commit. You can choose to use pre-made actions or create your own actions to submit your dependencies to the dependency submission API in the required format each time your project is built. For more information about using the Dependency submission API, see "[Using the Dependency submission API](/code-security/supply-chain-security/understanding-your-software-supply-chain/using-the-dependency-submission-api)."
16+
17+
You can submit multiple sets of dependencies to the Dependency submission API to be included in your dependency graph. The API uses the `job.correlator` property and the `detector.name` category of the snapshot to ensure the latest submissions for each workflow get shown. The `correlator` property itself is the primary field you will use to keep independent submissions distinct. An example `correlator` could be a simple combination of two variables available in actions runs: `<GITHUB_WORKFLOW> <GITHUB_JOB>`.

content/rest/dependency-graph/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ topics:
1111
miniTocMaxHeadingLevel: 3
1212
children:
1313
- /dependency-review
14+
- /dependency-submission
1415
redirect_from:
1516
- /rest/reference/dependency-graph
1617
---
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Issue 6397
2+
versions:
3+
fpt: '*'
4+
ghec: '*'
5+
ghes: '>3.6'
6+
ghae: 'issue-6397'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
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 {% data variables.product.prodname_dotcom %}'s dependency graph feature, providing a more complete picture of all of your project's dependencies.
2+
3+
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](/code-security/supply-chain-security/understanding-your-software-supply-chain/exploring-the-dependencies-of-a-repository#viewing-the-dependency-graph)."
4+
5+
Submitted dependencies will receive {% data variables.product.prodname_dependabot_alerts %}, {% data variables.product.prodname_dependabot_version_updates %} and {% data variables.product.prodname_dependabot_security_updates %} for any known vulnerabilities. You will only get {% data variables.product.prodname_dependabot_alerts %} for dependencies that are from one of the [supported ecosystems](https://github.com/github/advisory-database#supported-ecosystems) of the {% data variables.product.prodname_advisory_database %}. Submitted dependencies will not be surfaced in dependency review or your organization's dependency insights.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% note %}
2+
3+
**Note:** The Dependency submission API is currently in public beta and subject to change.
4+
5+
{% endnote %}

lib/redirects/static/client-side-rest-api-redirects.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,8 @@
569569
"/rest/dependabot#delete-a-repository-secret": "/rest/dependabot/secrets#delete-a-repository-secret",
570570
"/rest/dependency-graph#get-a-diff-of-the-dependencies-between-commits": "/rest/dependency-graph/dependency-review#get-a-diff-of-the-dependencies-between-commits",
571571
"/rest/dependency-graph#dependency-review": "/rest/dependency-graph/dependency-review",
572+
"/rest/dependency-graph#create-a-snapshot-of-dependencies-for-a-repository": "/rest/dependency-graph/dependency-submission#create-a-snapshot-of-dependencies-for-a-repository",
573+
"/rest/dependency-graph#dependency-submission": "/rest/dependency-graph/dependency-submission",
572574
"/rest/deployments#deployments": "/rest/deployments/deployments",
573575
"/rest/deployments#statuses": "/rest/deployments/statuses",
574576
"/rest/repos#create-a-repository-dispatch-event": "/rest/repos/repos#create-a-repository-dispatch-event",

0 commit comments

Comments
 (0)