GitHub Dependabot

An essential tool for efficient dependency version management

Serendra Birari
Globant
7 min readJan 29, 2024

--

Credit: lightrun.com

Managing software dependencies is always an important aspect of the software development process. Nowadays, software developers and organizations significantly use various tools to develop their applications quickly, to reduce development efforts, and to use the best of the features available in the market. Dependency management takes time and effort to track and update. This becomes critical when the project uses open-source software, which is more susceptible to vulnerabilities.

GitHub is a well-known platform for software version control and team collaboration. Furthermore, it offers various tools to make the software development process easier and streamlined. GitHub Dependabot is a tool from GitHub that helps to manage the complex task of dependency management in an easier and more automated way.

What Is GitHub Dependabot?

GitHub Dependabot manages your project’s dependencies according to the dependency file available in the repository in an automated way. Dependabot checks dependencies in your project and creates pull requests whenever a new version is available. It saves a significant amount of time and makes the process autonomous. Dependabot helps to elevate the project’s robustness and reduce system vulnerabilities by keeping dependencies up-to-date.

Features of GitHub Dependabot

GitHub Dependabot offers several features that make it a reliable tool for automatic dependency management:

  • Integration with GitHub: Dependabot is directly integrated into GitHub, so it works as a native feature. It allows seamless management of dependencies by analyzing dependencies mentioned in files in the GitHub repository.
  • Automatic pull requests: Dependabot creates automatic pull requests whenever it finds new version updates. It creates pull requests with all the crucial details, such as release notes, change logs, and commits.
  • Security updates: Dependabot creates pull requests to update dependencies with known vulnerability fixes.
  • Version updates: Dependabot creates pull requests to keep dependencies up-to-date, even when they don’t have any vulnerabilities.
  • Security vulnerability alerts: Dependabot sends alert notifications to users if it finds any known security vulnerability associated with the dependencies.
  • Compatibility scores: Dependabot provides compatibility scores based on successful test runs of other projects using the same updates. These are calculated from CI test runs in other public repositories where the same update has been made.
  • Configurability: Dependabot is highly configurable, allowing users to customize update schedules, target versions, assignees for PRs, and package managers, ignore specific dependencies, and much more.

How does GitHub Dependabot work?

GitHub Dependabot works in a streamlined way to manage dependencies, which is described in four steps:

  1. Dependency checking: Dependabot continuously checks your project’s dependency files such as package.json, and requirements.txt based on your configuration settings.
  2. Update identification: Dependabot not only identifies a new version of a library or package but also finds a dependency with a known security vulnerability.
  3. Pull request creation: After identifying an update or vulnerability, Dependabot prepares and generates a pull request for the specific update or fix according to the nature of the change.
  4. Dependabot alerts: If Dependabot finds a dependency with a known security vulnerability, it creates a security alert.

By going through these steps, GitHub Dependabot makes the process of updating dependencies simpler and also ensures that your software development process remains seamless, efficient, and safe.

Security advisories in Dependabot

Security advisories in Dependabot refer to the notifications generated by Dependabot when it detects a known security vulnerability in a dependency used in your project.

Here’s how it works:

  1. GitHub Security Advisory API maintains a database containing known vulnerabilities reported from various sources, including the National Vulnerability Database, partner organizations, and open-source projects.
  2. Dependabot checks the dependencies in your project against this database.
  3. Dependabot generates a security advisory if it finds a security vulnerability in one or more libraries or packages used in your project.
  4. This security advisory provides critical information about the vulnerability, including its severity, potential impacts, and suggestions on fixes.
  5. Dependabot creates a pull request to update the vulnerable dependency to a safe version, if any such update is available.

Security advisories inform you about potential risks, suggest fixes, and make it easier for developers to keep their vulnerability objects secure.

Setting Up GitHub Dependabot

Setting up the Dependabot in GitHub is simple. Follow the following steps to enable and configure Dependabot:

1. Log in to your GitHub account and navigate to your GitHub repository.

2. Select the Settings tab and navigate to the “Code security and analysis”. You’ll find the option to enable Dependabot alerts and automatic security and version updates. Once enabled, it will start scanning your dependencies.

GitHub Dependabot — Settings
Code security and analysis

3. Enable Dependabot alerts, which automatically enable the Dependency graph. The Dependency Graph is a visual representation of libraries, packages, available updates, and detected vulnerabilities:

Enable Dependabot alerts

4. Enable Dependabot security updates:

Enable Dependabot security updates

5. Now enable Dependabot version updates. Configure the .github/dependabot.yml file in your repository. Once you click the Enable button, the dependabot.yml file will be opened in the GitHub editor. Now configure the dependabot.yml file as per your source code and commit the changes. In our case, it’s a Terraform package ecosystem:

Enable Dependabot version updates

6. Dependabot will identify the packages used in the code and check for vulnerabilities and version updates. In our case, there are two Terraform providers for which the versions are specified. Dependabot has detected these provider versions and created two pull requests.

Below is the Terraform provider file:

Terraform package file

First PR:

First PR created by Dependabot

Second PR:

Second PR created by Dependabot

7. Click on the “Security” tab to see Dependabot alerts and security advisories:

Security overview

Configuring Dependabot

The Dependabot configuration file is dependabot.yml and uses YAML syntax. This file resides in the .github directory of your repository in the default branch. A check for version updates is triggered when the dependabot.yml file is added or updated.

The dependabot.yml file has two mandatory top-level keys: version, and updates. Dependabot uses this file to decide how to update the versions of dependencies in your project. Below is the sample dependabot.yml file:

Sample — dependabot.yml

Below is the description of the different options used in the previous example:

  • Package-ecosystem: Specifies the package manager or build system that your project uses.
  • Directory: Specifies the location of the package configuration files in your repository.
  • Schedule-interval: Determines how frequently GitHub Dependabot will check for updates to the dependencies in your project.
  • Open-pull-requests-limit: Limits the number of open pull requests GitHub Dependabot will create. If this field is not specified, the default value is 5.
  • Reviewers: Specifies the GitHub users or teams that will be requested for review whenever GitHub Dependabot creates a pull request for a dependency update.
  • Ignore: Specify the dependencies that you do not want GitHub Dependabot to update.

For more configuration options and details, you can refer to the GitHub official documentation.

To check the supported package ecosystems, you can also refer to the GitHub official documentation.

Limitations of GitHub Dependabot

Like any other tool, the Dependabot also has its limitations. Below are some of them:

  • Compatibility issues: Sometimes, automatic updates of dependencies can create compatibility issues in your code. The compatibility score gives some idea about the update’s stability, but you can’t completely rely on it.
  • Assessment of PR required: You can’t merge PR created by Dependabot directly. You need to review the PR to check the update details, compatibility criteria, and its impact on existing functionality.
  • Limited language and package manager support: Currently Dependabot supports limited languages but in the future, it may widen its support for more languages and package managers.

Conclusion

GitHub Dependabot shines out as a simple, reliable, and automated dependency management tool that saves time, keeps packages up-to-date, and minimizes vulnerabilities in your project. GitHub Dependabot is helping us, and we recommend you consider integrating it in your software development process.

Reference

--

--