Skip to main content

关于 Dependabot 安全更新

Dependabot 可通过提出安全更新拉取请求为您修复有漏洞依赖项。

谁可以使用此功能?

Dependabot security updates 可用于以下存储库:

  • GitHub 上的所有存储库

About Dependabot security updates

Dependabot security updates make it easier for you to fix vulnerable dependencies in your repository. You typically add a dependabot.yml file to your repository to enable Dependabot security updates. You then configure options in this file to tell Dependabot how to maintain your repository.

For information on the supported repositories and ecosystems, see "Dependabot supported ecosystems and repositories."

If you enable Dependabot security updates, when a Dependabot alert is raised for a vulnerable dependency in the dependency graph of your repository, Dependabot automatically tries to fix it. For more information, see About Dependabot alerts and Configuring Dependabot security updates.

Note

There is no interaction between the settings specified in the dependabot.yml file and Dependabot security alerts, other than the fact that alerts will be closed when related pull requests generated by Dependabot for security updates are merged.

Dependabot signs its own commits by default, even if commit signing is not a requirement for the repository. For more information about verified commits, see "About commit signature verification."

Note

When Dependabot security updates are enabled for a repository, Dependabot will automatically try to open pull requests to resolve every open Dependabot alert that has an available patch. If you prefer to customize which alerts Dependabot opens pull requests for, you should leave Dependabot security updates disabled and create an auto-triage rule. For more information, see "Customizing auto-triage rules to prioritize Dependabot alerts."

GitHub may send Dependabot alerts to repositories affected by a vulnerability disclosed by a recently published GitHub security advisory. For more information, see Browsing security advisories in the GitHub Advisory Database.

Dependabot checks whether it's possible to upgrade the vulnerable dependency to a fixed version without disrupting the dependency graph for the repository. Then Dependabot raises a pull request to update the dependency to the minimum version that includes the patch and links the pull request to the Dependabot alert, or reports an error on the alert. For more information, see Troubleshooting Dependabot errors.

The Dependabot security updates feature is available for repositories where you have enabled the dependency graph and Dependabot alerts. You will see a Dependabot alert for every vulnerable dependency identified in your full dependency graph. However, security updates are triggered only for dependencies that are specified in a manifest or lock file. For more information, see About the dependency graph.

Note

For npm, Dependabot will raise a pull request to update an explicitly defined dependency to a secure version, even if it means updating the parent dependency or dependencies, or even removing a sub-dependency that is no longer needed by the parent. For other ecosystems, Dependabot is unable to update an indirect or transitive dependency if it would also require an update to the parent dependency. For more information, see Troubleshooting Dependabot errors.

You can enable a related feature, Dependabot version updates, so that Dependabot raises pull requests to update the manifest to the latest version of the dependency, whenever it detects an outdated dependency. For more information, see About Dependabot version updates.

When Dependabot raises pull requests, these pull requests could be for security or version updates:

  • Dependabot security updates are automated pull requests that help you update dependencies with known vulnerabilities.
  • Dependabot version updates are automated pull requests that keep your dependencies updated, even when they don’t have any vulnerabilities. To check the status of version updates, navigate to the Insights tab of your repository, then Dependency Graph, and Dependabot.

If you enable Dependabot security updates, parts of the configuration may also affect pull requests created for Dependabot version updates. This is because some configuration settings are common to both types of updates. For more information, see Customizing pull requests for Dependabot security updates.

Pull requests opened by Dependabot can trigger workflows that run actions. For more information, see "Automating Dependabot with GitHub Actions."

If you enable Dependabot on a new repository and have GitHub Actions enabled, Dependabot will run on GitHub Actions by default.

If you enable Dependabot on a new repository and have GitHub Actions disabled, Dependabot will run on the legacy application in GitHub to perform Dependabot updates. This doesn't provide as good performance, visibility, or control of Dependabot updates jobs as GitHub Actions does. If you want to use Dependabot with GitHub Actions, you must ensure that your repository enables GitHub Actions, then enable "Dependabot on Actions runners" from the repository's "Code security" settings page. For more information, see About Dependabot on GitHub Actions runners.

Dependabot security updates can fix vulnerable dependencies in GitHub Actions. When security updates are enabled, Dependabot will automatically raise a pull request to update vulnerable GitHub Actions used in your workflows to the minimum patched version.

About pull requests for security updates

Each pull request contains everything you need to quickly and safely review and merge a proposed fix into your project. This includes information about the vulnerability like release notes, changelog entries, and commit details. Details of which vulnerability a pull request resolves are hidden from anyone who does not have access to Dependabot alerts for the repository.

When you merge a pull request that contains a security update, the corresponding Dependabot alert is marked as resolved for your repository. For more information about Dependabot pull requests, see Managing pull requests for dependency updates.

Note

It's good practice to have automated tests and acceptance processes in place so that checks are carried out before the pull request is merged. This is particularly important if the suggested version to upgrade to contains additional functionality, or a change that breaks your project's code. For more information about continuous integration, see "About continuous integration with GitHub Actions."

About grouped security updates

To further reduce the number of pull requests you may be seeing, you can enable grouped security updates to group sets of dependencies together (per package ecosystem). Dependabot then raises a single pull request to update as many vulnerable dependencies as possible in the group to secure versions at the same time.

For security updates, Dependabot will only group dependencies from different directories per ecosystem under certain conditions and configurations. Dependabot will not group dependencies from different package ecosystems together, and it will not group security updates with version updates.

You can enable grouped pull requests for Dependabot security updates in one, or both, of the following ways.

  • To group as many available security updates together as possible, across directories and per ecosystem, enable grouping in the "Code security" settings for your repository, or in "Global settings" under "Code security" for your organization.
  • For more granular control of grouping, such as grouping by package name, development/production dependencies, SemVer level, or across multiple directories per ecosystem, add configuration options to the dependabot.yml configuration file in your repository.

Note

If you have configured group rules for Dependabot security updates in a dependabot.yml file, all available updates will be grouped according to the rules you've specified. Dependabot will only group across those directories not configured in your dependabot.yml if the setting for grouped security updates at the organization or repository level is also enabled.

For more information, see Configuring Dependabot security updates.

About compatibility scores

Dependabot security updates may include compatibility scores to let you know whether updating a dependency could cause breaking changes to your project. These are calculated from CI tests in other public repositories where the same security update has been generated. An update's compatibility score is the percentage of CI runs that passed when updating between specific versions of the dependency.

About automatic deactivation of Dependabot updates

When maintainers of a repository stop interacting with Dependabot pull requests, Dependabot temporarily pauses its updates and lets you know, see Dependabot update pull requests no longer generated.

About notifications for Dependabot security updates

You can filter your notifications on GitHub to show Dependabot security updates. For more information, see Managing notifications from your inbox.