Dependabot's core logic for creating update PRs.
Dependabot's core logic for creating update PRs.
</picture>
Welcome to the public home of Dependabot :dependabot:.
Dependabot-Core is the library at the heart of Dependabot security / version updates.
Use it to generate automated pull requests updating dependencies for projects written in Ruby, JavaScript, Python, PHP, Dart, Elixir, Elm, Go, Rust, Java, Julia, and .NET. It can also update git submodules, Docker files, Opentofu, Terraform files and Pre-Commit hooks. Features include:
Most people are familiar with the Dependabot service that runs on GitHub.com and GitHub Enterprise. Enabling that is as
simple as checking a dependabot.yml configuration file in to your repository's .github directory.
However, if you want to run a custom version of Dependabot or run it on another platform, you're not left out in the cold. This repo provides the logic necessary for hosting your own standalone Dependabot. It currently supports opening Pull Requests against repositories hosted on GitHub, Github Enterprise, Azure DevOps, GitLab, BitBucket, and AWS CodeCommit.
Dependabot-Core is a library, so you'll need an entrypoint script of some kind. Here are a few examples to help you get started.
Note: If you're looking to run Dependabot locally for development/debugging purposes, see the Development Guide.
The open-source Dependabot CLI is our recommended entrypoint for standalone use cases.
We use it in production here at GitHub, and advanced users can also leverage it to run a self-hosted version of Dependabot within their own projects / CI systems.
It creates dependency diffs but does not create PRs. So you will need to wire that up yourself. To aid with that, we created the example-cli-usage repo which demonstrates how to turn those diffs into actual PR's.
Alternatively, because Dependabot-Core is a Ruby library, you can write your own ruby-based wrapper that leverages the Dependabot-core code. The tricky bit is Dependabot assumes it's running in an isolated, throw-away environment so you'll need to handle all that yourself. For example protecting against security risks of arbitrary code execution exfiltrating credentials, ensuring the appropriate version of Go or Python or whatever language you need is available, and handling when Dependabot makes changes to its runtime environment.
In an environment such as GitHub where Dependabot runs in a container, if you want to change your build or installation process depending on whether it's running within the context of the Dependabot container, you can check the existence of the DEPENDABOT environment variable.
Want to give us feedback on Dependabot, or contribute to it? That's great - thank you so much!
Most bug reports should be accompanied by a link to a public repository that reproduces the problem. Bug reports that cannot be reproduced on a public repo using the CLI tool or dry-run script may be closed as "cannot reproduce".
Our issue tracker is quite active, and as a result there's a good chance someone already filed the same issue. If so, please upvote that issue, because we use reactions on issues as one signal to gauge the impact of a feature request or bug.
However, please do not leave comments that contribute nothing new to the discussion. For details, see https://go.dev/wiki/NoPlusOne. This is open source, if you see something you want fixed, we are happy to coach you through contributing a pull request to fix it.
The issue-tracker is meant solely for issues related to Dependabot's updating logic. Issues about security alerts or Dependency Graph should instead be filed as a Code Security discussion.
A good rule of thumb is that if you have questions about the diff in a PR, it belongs here.
If you believe you have found a security vulnerability in Dependabot, please review our security policy for details about disclosing them to the GitHub Bug Bounty program, so we can work to resolve the issue before it is disclosed publicly.
Want to contribute to Dependabot? That's great - thank you so much!
Contribution workflow:
Please refer to the CONTRIBUTING guidelines for more information.
If you're interested in contributing support for a new ecosystem, please refer to the contributing guidelines for more information.
The first step to debugging a problem or writing a new feature is getting a development environment going. We provide a custom Docker-based developer shell that bakes in all required dependencies. In most cases this is the best way to work with the project.
The developer shell uses volume mounts to incorporate your local changes to Dependabot's source code. This way you can edit locally using your favorite editor and the changes are immediately reflected within the docker container for performing dry-runs or executing tests. Note: See caveat about editing the native package manager helper scripts.
The script to launch the developer shell builds the docker images from scratch if it can't find them locally. This can take a while.
Skip the wait by pulling the pre-built image for the ecosystem you want to work on. The image name uses the YAML ecosystem name
to specify the ecosystem. For example, for Go Modules, the YAML name is gomod:
$ docker pull ghcr.io/dependabot/dependabot-updater-gomodNote: Pre-built images are currently only available for AMD64 / Intel architecture. They will run on ARM, but 2x-3x slower than if you manually build ARM-specific images.
Next, run the developer shell, specifying the desired ecosystem using the top-level directory name of the ecosystem in this project. For example, for Go Modules, the top-level directory is named go_modules:
$ bin/docker-dev-shell go_modules
=> running docker development shell
[dependabot-core-dev] ~ $ cd go_modules && rspec spec # to run tests for a particular packageNormally the Quickstart is all you need, but occasionally you'll need to rebuild the underlying images.
For example, while we don't yet publish ARM-specific images, if you are working on an ARM-based platform, we recommend manually building the images because the resulting containers run much faster.
The developer shell runs within a Dependabot Development docker image, which is built on top of an ecosystem image.
flowchart LR
A["docker-dev-shell script"] --> B("Dependabot Development docker image")
B --> C("Dependabot Updater Ecosystem docker image (ecosystem specific)")
C --> D("Dependabot Updater Core docker image")Changes to the docker files for any of these images requires building one or more of the images locally in order to be reflected in the development shell.
The simple but slow way is to delete any existing images and then run bin/docker-dev-shell which automatically builds
missing images.
The faster way is to pull all the pre-built images that are dependencies of the image you actually need to build. To (re)build a specific one:
The Updater core image:
$ docker pull ghcr.io/dependabot/dependabot-updater-core # OR
$ docker build -f Dockerfile.updater-core . --tag=dependabot-manual-build/updater-core # recommended on ARMEach language/ecosystem sits on top of the core image. You need to rebuild whichever one you’re working on so it picks up your new core bits. For instance, if you’re working on Go Modules:
The Updater ecosystem image:
$ docker pull ghcr.io/dependabot/dependabot-updater-gomod # OR
$ script/build go_modules # recommended on ARMOr explicitly:
$ docker build \
--platform linux/amd64 \
--file go_modules/Dockerfile \
--build-arg UPDATER_CORE_IMAGE=dependabot-manual-build/updater-core \
--tag dependabot-manual-build/updater-gomod \
.Spin-up the development container using the --rebuild flag:
$ bin/docker-dev-shell go_modules --rebuildIf successful, you should be inside the shell:
=> running docker development shell
[dependabot-core-dev] ~ $Once inside the shell, you can run tests, e.g.:
rspec common/spec/dependabot/file_fetchers/base_exclude_spec.rbSeveral Dependabot packages make use of 'native helpers', small executables in their host language.
Changes to these files are not automatically reflected inside the development container.
Once you have made any edits to the helper files, run the appropriate build script to update the installed version with your changes like so:
$ bin/docker-dNo open issues yet, or sync has not completed.