Lesson 6 of 6 Security and Compliance Scanning

Automating Vulnerability Analysis with Dependabot

This lesson explains Dependabot alerts, security updates and version updates.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe the dependency graph and advisory database.
  • Distinguish the three Dependabot features.
  • Write a dependabot.yml file.
  • Manage alert and pull request volume.

The foundation: dependency graph and advisories

Dependabot depends on two things. The dependency graph lists a repository's dependencies, parsed from manifests and lock files such as package-lock.json. The GitHub Advisory Database lists known vulnerabilities, with affected version ranges. Lock files give a more accurate graph, since they include transitive dependencies. A dependency submission API allows a build to report dependencies that static parsing cannot find.

True or false

What Dependabot relies on

Exam skills 4.3.6

Check how the dependency graph and advisories feed Dependabot.

Log in to try this activity Interactive activities are free with an account.

Three separate features

The name Dependabot covers three features, and it is important to distinguish them.

Dependabot alerts

Dependabot alerts tell you that a repository uses a vulnerable dependency. An alert is raised when a new advisory matches, or when a change adds a vulnerable package. It appears on the Security tab, with severity, affected versions and a patched version. Alerts are available on all GitHub plans, and they need the dependency graph.

Dependabot security updates

Dependabot security updates act on an alert by opening a pull request that raises the package to the minimum patched version. Tests then run in the normal way, so that a team can merge with confidence.

Dependabot version updates

Dependabot version updates keep dependencies current even without a vulnerability, on a schedule, so that an urgent upgrade is less likely to be a big jump. They are set in a configuration file.

# .github/dependabot.yml
version: 2
updates:
  - package-ecosystem: npm
    directory: /
    schedule:
      interval: weekly
    open-pull-requests-limit: 5
    groups:
      development:
        dependency-type: development
        update-types: [minor, patch]

  - package-ecosystem: github-actions
    directory: /
    schedule:
      interval: weekly

  - package-ecosystem: docker
    directory: /
    schedule:
      interval: weekly

The github-actions ecosystem keeps actions current, including SHA-pinned ones. groups combines updates into a single pull request, which reduces noise.

Alerts
PurposeNotify about vulnerabilities
TriggerNew advisory or new dependency
OutputAn alert
ConfigurationRepository setting
Choose when You need visibility of risk.
Security updates
PurposeFix a vulnerable version
TriggerA Dependabot alert
OutputA pull request
ConfigurationRepository setting
Choose when You want proposed fixes for vulnerabilities.
Version updates
PurposeStay current
TriggerSchedule
OutputA pull request
Configuration.github/dependabot.yml
Choose when You want regular, small upgrades.

The following diagram shows the configuration and the two kinds of update.

Dependabot doing both jobs. Security updates open pull requests that fix vulnerable npm packages automatically; version updates in .github/dependabot.yml run weekly, with a group that combines minor and patch updates into a single pull request. Alerts alone would notify without fixing.
The group name is an example.
Sort into groups

Alerts, security updates or version updates?

Exam skills 4.3.6

Decide which Dependabot feature each statement describes.

Log in to try this activity Interactive activities are free with an account.

Managing the volume

Without management, Dependabot can produce a stream of pull requests and alerts that nobody reads. Several features help.

  • Dependabot auto-triage rules dismiss or snooze alerts that match conditions, such as low severity development dependencies.
  • EPSS scores estimate how likely a vulnerability is to be exploited, which improves prioritization beyond severity.
  • Grouped updates reduce the number of pull requests.
  • Auto-merge with good test coverage can merge minor and patch updates automatically.
  • Dependency review stops new vulnerable packages from arriving through a pull request.

Enabling Dependabot across an organization is done with security configurations. For Azure Repos, Dependabot is not the mechanism: dependency scanning from GitHub Advanced Security for Azure DevOps fills that role.

Match the pairs

Keeping Dependabot manageable

Exam skills 4.3.6

Match each feature with how it reduces Dependabot noise.

Log in to try this activity Interactive activities are free with an account.

Handling an alert

  1. Assess

    Read the advisory, and decide whether the vulnerable function is reachable.

  2. Fix

    Merge a Dependabot pull request, or update the dependency by hand.

  3. Handle a blocked fix

    If no patch exists, consider a workaround, or replacing the package.

  4. Dismiss with a reason

    Record that a finding is tolerable, or inaccurate, if that is the case.

Scenario questions

Handling a Dependabot alert

Exam skills 4.3.6

Choose the right response to each Dependabot alert.

Log in to try this activity Interactive activities are free with an account.
Worked example

Automating fixes

A repository receives alerts for vulnerable npm packages, but developers do not get time to create upgrades. The team wants proposed fixes automatically, and it also wants a weekly routine of minor updates in a single pull request. What should you configure?

Enable Dependabot security updates for proposed fixes, and add a .github/dependabot.yml with a weekly schedule and a group for minor and patch updates, for version updates. Alerts alone would notify without fixing. Code scanning finds flaws in your own code, and would not update dependencies.

Check yourself

Which Dependabot feature needs a configuration file?

Show answer

Version updates, through .github/dependabot.yml. Alerts and security updates are repository settings.

Exam Tips

Remember for the exam

  • Dependabot alerts need the dependency graph, and are on all plans.
  • Security updates open pull requests that fix alerts.
  • Version updates use a schedule in .github/dependabot.yml.
  • Use groups to reduce pull request volume.
  • Azure Repos uses GitHub Advanced Security dependency scanning, not Dependabot.