Skip to content

Latest commit

 

History

History
103 lines (85 loc) · 5.07 KB

README.md

File metadata and controls

103 lines (85 loc) · 5.07 KB

Dependency Review

Scan a pull request's dependency changes for known-vulnerable packages and disallowed licenses, using GitHub Dependency Review. It diffs the base and head of a PR and surfaces any newly-introduced dependency that carries a known vulnerability or a license outside your policy.

This composite wraps actions/dependency-review-action (SHA-pinned) and exposes the most useful knobs as inputs. It is non-blocking by default: warn-only defaults to true, so findings are reported as warnings and the check always succeeds — safe to roll out org-wide as a Required Workflow without blocking existing PRs. Set warn-only to "false" to start enforcing, optionally tightening fail-on-severity.

The underlying action only produces a meaningful diff on pull_request / pull_request_target events (or when base-ref / head-ref are supplied explicitly). Gate the calling job accordingly. allow-licenses and deny-licenses are mutually exclusive — set at most one.

Inputs

Name Description Required Default
fail-on-severity Block the PR on vulnerabilities of this severity or higher (low, moderate, high, critical). Only applies when warn-only is false. ❌ critical
fail-on-scopes Comma-separated dependency scopes to block on (runtime, development, unknown). Defaults to runtime so dev-only vulnerabilities don't block. ❌ runtime
allow-licenses Comma-separated allow-list of SPDX licenses; a dependency under any other license fails the check. Mutually exclusive with deny-licenses. ❌ -
deny-licenses Comma-separated deny-list of SPDX licenses; a dependency under any of these fails the check. Mutually exclusive with allow-licenses. ❌ -
comment-summary-in-pr Post the review summary as a PR comment (always, on-failure, never). Anything but never requires repo-token to have Pull requests: write. ❌ never
base-ref Base git ref to diff from. Defaulted automatically on pull_request / pull_request_target; required for other events. ❌ -
head-ref Head git ref to diff to. Defaulted automatically on pull_request / pull_request_target; required for other events. ❌ -
retry-on-snapshot-warnings Retry when the dependency snapshot is not yet available, instead of failing immediately. ❌ false
warn-only Report every finding as a warning and always succeed, overriding fail-on-severity. Defaults to true so the check can roll out org-wide without blocking PRs; set to false to enforce. ❌ true
repo-token Token used to read dependency changes and (optionally) post the PR comment. ❌ ${{ github.token }}

Outputs

Name Description
comment-content The prepared dependency-review report comment (markdown).
dependency-changes All dependency changes in the PR (JSON).
vulnerable-changes Vulnerable dependency changes (JSON).
invalid-license-changes Dependency changes with disallowed licenses (JSON).
denied-changes Denied dependency changes (JSON).

Permissions

The composite reads the dependency diff with Contents: read. Posting a PR comment (comment-summary-in-pr ≠ never) additionally requires Pull requests: write on the token supplied through repo-token. For the default github.token, grant the calling job contents: read and pull-requests: write as shown below; a composite cannot declare these permissions. An independent repository-scoped token with those permissions can also be supplied explicitly.

The reusable workflow keeps its job token read-only in both modes. Enable its comments with the independent repo-token secret documented there; raising that caller's job permissions alone is insufficient.

Usage

Non-blocking (default) — warn on findings

jobs:
  dependency-review:
    if: github.event_name == 'pull_request'
    runs-on: ubuntu-latest
    permissions:
      contents: read
    steps:
      - name: 📑 Checkout
        uses: actions/checkout@<full-commit-sha> # vX.Y.Z
        with:
          persist-credentials: false

      - name: 🛡️ Review dependencies
        uses: devantler-tech/.github/actions/dependency-review@<full-commit-sha> # vX.Y.Z

Enforce — fail on high-severity vulnerabilities and post a comment

jobs:
  dependency-review:
    if: github.event_name == 'pull_request'
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write # required for comment-summary-in-pr
    steps:
      - name: 📑 Checkout
        uses: actions/checkout@<full-commit-sha> # vX.Y.Z
        with:
          persist-credentials: false

      - name: 🛡️ Review dependencies
        uses: devantler-tech/.github/actions/dependency-review@<full-commit-sha> # vX.Y.Z
        with:
          warn-only: "false"
          fail-on-severity: high
          comment-summary-in-pr: on-failure