Find and fix vulnerable Maven/Gradle dependencies

Proprietary

This software composition analysis (SCA) tool detects and upgrades dependencies with publicly disclosed vulnerabilities. This recipe both generates a report of vulnerable dependencies and upgrades to newer versions with fixes. This recipe by default only upgrades to the latest patch version. If a minor or major upgrade is required to reach the fixed version, this can be controlled using the maximumUpgradeDelta option. Vulnerability information comes from the GitHub Security Advisory Database, which aggregates vulnerability data from several public databases, including the National Vulnerability Database maintained by the United States government. Upgrades dependencies versioned according to Semantic Versioning.

Customizing Vulnerability Data

This recipe can be customized by extending DependencyVulnerabilityCheckBase and overriding the vulnerability data sources:

  • baselineVulnerabilities(ExecutionContext ctx): Provides the default set of known vulnerabilities. The base implementation loads vulnerability data from the GitHub Security Advisory Database CSV file using ResourceUtils.parseResourceAsCsv(). Override this method to replace the entire vulnerability dataset with your own curated list.

  • supplementalVulnerabilities(ExecutionContext ctx): Allows adding custom vulnerability data beyond the baseline. The base implementation returns an empty list. Override this method to add organization-specific vulnerabilities, internal security advisories, or vulnerabilities from additional sources while retaining the baseline GitHub Advisory Database.

Both methods return List<Vulnerability> objects. Vulnerability data can be loaded from CSV files using ResourceUtils.parseResourceAsCsv(path, Vulnerability.class, consumer) or constructed programmatically. To customize, extend DependencyVulnerabilityCheckBase and override one or both methods depending on your needs. For example, override supplementalVulnerabilities() to add custom CVEs while keeping the standard vulnerability database, or override baselineVulnerabilities() to use an entirely different vulnerability data source. Last updated: 2026-11-13T1848.

org.openrewrite.java.dependencies.DependencyVulnerabilityCheck

Optional

Match dependencies with the specified scope. Default is runtime. An explanation of what each scope means can be found in the Apache Maven documentation.

overrideTransitiveBoolean

When enabled transitive dependencies with vulnerabilities will have their versions overridden. By default only direct dependencies have their version numbers upgraded.

The maximum difference to allow when suggesting a dependency version upgrade. Patch version upgrades are the default and safest option, as patch releases assert full backwards compatibility with no breaking changes. Minor version upgrades can introduce new features but do not typically include breaking changes. Major version upgrades will typically require code changes above and beyond this recipe.

Only fix vulnerabilities with a severity level equal to or higher than the specified minimum. Vulnerabilities are classified as low, moderate, high, or critical based on their potential impact. Default is low, which includes all severity levels.

Only fix vulnerabilities matching this regular expression pattern. This allows filtering to specific CVEs or CVE ranges. For example, CVE-2023-.* will only check for CVEs from 2023, CVE-(2022|2023)-.* will check for CVEs from 2022 or 2023, CVE-2021-44228|CVE-2022-23305 will check for those specific CVEs. If not specified, all CVEs will be checked (subject to other filters).

mod run . --recipe=org.openrewrite.java.dependencies.DependencyVulnerabilityCheck

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.