MSBA-360 · Lesson 8 of 12 · 18 min
Dependency review
▶ Video coming soon A video version of this lesson is on the way.
Dependabot alerts and updates deal with dependencies that are already in a repository. The eighth session was about the moment a dependency arrives. "Every vulnerable package in our estate came in through a pull request that somebody approved," Seraphine said. "Most reviewers never looked at the lock file changes, because they are thousands of lines long. Dependency review is how we make that part of the pull request readable."
What dependency review shows
Dependency review compares the dependency graph of a pull request's base branch with that of its head branch and shows what would change: which dependencies are added, removed or changed in version, and, for each, any known vulnerabilities and its licence. In the pull request's Files changed tab, a manifest or lock file can be shown as a rich diff that lists dependency changes in plain language instead of raw text. A reviewer sees "adds tar-stream 2.2.0, which has one high-severity vulnerability" rather than 4,000 changed lines.
Dependency review is free for public repositories. For private and internal repositories it is part of GitHub Code Security, which is why Skerry applied it through the Skerry code security configuration to confidential and restricted repositories, and why Tidewater's private guidebook repositories did not have it.
The dependency review action
Seeing changes is useful; enforcing rules is better. The dependency review action, published by GitHub as actions/dependency-review-action, runs in a workflow on pull requests, calls the dependency review API and fails the check when the pull request introduces something the configuration does not allow. Combined with a ruleset that requires the check to pass, it stops a vulnerable or disallowed dependency from being merged.
name: Dependency review
on: pull_request
permissions:
contents: read
pull-requests: write
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/dependency-review-action@v4
with:
fail-on-severity: high
fail-on-scopes: runtime
allow-licenses: MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC
comment-summary-in-pr: on-failureConfiguring the action
The most important options decide what fails the check. fail-on-severity sets the lowest vulnerability severity that fails it; high means that low and moderate vulnerabilities produce warnings but not failures. fail-on-scopes limits failures to certain dependency scopes, such as runtime dependencies, so that a vulnerable development tool does not block a merge. allow-ghsas lists specific advisory identifiers to ignore, for vulnerabilities the team has assessed and accepted.
Licence rules use allow-licenses, a list of licences that are acceptable, or an equivalent deny list. Licences are identified by their SPDX identifiers, such as MIT or Apache-2.0. Using an allow list is safer than a deny list, because an unfamiliar licence fails the check until someone decides it is acceptable, rather than passing because nobody thought to deny it. Packages can be exempted individually where a licence has been approved for one use.
Other options control reporting. comment-summary-in-pr posts a summary comment on the pull request, always, never or only when the check fails. warn-only makes the action report problems without failing, which is useful during a rollout. The action can also show OpenSSF Scorecard results for new dependencies, a measure of how well-maintained a project is, which helps reviewers notice a new dependency maintained by one person who has not released anything in four years. Configuration can live in a separate file shared across repositories, which is how Skerry kept one policy for every team.
| Option | What it controls | Skerry's setting |
|---|---|---|
| fail-on-severity | Lowest vulnerability severity that fails the check | high |
| fail-on-scopes | Which dependency scopes can fail the check | runtime |
| allow-licenses | Licences accepted without review | MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC |
| allow-ghsas | Advisories accepted after assessment | Two, each with a ticket reference |
| comment-summary-in-pr | When to post a summary comment | on-failure |
| show-openssf-scorecard | Show project health for new dependencies | Enabled, warnings only |
Making it required
A check that can be ignored does not protect anything. Skerry made the dependency review workflow a required workflow through an organization ruleset targeting repositories whose data-classification custom property was confidential or restricted, using the ruleset rule that requires a workflow to pass before merging. That meant teams could not forget to add it, and a repository owner could not remove it. The same check could have been made a required status check in each repository, but the ruleset approach applied it everywhere at once.
Worked problem
A failed review
Teodric opens a pull request that adds a library for reading barcode images to a store-systems service. The dependency review check fails: the library pulls in a transitive dependency with a high-severity vulnerability, and the library itself uses the AGPL-3.0 licence, which is not on the allowed list. What should he do?
Show solution
- Read the summary comment: it lists the vulnerable transitive package with its advisory and the AGPL-3.0 licence.
- For the vulnerability, check whether a newer version of the barcode library depends on a fixed version. It does, so he bumps the version.
- For the licence, ask the legal and open source review process. Skerry's policy does not allow AGPL-licensed code in store systems, so he chooses a different, Apache-licensed library.
- The new pull request passes. He does not ask for an exemption, because the policy exists for a reason and there was an acceptable alternative.
Licence compliance
Licence checking is the part of dependency review that most surprises developers. Open source licences grant permission to use code under conditions. Permissive licences, such as MIT, BSD and Apache-2.0, ask mainly for attribution. Copyleft licences, such as the GPL family, require that software combining the code be distributed under the same licence in some circumstances. A company that ships software to customers or devices needs to know which conditions it has accepted, and a lawyer is usually involved in setting the allowed list.
Dependency review can only check licences the dependency graph knows. Licence data comes from package metadata and from GitHub's own detection, and some packages declare no licence or an unusual one. A package with no detected licence is not automatically safe; Skerry's allowed-list approach treated it as needing review. The SBOM export in lesson 9 records the same licence data for each package, which helped the legal team prepare its open source notices.
How the pieces fit
Dependency review, Dependabot alerts and Dependabot updates cover different moments. Dependency review stops new problems entering through a pull request. Dependabot alerts find problems in what is already there, including ones that become known later, after a new advisory is published. Dependabot updates fix both. A repository that has only dependency review will still accumulate alerts over time, because today's safe version is tomorrow's vulnerable one.
| Moment | Feature | Typical outcome |
|---|---|---|
| A pull request adds or changes a dependency | Dependency review | Check passes or fails before merge |
| A new advisory affects an existing dependency | Dependabot alerts | Alert raised for repositories using it |
| A fix is available for an alert | Dependabot security updates | Pull request to the patched version |
| A dependency falls behind | Dependabot version updates | Scheduled pull request to a newer version |
Rolling it out without blocking everyone
Seraphine rolled dependency review out in two stages. For the first two weeks the shared configuration used warn-only, and she reviewed every warning. Most were genuine: 23 pull requests would have added a vulnerable or disallowed dependency. A few were noisy: a test framework with a moderate vulnerability in a scope that never ran in production, which led to the fail-on-scopes setting. Only then did she remove warn-only and make the workflow required.
Developers' reaction was better than expected. The summary comment explained the problem in the pull request, where the developer was already working, instead of in an alert days later. Teodric said that was the point: "It tells me while I still remember why I added the package."
Dependency review outside pull requests
The same comparison is available through the dependency review API, which returns the dependency changes between any two commits. Teams use it in other tools, for example to check a release branch against the previous release before deployment, or to report changes in a change-advisory meeting. Skerry's release engineering used it to produce a short list of dependency changes for every store-systems release, which the change board reviewed alongside the code changes.
Dependency review and Dependabot pull requests
Dependency review also runs on Dependabot's own pull requests, because they are ordinary pull requests that change manifests. That catches an interesting case: a version update that introduces a new transitive dependency with a vulnerability or a disallowed licence. Without the check, the update might be auto-merged; with it, the check fails and the update waits for a person. In its first month, Skerry's check stopped four Dependabot version updates this way, each of which would otherwise have been merged automatically under the auto-merge rules from lesson 7.
Handling exceptions
No policy fits every case, so the configuration needs a way to make exceptions that is visible and reviewable. The dependency review action allows exceptions in its configuration: specific advisories accepted with allow-ghsas, and specific packages exempted from licence checks. Because Skerry kept its configuration in a shared file in the governance repository, every exception was a pull request to that file, with a ticket reference and an expiry date in a comment. The governance team reviewed the exceptions monthly and removed any that had expired or whose reason no longer applied.
Freya insisted on one more rule: an exception for a vulnerability must name the specific advisory, never a severity level or a whole package. Accepting a package wholesale would silently accept every future vulnerability in it. Accepting one advisory accepts one known, assessed risk.
Common reasons the check fails unexpectedly
Developers new to the check met a few puzzling failures. One was a failure on a dependency they had not added: a lock file regenerated with a newer package manager had pulled in a different transitive version that happened to be vulnerable. The fix was to understand the lock file change, not to ignore it. Another was a licence failure on a package whose licence was declared in an unusual way, such as a licence expression combining two licences with OR. The action evaluates such expressions, but where metadata was missing or malformed, the package appeared to have an unknown licence. Those cases went to the legal team, who usually approved them quickly once they had looked at the package.
A third was a check that passed in a fork but failed in the main repository. Pull requests from forks run with restricted permissions, and the action needs read access to the repository's dependency graph through the API. Skerry's managed users could not create public forks, so this mattered only for the skerry-oss enterprise, where the platform team adjusted the workflow trigger for the two public libraries.
The cost of not reviewing dependencies
Seraphine's final slide showed what the first two weeks of warnings had found: 23 pull requests that would have introduced a high or critical vulnerability or a disallowed licence. If those had merged, each would have become a Dependabot alert a few hours later and taken, on Skerry's measured median, nine days to fix. Stopping them at review took minutes. That arithmetic convinced the commerce group's director to ask for the check on every repository, not just confidential ones.
Where dependency review fits in the review process
The check does not replace a human reviewer; it changes what the reviewer has to look at. Skerry's code review guide added one line: when a pull request changes dependencies, read the dependency review summary and ask why each new dependency is needed. That question alone caught several cases where a developer had added a large library for a single small function that the standard library already provided.
Common mistakes
MistakeApproving pull requests without reading dependency changes because the lock file diff is long.
InsteadUse the rich diff and the dependency review summary to see what changed.
MistakeAdding the dependency review action but not making it required.
InsteadRequire it through a ruleset or a required status check.
MistakeUsing a deny list of licences.
InsteadPrefer an allow list so unfamiliar licences need a decision.
MistakeFailing on every severity in every scope from day one.
InsteadStart with warn-only, tune severity and scope, then enforce.
Summary and key terms
- Dependency review compares the dependency graph before and after a pull request and shows added, removed and changed dependencies with vulnerabilities and licences.
- It is free on public repositories and part of Code Security on private and internal ones.
- The dependency review action fails a check on vulnerabilities by severity and scope and on licences outside an allowed list.
- Requiring the workflow through a ruleset applies it consistently across repositories.
- Dependency review stops new problems; Dependabot alerts and updates handle what is already in the code.
- Dependency review
- A comparison of dependency changes between a pull request's base and head.
- Rich diff
- A readable view of dependency changes in a manifest or lock file.
- Dependency review action
- A GitHub Action that fails a pull request check when disallowed dependencies are introduced.
- fail-on-severity
- The action option setting the lowest severity that fails the check.
- Allow list
- A list of licences accepted without review; anything else needs a decision.
- SPDX identifier
- A standard short name for a licence, such as MIT or Apache-2.0.
- Copyleft licence
- A licence that requires derived software to be shared under the same terms in some circumstances.
Practice problems
Work each problem on paper first, then reveal the answer to check.
What does fail-on-scopes: runtime do?
Show answer
Limits failures to runtime dependencies, so vulnerable development dependencies do not fail the check.
Why is an allow list of licences safer than a deny list?
Show answer
An unfamiliar licence fails until someone approves it, rather than passing because nobody denied it.
Which product includes dependency review for private repositories?
Show answer
GitHub Code Security.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.