This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 38d8d993b4f3 CAMEL-27345: camel-report-maven-plugin -
camel-report:audit checks the project dependencies for CVEs in CI/CD and can
fail the build (#30558)
38d8d993b4f3 is described below
commit 38d8d993b4f3ca4399cb94653e255b8e995bd091
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Nov 21 22:40:46 2026 +0100
CAMEL-27345: camel-report-maven-plugin - camel-report:audit checks the
project dependencies for CVEs in CI/CD and can fail the build (#30558)
A new camel-report:audit goal checks the dependencies Maven resolved for
the build against OSV.dev (or the offline OSV database) and the Apache Camel
security advisories of the catalog, the same checks as camel dependency audit.
It reports the dependency trail, supports failOn by severity, suppressions in
camel-audit-suppressions.txt, the proxy of the Maven settings, and writes JSON
and SARIF reports for GitHub code scanning.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Claus Ibsen <[email protected]>
---
catalog/camel-report-maven-plugin/pom.xml | 6 +
.../src/main/docs/camel-report-maven-plugin.adoc | 124 +++++++
.../java/org/apache/camel/maven/AuditMojo.java | 393 +++++++++++++++++++++
.../java/org/apache/camel/maven/AuditReport.java | 254 +++++++++++++
.../org/apache/camel/maven/AuditReportTest.java | 179 ++++++++++
.../modules/ROOT/pages/camel-jbang-projects.adoc | 4 +-
.../ROOT/pages/camel-report-maven-plugin.adoc | 124 +++++++
7 files changed, 1083 insertions(+), 1 deletion(-)
diff --git a/catalog/camel-report-maven-plugin/pom.xml
b/catalog/camel-report-maven-plugin/pom.xml
index 587fe6b78316..ec910feff3ca 100644
--- a/catalog/camel-report-maven-plugin/pom.xml
+++ b/catalog/camel-report-maven-plugin/pom.xml
@@ -72,6 +72,12 @@
<artifactId>camel-catalog-maven</artifactId>
<version>${project.version}</version>
</dependency>
+ <!-- the CVE audit (camel-report:audit) -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-catalog-cve</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
diff --git
a/catalog/camel-report-maven-plugin/src/main/docs/camel-report-maven-plugin.adoc
b/catalog/camel-report-maven-plugin/src/main/docs/camel-report-maven-plugin.adoc
index 59bdf4bfc4c2..56b9e00527bb 100644
---
a/catalog/camel-report-maven-plugin/src/main/docs/camel-report-maven-plugin.adoc
+++
b/catalog/camel-report-maven-plugin/src/main/docs/camel-report-maven-plugin.adoc
@@ -4,6 +4,7 @@ The Camel Report Maven Plugin supports the following goals
- camel-report:validate - To validate your source code for invalid Camel
endpoint uris
- camel-report:route-coverage - To report the coverage of your Camel routes
after unit testing
+ - camel-report:audit - To check the dependencies for known vulnerabilities
(CVEs), and fail the build on them
== camel-report:validate
@@ -218,6 +219,129 @@ In particular, in order to use the validate plugin with
transitive dependencies,
</plugin>
----
+== camel-report:audit
+
+Checks the dependencies of the project for known vulnerabilities (CVEs), for a
CI/CD pipeline: every JAR against
+https://osv.dev[OSV.dev], and the Camel JARs against the Apache Camel security
advisories that ship with the Camel
+catalog. These are the same checks as `camel dependency audit` of the
xref:camel-jbang.adoc[Camel CLI]. The
+dependencies are those Maven resolved for the build, with the versions the
BOMs (`dependencyManagement`) chose.
+
+[source,bash]
+----
+mvn camel-report:audit
+----
+
+[source,text]
+----
+[WARNING] SEVERITY SCORE CVE ARTIFACT
FIX VIA SUMMARY
+[WARNING] CRITICAL 9.8 CVE-2022-42889 org.apache.commons:commons-text:1.9
1.10.0 Arbitrary code execution in Apache Commons Text
+[WARNING] MEDIUM 6.5 CVE-2025-48924
org.apache.commons:commons-lang3:3.11 3.18.0 commons-text Apache Commons
Lang is vulnerable to Uncontrolled Recursion…
+[WARNING] 2 vulnerabilities in 2 of 3 dependencies of com.acme:orders, 1
suppressed
+----
+
+*FIX* is the version that fixes the JAR, or the Camel release to upgrade to
for a Camel advisory, and *VIA* the
+dependency chain that brings it in.
+
+By default the goal only reports. To fail the build, set `failOn` to a
severity:
+
+[source,bash]
+----
+mvn camel-report:audit -Dcamel.audit.failOn=high
+----
+
+Or run it in every build, in the `verify` phase:
+
+[source,xml]
+----
+<plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-report-maven-plugin</artifactId>
+ <version>${camel.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>audit</goal>
+ </goals>
+ <configuration>
+ <failOn>high</failOn>
+ <osvDatabase>true</osvDatabase>
+ </configuration>
+ </execution>
+ </executions>
+</plugin>
+----
+
+The Apache Camel security advisories are those of the catalog of the plugin,
so use the latest release of the plugin,
+whatever the Camel version of the project, to know the latest advisories.
+
+=== The offline OSV database
+
+By default the goal sends the coordinates (`groupId:artifactId:version`) of
the dependencies to the OSV.dev API. With
+`osvDatabase` it does not: it downloads the export of all the Maven
vulnerabilities of OSV.dev (one ZIP file of about
+10 MB, updated every day by OSV.dev) and matches the versions locally, so no
coordinates leave the machine. The ZIP is
+kept in `~/.camel/osv` (shared with the Camel CLI) and downloaded again once a
day.
+
+A build machine without internet access downloads it from the repository
manager of the company, such as a raw
+repository of Nexus or a generic remote repository of Artifactory that proxies
+`https://osv-vulnerabilities.storage.googleapis.com/Maven/all.zip`, or reads a
file:
+
+[source,bash]
+----
+mvn camel-report:audit
-Dcamel.audit.osvDatabaseUrl=https://nexus.corp.com/repository/osv/Maven/all.zip
+----
+
+The goal reaches OSV.dev, or the URL of the database, through the proxy of the
Maven settings (`settings.xml`, with its
+username, password and `nonProxyHosts`), else the `HTTPS_PROXY` and `NO_PROXY`
environment variables.
+
+=== Suppressions
+
+A vulnerability that does not apply to the project, such as one in a feature
the project does not use, goes in
+`camel-audit-suppressions.txt` beside the `pom.xml`, one per line with the
reason. It is then reported as suppressed,
+and does not fail the build:
+
+[source,text]
+----
+# the id of the CVE, or of its GHSA alias, and why
+CVE-2022-1471 the YAML comes from our own configuration only
+----
+
+=== Reports
+
+The goal writes `target/camel-audit.json` (in the shape of `camel dependency
audit --json`, with the suppressed
+findings and their reasons) and `target/camel-audit.sarif`. The SARIF report
can be uploaded to GitHub code scanning,
+which then shows the vulnerabilities in the Security tab of the repository:
+
+[source,yaml]
+----
+- run: mvn -B verify camel-report:audit
+- uses: github/codeql-action/upload-sarif@v4
+ if: always()
+ with:
+ sarif_file: target/camel-audit.sarif
+----
+
+=== Options
+
+[width="100%",cols="10%,10%,80%",options="header",]
+|===
+| Parameter | Default Value | Description
+| skip | false | Skips the audit.
+| scopes | compile,runtime | The scopes of the dependencies to check,
separated by commas.
+| severity | low | The lowest severity to list: critical, high, medium or low.
+| failOn | none | Fails the build when a vulnerability at or above this
severity is found (also one below `severity`): critical, high, medium, low, or
none to only report them.
+| failOnError | false | Fails the build when the dependencies could not be
checked with OSV.dev or the OSV database (not reachable, no database).
Otherwise only the Apache Camel security advisories are checked then, with a
warning.
+| offline | false | Checks the Apache Camel security advisories of the catalog
only, without OSV.dev.
+| osvDatabase | false | Checks with the offline OSV database instead of the
OSV.dev API.
+| osvDatabaseUrl | | Where the offline OSV database is downloaded from, or a
ZIP file on disk (default
`\https://osv-vulnerabilities.storage.googleapis.com/Maven/all.zip`). Implies
`osvDatabase`.
+| osvDatabaseCache | ~/.camel/osv | Where a downloaded OSV database is kept.
+| excludeGroupIds | | The groupIds that are not checked and not sent to
OSV.dev, such as those of the internal libraries of a company, separated by
commas; `com.acme` also leaves out `com.acme.billing`. The modules of the build
are never checked.
+| suppressions | camel-audit-suppressions.txt | The file of the
vulnerabilities that do not apply, beside the `pom.xml`.
+| jsonReport | target/camel-audit.json | The JSON report; empty for none.
+| sarifReport | target/camel-audit.sarif | The SARIF report; empty for none.
+|===
+
+Each option can be set as a property with the `camel.audit.` prefix, such as
`-Dcamel.audit.failOn=high`.
+
== camel-report:route-coverage
For generating a report of the coverage of your Camel routes from unit testing.
diff --git
a/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/AuditMojo.java
b/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/AuditMojo.java
new file mode 100644
index 000000000000..8725b5cc980d
--- /dev/null
+++
b/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/AuditMojo.java
@@ -0,0 +1,393 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+
+import org.apache.camel.catalog.CamelCatalog;
+import org.apache.camel.catalog.DefaultCamelCatalog;
+import org.apache.camel.catalog.cve.CveAudit;
+import org.apache.camel.catalog.cve.CveFinding;
+import org.apache.camel.catalog.cve.CveScan;
+import org.apache.camel.catalog.cve.Dependency;
+import org.apache.camel.catalog.cve.HttpProxy;
+import org.apache.camel.catalog.cve.OsvClient;
+import org.apache.camel.catalog.cve.OsvDatabase;
+import org.apache.camel.catalog.cve.VulnerabilitySource;
+import org.apache.camel.tooling.maven.MavenDownloaderImpl;
+import org.apache.camel.tooling.maven.MavenProxy;
+import org.apache.camel.util.json.Jsoner;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.project.MavenProject;
+import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.RepositorySystemSession;
+
+/**
+ * Checks the dependencies of the project for known vulnerabilities (CVEs)
with OSV.dev and the Apache Camel security
+ * advisories, and reports them, or fails the build (CAMEL-27345). The same
checks as {@code camel dependency audit} of
+ * the Camel CLI, for a CI/CD pipeline.
+ */
+@Mojo(name = "audit", threadSafe = true, defaultPhase = LifecyclePhase.VERIFY,
+ requiresDependencyResolution = ResolutionScope.TEST)
+public class AuditMojo extends AbstractMojo {
+
+ @Parameter(defaultValue = "${project}", readonly = true, required = true)
+ private MavenProject project;
+
+ @Parameter(defaultValue = "${session}", readonly = true, required = true)
+ private MavenSession session;
+
+ @Parameter(defaultValue = "${repositorySystemSession}", readonly = true)
+ private RepositorySystemSession repositorySystemSession;
+
+ private final RepositorySystem repositorySystem;
+
+ /**
+ * Skips the audit.
+ */
+ @Parameter(property = "camel.audit.skip", defaultValue = "false")
+ private boolean skip;
+
+ /**
+ * The scopes of the dependencies to check, separated by commas.
+ */
+ @Parameter(property = "camel.audit.scopes", defaultValue =
"compile,runtime")
+ private String scopes;
+
+ /**
+ * The lowest severity to list: critical, high, medium or low.
+ */
+ @Parameter(property = "camel.audit.severity", defaultValue = "low")
+ private String severity;
+
+ /**
+ * Fails the build when a vulnerability at or above this severity is found
(also when it is below the severity
+ * listed): critical, high, medium, low, or none to only report them.
+ */
+ @Parameter(property = "camel.audit.failOn", defaultValue = "none")
+ private String failOn;
+
+ /**
+ * Fails the build when the dependencies could not be checked with OSV.dev
or the OSV database (not reachable, no
+ * database). Otherwise only the Apache Camel security advisories are
checked then, with a warning.
+ */
+ @Parameter(property = "camel.audit.failOnError", defaultValue = "false")
+ private boolean failOnError;
+
+ /**
+ * Checks the Apache Camel security advisories of the catalog only,
without OSV.dev.
+ */
+ @Parameter(property = "camel.audit.offline", defaultValue = "false")
+ private boolean offline;
+
+ /**
+ * Checks with the offline OSV database instead of the OSV.dev API: the
export of all the Maven vulnerabilities of
+ * OSV.dev, downloaded once a day and matched locally, so no coordinates
of the project leave the machine.
+ */
+ @Parameter(property = "camel.audit.osvDatabase", defaultValue = "false")
+ private boolean osvDatabase;
+
+ /**
+ * Where the offline OSV database is downloaded from, such as a mirror on
the repository manager of the company, or
+ * a ZIP file on disk (default:
https://osv-vulnerabilities.storage.googleapis.com/Maven/all.zip). Implies
+ * osvDatabase.
+ */
+ @Parameter(property = "camel.audit.osvDatabaseUrl")
+ private String osvDatabaseUrl;
+
+ /**
+ * Where a downloaded OSV database is kept, shared with the Camel CLI.
+ */
+ @Parameter(property = "camel.audit.osvDatabaseCache", defaultValue =
"${user.home}/.camel/osv")
+ private File osvDatabaseCache;
+
+ /**
+ * The groupIds that are not checked, and not sent to OSV.dev, such as
those of the internal libraries of a company,
+ * separated by commas; {@code com.acme} also leaves out {@code
com.acme.billing}. The modules of the build are
+ * never checked.
+ */
+ @Parameter(property = "camel.audit.excludeGroupIds")
+ private String excludeGroupIds;
+
+ /**
+ * A file of the vulnerabilities that do not apply, one per line with the
reason, such as
+ * {@code CVE-2022-1471 the YAML comes from our own configuration only}.
They are reported as suppressed, and do not
+ * fail the build.
+ */
+ @Parameter(property = "camel.audit.suppressions", defaultValue =
"${project.basedir}/camel-audit-suppressions.txt")
+ private File suppressions;
+
+ /**
+ * The JSON report, in the shape of {@code camel dependency audit --json};
empty for none.
+ */
+ @Parameter(property = "camel.audit.jsonReport", defaultValue =
"${project.build.directory}/camel-audit.json")
+ private File jsonReport;
+
+ /**
+ * The SARIF report, for GitHub code scanning and other tools; empty for
none.
+ */
+ @Parameter(property = "camel.audit.sarifReport", defaultValue =
"${project.build.directory}/camel-audit.sarif")
+ private File sarifReport;
+
+ @Inject
+ public AuditMojo(RepositorySystem repositorySystem) {
+ this.repositorySystem = repositorySystem;
+ }
+
+ /** The dependencies to check, and the chain that brings each transitive
one in, by {@code groupId:artifactId}. */
+ record Collected(List<Dependency> deps, Map<String, String> via) {
+ }
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ if (skip) {
+ getLog().info("Skipping the audit as per configuration");
+ return;
+ }
+ String listLevel = level("severity", severity, false);
+ String failLevel = level("failOn", failOn, true);
+
+ Set<String> reactor = new LinkedHashSet<>();
+ for (MavenProject p : session.getProjects()) {
+ reactor.add(p.getGroupId() + ":" + p.getArtifactId());
+ }
+ Collected collected = collect(project.getArtifacts(), split(scopes),
reactor, split(excludeGroupIds));
+ String name = project.getGroupId() + ":" + project.getArtifactId();
+ if (collected.deps().isEmpty()) {
+ getLog().info("No dependencies of " + name + " to audit");
+ return;
+ }
+ Set<String> declared = new LinkedHashSet<>();
+ project.getDependencies().forEach(d -> declared.add(d.getGroupId() +
":" + d.getArtifactId()));
+
+ CamelCatalog catalog = new DefaultCamelCatalog();
+ OsvDatabase database = null;
+ VulnerabilitySource source = null;
+ if (!offline) {
+ if (osvDatabase || (osvDatabaseUrl != null &&
!osvDatabaseUrl.isBlank())) {
+ String url = osvDatabaseUrl != null &&
!osvDatabaseUrl.isBlank() ? osvDatabaseUrl : OsvDatabase.DEFAULT_URL;
+ database = OsvDatabase.open(url, osvDatabaseCache.toPath(),
OsvDatabase.DEFAULT_MAX_AGE, proxy(url));
+ source = database;
+ } else {
+ source = new OsvClient(proxy(OsvClient.API_URL));
+ }
+ }
+ CveAudit.Result result = CveAudit.audit(collected.deps(), Map.of(),
declared, collected.via(), null, catalog,
+ source);
+
+ Map<String, String> suppressed = readSuppressions();
+ Map<CveFinding, String> hidden = new LinkedHashMap<>();
+ List<CveFinding> remaining = new ArrayList<>();
+ for (CveFinding f : result.findings()) {
+ String reason = AuditReport.suppression(f, suppressed);
+ if (reason != null) {
+ hidden.put(f, reason);
+ } else {
+ remaining.add(f);
+ }
+ }
+ List<CveFinding> listed = remaining.stream().filter(f ->
AuditReport.atOrAbove(f, listLevel)).toList();
+ boolean failed = remaining.stream().anyMatch(f ->
AuditReport.atOrAbove(f, failLevel));
+
+ if (result.osvError() != null) {
+ getLog().warn(result.osvError() + ": only the Apache Camel
security advisories were checked");
+ }
+ if (database != null && database.warning() != null) {
+ getLog().warn(database.warning());
+ }
+ String note = database != null && database.updated() != null
+ ? " (offline OSV database, updated " +
database.updated().toString().substring(0, 10) + ")" : "";
+ String more = hidden.isEmpty() ? "" : ", " + hidden.size() + "
suppressed";
+ if (listed.isEmpty()) {
+ getLog().info(
+ "No known vulnerabilities" + ("low".equals(listLevel) ? ""
: " of " + listLevel + " severity or worse")
+ + " in " + collected.deps().size() + " dependencies
of " + name + note + more);
+ } else {
+ AuditReport.table(listed).forEach(line -> getLog().warn(line));
+ getLog().warn(listed.size() + " vulnerabilities in " +
CveScan.artifactRows(listed).size() + " of "
+ + collected.deps().size() + " dependencies of " +
name + note + more);
+ }
+ writeReports(name, collected.deps().size(), remaining, hidden, failed,
result.osvError(), catalog);
+
+ if (failOnError && result.osvError() != null) {
+ throw new MojoFailureException(
+ "The dependencies of " + name + " could not be checked: "
+ result.osvError());
+ }
+ if (failed) {
+ long count = remaining.stream().filter(f ->
AuditReport.atOrAbove(f, failLevel)).count();
+ throw new MojoFailureException(
+ count + " vulnerabilities of " + failLevel + " severity or
worse in the"
+ + " dependencies of " + name + "
(failOn=" + failLevel + ")");
+ }
+ }
+
+ /**
+ * The dependencies to check: of the given scopes, without the modules of
the build and the excluded groupIds, with
+ * the chain from the dependency of the project that brings each
transitive one in.
+ */
+ static Collected collect(
+ Collection<Artifact> artifacts, Set<String> scopes, Set<String>
reactor, Set<String> excludedGroups) {
+ List<Dependency> deps = new ArrayList<>();
+ Map<String, String> via = new LinkedHashMap<>();
+ Set<String> seen = new LinkedHashSet<>();
+ for (Artifact a : artifacts) {
+ String ga = a.getGroupId() + ":" + a.getArtifactId();
+ String scope = a.getScope() != null ? a.getScope() : "compile";
+ if (!scopes.contains(scope) || reactor.contains(ga) ||
excluded(a.getGroupId(), excludedGroups)
+ || !seen.add(ga)) {
+ continue;
+ }
+ deps.add(new Dependency(a.getGroupId(), a.getArtifactId(),
a.getBaseVersion()));
+ List<String> trail = a.getDependencyTrail();
+ if (trail != null && trail.size() > 2) {
+ // the project, the dependencies that bring it in, and the
artifact itself
+ List<String> chain = new ArrayList<>();
+ for (String id : trail.subList(1, trail.size() - 1)) {
+ String[] parts = id.split(":");
+ chain.add(parts[0] + ":" + parts[1]);
+ }
+ via.put(ga, CveScan.via(chain));
+ }
+ }
+ return new Collected(deps, via);
+ }
+
+ private static boolean excluded(String groupId, Set<String>
excludedGroups) {
+ for (String g : excludedGroups) {
+ if (groupId.equals(g) || groupId.startsWith(g + ".")) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // the proxy of the Maven settings for the URL, else HTTPS_PROXY; null for
the proxy settings of the JVM
+ private HttpProxy proxy(String url) {
+ if (!url.startsWith("http://") && !url.startsWith("https://")) {
+ return null;
+ }
+ if (repositorySystemSession != null) {
+ // the settings carry the nonProxyHosts, which the proxy of the
session does not expose
+ try (MavenDownloaderImpl downloader = new MavenDownloaderImpl(
+ repositorySystem, repositorySystemSession, session != null
? session.getSettings() : null)) {
+ downloader.build();
+ MavenProxy maven = downloader.proxyFor(url);
+ if (maven != null) {
+ return new HttpProxy(
+ maven.host(), maven.port(), maven.username(),
maven.password(),
+ HttpProxy.splitHosts(maven.nonProxyHosts()));
+ }
+ } catch (IOException e) {
+ // only close() declares IOException: build() and proxyFor()
throw none, and the downloader
+ // owns no resources when it uses the repository system and
session of the build
+ getLog().debug("Cannot close the Maven downloader: " +
e.getMessage());
+ }
+ }
+ return HttpProxy.fromEnvironment(System.getenv());
+ }
+
+ private Map<String, String> readSuppressions() throws
MojoExecutionException {
+ try {
+ return AuditReport.readSuppressions(suppressions != null ?
suppressions.toPath() : null);
+ } catch (IOException e) {
+ throw new MojoExecutionException("Cannot read the suppressions " +
suppressions, e);
+ }
+ }
+
+ private void writeReports(
+ String name, int scanned, List<CveFinding> findings,
Map<CveFinding, String> hidden, boolean failed,
+ String osvError, CamelCatalog catalog)
+ throws MojoExecutionException {
+ try {
+ if (jsonReport != null && !jsonReport.getPath().isBlank()) {
+ write(jsonReport.toPath(),
+ Jsoner.prettyPrint(AuditReport.json(name, scanned,
findings, hidden, failOn, failed, osvError)
+ .toJson()));
+ }
+ if (sarifReport != null && !sarifReport.getPath().isBlank()) {
+ write(sarifReport.toPath(), Jsoner.prettyPrint(
+ AuditReport.sarif(findings, pomPath(),
catalog.getCatalogVersion()).toJson()));
+ }
+ } catch (IOException e) {
+ throw new MojoExecutionException("Cannot write the audit report",
e);
+ }
+ }
+
+ // the POM of the project, relative to the directory the build runs in
(the root of the repository, in CI)
+ private String pomPath() {
+ File pom = project.getFile();
+ if (pom == null) {
+ return "pom.xml";
+ }
+ try {
+ Path root =
Path.of(session.getExecutionRootDirectory()).toAbsolutePath().normalize();
+ return
root.relativize(pom.toPath().toAbsolutePath().normalize()).toString().replace('\\',
'/');
+ } catch (RuntimeException e) {
+ return "pom.xml";
+ }
+ }
+
+ private static void write(Path file, String text) throws IOException {
+ if (file.getParent() != null) {
+ Files.createDirectories(file.getParent());
+ }
+ Files.writeString(file, text);
+ }
+
+ private static String level(String option, String value, boolean
noneAllowed) throws MojoExecutionException {
+ String level = value != null ? value.trim().toLowerCase(Locale.ROOT) :
"";
+ if (AuditReport.LEVELS.contains(level) || noneAllowed &&
"none".equals(level)) {
+ return level;
+ }
+ throw new MojoExecutionException(
+ option + " must be critical, high, medium, low" + (noneAllowed
? " or none" : "")
+ + ", was: " + value);
+ }
+
+ private static Set<String> split(String text) {
+ Set<String> answer = new LinkedHashSet<>();
+ if (text != null) {
+ for (String s : text.split(",")) {
+ if (!s.isBlank()) {
+ answer.add(s.trim());
+ }
+ }
+ }
+ return answer;
+ }
+}
diff --git
a/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/AuditReport.java
b/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/AuditReport.java
new file mode 100644
index 000000000000..bcb03910ad79
--- /dev/null
+++
b/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/AuditReport.java
@@ -0,0 +1,254 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.camel.catalog.cve.CveFinding;
+import org.apache.camel.catalog.cve.CveScan;
+import org.apache.camel.catalog.cve.CvssScore;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+
+/**
+ * The parts of {@code camel-report:audit} that need no Maven project: the
suppressions, the console table, and the JSON
+ * and SARIF reports.
+ */
+final class AuditReport {
+
+ static final List<String> LEVELS = List.of("critical", "high", "medium",
"low");
+
+ private AuditReport() {
+ }
+
+ /**
+ * The suppressed vulnerabilities of a suppression file, by id (a CVE or
GHSA id), with the reason: one per line, as
+ * {@code CVE-2022-1471 not reachable: the YAML comes from our own config
only}; blank lines and lines starting with
+ * {@code #} are left out.
+ */
+ static Map<String, String> readSuppressions(Path file) throws IOException {
+ Map<String, String> answer = new LinkedHashMap<>();
+ if (file == null || !Files.isRegularFile(file)) {
+ return answer;
+ }
+ for (String line : Files.readAllLines(file)) {
+ String text = line.trim();
+ if (text.isEmpty() || text.startsWith("#")) {
+ continue;
+ }
+ String[] parts = text.split("\\s+", 2);
+ answer.put(parts[0].toUpperCase(Locale.ROOT), parts.length > 1 ?
parts[1] : "");
+ }
+ return answer;
+ }
+
+ /** The suppression of a finding, by its id or one of its aliases; null
when it is not suppressed. */
+ static String suppression(CveFinding finding, Map<String, String>
suppressions) {
+ String reason =
suppressions.get(finding.canonicalId().toUpperCase(Locale.ROOT));
+ if (reason == null) {
+ for (String alias : finding.aliases()) {
+ reason = suppressions.get(alias.toUpperCase(Locale.ROOT));
+ if (reason != null) {
+ break;
+ }
+ }
+ }
+ return reason;
+ }
+
+ /**
+ * Whether a finding is at or above the severity level; a severity OSV.dev
does not give counts as the lowest one.
+ */
+ static boolean atOrAbove(CveFinding finding, String level) {
+ int index = LEVELS.indexOf(level);
+ if (index < 0) {
+ return false;
+ }
+ return CveScan.severityIndex(finding.severity()) <= index || index ==
LEVELS.size() - 1;
+ }
+
+ /** The lines of the console table: severity, score, id, artifact, fix and
the dependency that brings it in. */
+ static List<String> table(List<CveFinding> findings) {
+ List<String[]> rows = new ArrayList<>();
+ rows.add(new String[] { "SEVERITY", "SCORE", "CVE", "ARTIFACT", "FIX",
"VIA", "SUMMARY" });
+ for (CveFinding f : findings) {
+ for (String gav : f.affectedGavs()) {
+ String fix = f.fixFor().get(gav);
+ String via = f.gavVia().get(gav);
+ String summary = f.summary() != null ? f.summary() : "";
+ if (summary.length() > 60) {
+ summary = summary.substring(0, 59) + "…";
+ }
+ rows.add(new String[] {
+ f.severity(), CvssScore.format(f.score()),
f.canonicalId(), gav, fix != null ? fix : "none",
+ via != null ? via : "", summary });
+ }
+ }
+ int[] width = new int[rows.get(0).length];
+ for (String[] row : rows) {
+ for (int i = 0; i < row.length; i++) {
+ width[i] = Math.max(width[i], row[i].length());
+ }
+ }
+ List<String> lines = new ArrayList<>();
+ for (String[] row : rows) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < row.length; i++) {
+ sb.append(i == 1 ? pad(row[i], width[i], true) : pad(row[i],
width[i], false));
+ if (i < row.length - 1) {
+ sb.append(" ");
+ }
+ }
+ lines.add(sb.toString().stripTrailing());
+ }
+ return lines;
+ }
+
+ private static String pad(String text, int width, boolean right) {
+ String spaces = " ".repeat(Math.max(0, width - text.length()));
+ return right ? spaces + text : text + spaces;
+ }
+
+ /** The JSON report, in the shape of {@code camel dependency audit
--json}, with the suppressed findings. */
+ static JsonObject json(
+ String project, int scanned, List<CveFinding> findings,
Map<CveFinding, String> suppressed, String failOn,
+ boolean failed, String osvError) {
+ JsonObject doc = new JsonObject();
+ doc.put("source", project);
+ doc.put("scanned", scanned);
+ doc.put("vulnerabilities", findings.size());
+ doc.put("suppressed", suppressed.size());
+ doc.put("failOn", failOn);
+ doc.put("failed", failed);
+ if (osvError != null) {
+ doc.put("osvError", osvError);
+ }
+ JsonArray rows = new JsonArray();
+ findings.forEach(f -> rows.add(f.toJson()));
+ doc.put("findings", rows);
+ JsonArray hidden = new JsonArray();
+ suppressed.forEach((f, reason) -> {
+ JsonObject row = f.toJson();
+ row.put("suppression", reason);
+ hidden.add(row);
+ });
+ doc.put("suppressedFindings", hidden);
+ return doc;
+ }
+
+ /**
+ * The SARIF 2.1.0 report, for GitHub code scanning and other tools: one
rule per vulnerability, and one result per
+ * vulnerable artifact, located at the POM of the project.
+ *
+ * @param pom the path of the POM, relative to the root of the repository
+ */
+ static JsonObject sarif(List<CveFinding> findings, String pom, String
version) {
+ JsonArray rules = new JsonArray();
+ JsonArray results = new JsonArray();
+ for (CveFinding f : findings) {
+ JsonObject rule = new JsonObject();
+ rule.put("id", f.canonicalId());
+ rule.put("name", f.canonicalId());
+ rule.put("shortDescription", text(f.summary() != null ?
f.summary() : f.canonicalId()));
+ if (f.details() != null) {
+ rule.put("fullDescription", text(f.details()));
+ }
+ rule.put("helpUri", helpUri(f));
+ JsonObject props = new JsonObject();
+ JsonArray tags = new JsonArray();
+ tags.add("security");
+ tags.add("vulnerability");
+ props.put("tags", tags);
+ if (f.score() != null) {
+ // the severity of GitHub code scanning is taken from this
score
+ props.put("security-severity", CvssScore.format(f.score()));
+ }
+ rule.put("properties", props);
+ rules.add(rule);
+
+ for (String gav : f.affectedGavs()) {
+ String fix = f.fixFor().get(gav);
+ String via = f.gavVia().get(gav);
+ JsonObject result = new JsonObject();
+ result.put("ruleId", f.canonicalId());
+ result.put("level", level(f.severity()));
+ result.put("message", text(gav + " has " + f.canonicalId() + "
(" + f.severity() + ")"
+ + (fix != null ? ", fixed in " +
fix : ", with no fix yet")
+ + (via != null ? ", brought in by "
+ via : "")
+ + (f.summary() != null ? ": " +
f.summary() : "")));
+ JsonObject location = new JsonObject();
+ JsonObject physical = new JsonObject();
+ JsonObject artifact = new JsonObject();
+ artifact.put("uri", pom);
+ physical.put("artifactLocation", artifact);
+ location.put("physicalLocation", physical);
+ JsonArray locations = new JsonArray();
+ locations.add(location);
+ result.put("locations", locations);
+ JsonObject fingerprints = new JsonObject();
+ fingerprints.put("camelAudit/v1", f.canonicalId() + "|" + gav);
+ result.put("partialFingerprints", fingerprints);
+ results.add(result);
+ }
+ }
+ JsonObject driver = new JsonObject();
+ driver.put("name", "camel-report:audit");
+ driver.put("informationUri",
"https://camel.apache.org/manual/camel-report-maven-plugin.html");
+ driver.put("version", version);
+ driver.put("rules", rules);
+ JsonObject tool = new JsonObject();
+ tool.put("driver", driver);
+ JsonObject run = new JsonObject();
+ run.put("tool", tool);
+ run.put("results", results);
+ JsonArray runs = new JsonArray();
+ runs.add(run);
+ JsonObject doc = new JsonObject();
+ doc.put("$schema", "https://json.schemastore.org/sarif-2.1.0.json");
+ doc.put("version", "2.1.0");
+ doc.put("runs", runs);
+ return doc;
+ }
+
+ private static String helpUri(CveFinding f) {
+ if (f.camelAdvisory() != null && f.camelAdvisory().url() != null) {
+ return f.camelAdvisory().url();
+ }
+ return "https://osv.dev/vulnerability/" + f.canonicalId();
+ }
+
+ private static String level(String severity) {
+ return switch (severity != null ? severity : "") {
+ case "CRITICAL", "HIGH" -> "error";
+ case "MEDIUM" -> "warning";
+ default -> "note";
+ };
+ }
+
+ private static JsonObject text(String text) {
+ JsonObject o = new JsonObject();
+ o.put("text", text);
+ return o;
+ }
+}
diff --git
a/catalog/camel-report-maven-plugin/src/test/java/org/apache/camel/maven/AuditReportTest.java
b/catalog/camel-report-maven-plugin/src/test/java/org/apache/camel/maven/AuditReportTest.java
new file mode 100644
index 000000000000..bb322b5865f4
--- /dev/null
+++
b/catalog/camel-report-maven-plugin/src/test/java/org/apache/camel/maven/AuditReportTest.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.maven;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.camel.catalog.cve.CveFinding;
+import org.apache.camel.util.json.JsonArray;
+import org.apache.camel.util.json.JsonObject;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * CAMEL-27345: camel-report:audit, the parts that need no Maven build or
network.
+ */
+public class AuditReportTest {
+
+ @TempDir
+ Path dir;
+
+ private static CveFinding finding(String id, String severity, String gav,
String fix, String... aliases) {
+ CveFinding f = new CveFinding(
+ id, severity, "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"summary of " + id,
+ null, null, new ArrayList<>(List.of(gav)), new HashMap<>(),
new ArrayList<>(List.of(aliases)),
+ new ArrayList<>());
+ if (fix != null) {
+ f.fixFor().put(gav, fix);
+ }
+ return f;
+ }
+
+ private static Artifact artifact(String groupId, String artifactId, String
version, String scope, String... trail) {
+ DefaultArtifact a = new DefaultArtifact(
+ groupId, artifactId, version, scope, "jar", null,
+ new DefaultArtifactHandler("jar"));
+ List<String> ids = new ArrayList<>();
+ ids.add("com.acme:app:jar:1.0");
+ ids.addAll(List.of(trail));
+ ids.add(groupId + ":" + artifactId + ":jar:" + version);
+ a.setDependencyTrail(ids);
+ return a;
+ }
+
+ @Test
+ void collectsTheDependenciesWithTheirChain() {
+ List<Artifact> artifacts = List.of(
+ artifact("org.apache.camel", "camel-kafka", "4.24.0",
"compile"),
+ artifact("org.apache.kafka", "kafka-clients", "3.9.0",
"compile", "org.apache.camel:camel-kafka:jar:4.24.0"),
+ artifact("org.xerial.snappy", "snappy-java", "1.1.10.1",
"runtime",
+ "org.apache.camel:camel-kafka:jar:4.24.0",
"org.apache.kafka:kafka-clients:jar:3.9.0"),
+ artifact("org.junit.jupiter", "junit-jupiter", "5.11.0",
"test"),
+ // a module of the build, and an internal library
+ artifact("com.acme", "shared", "1.0", "compile"),
+ artifact("com.acme.billing", "billing-core", "2.0",
"compile"));
+
+ AuditMojo.Collected c = AuditMojo.collect(artifacts, Set.of("compile",
"runtime"), Set.of("com.acme:shared"),
+ Set.of("com.acme"));
+
+ assertEquals(List.of("org.apache.camel:camel-kafka:4.24.0",
"org.apache.kafka:kafka-clients:3.9.0",
+ "org.xerial.snappy:snappy-java:1.1.10.1"),
c.deps().stream().map(d -> d.gav()).toList());
+ assertNull(c.via().get("org.apache.camel:camel-kafka"));
+ assertEquals("camel-kafka",
c.via().get("org.apache.kafka:kafka-clients"));
+ assertEquals("camel-kafka > kafka-clients",
c.via().get("org.xerial.snappy:snappy-java"));
+ }
+
+ @Test
+ void suppressesByIdOrAlias() throws Exception {
+ Path file = dir.resolve("camel-audit-suppressions.txt");
+ Files.writeString(file, """
+ # the YAML comes from our own configuration only
+ CVE-2022-1471 not reachable: SafeConstructor everywhere
+
+ ghsa-599f-7c49-w659
+ """);
+ Map<String, String> suppressions = AuditReport.readSuppressions(file);
+
+ assertEquals("not reachable: SafeConstructor everywhere",
+ AuditReport.suppression(finding("CVE-2022-1471", "HIGH",
"org.yaml:snakeyaml:1.33", "2.0"), suppressions));
+ // by its GHSA alias, case-insensitive, without a reason
+ assertEquals("", AuditReport.suppression(finding("CVE-2022-42889",
"CRITICAL",
+ "org.apache.commons:commons-text:1.9", "1.10.0",
"GHSA-599f-7c49-w659"), suppressions));
+ assertNull(AuditReport.suppression(finding("CVE-2025-48924", "MEDIUM",
"a:b:1", null), suppressions));
+
assertTrue(AuditReport.readSuppressions(dir.resolve("none.txt")).isEmpty());
+ }
+
+ @Test
+ void failsOnASeverityOrAbove() {
+ CveFinding medium = finding("CVE-1", "MEDIUM", "a:b:1", "2");
+ assertTrue(AuditReport.atOrAbove(medium, "low"));
+ assertTrue(AuditReport.atOrAbove(medium, "medium"));
+ assertFalse(AuditReport.atOrAbove(medium, "high"));
+ assertFalse(AuditReport.atOrAbove(medium, "none"));
+ // a severity OSV.dev does not give fails the lowest level only
+ assertTrue(AuditReport.atOrAbove(finding("CVE-2", "UNKNOWN", "a:b:1",
null), "low"));
+ assertFalse(AuditReport.atOrAbove(finding("CVE-2", "UNKNOWN", "a:b:1",
null), "medium"));
+ }
+
+ @Test
+ void theTableHasTheFixAndTheChain() {
+ CveFinding f = finding("CVE-2023-43642", "HIGH",
"org.xerial.snappy:snappy-java:1.1.10.1", "1.1.10.4");
+ f.gavVia().put("org.xerial.snappy:snappy-java:1.1.10.1", "camel-kafka
> kafka-clients");
+
+ List<String> lines = AuditReport.table(List.of(f,
finding("CVE-2024-3", "LOW", "com.example:lib:1.0", null)));
+
+ assertTrue(lines.get(0).startsWith("SEVERITY SCORE CVE"));
+ assertTrue(lines.get(1).contains("CVE-2023-43642") &&
lines.get(1).contains("9.8")
+ && lines.get(1).contains("1.1.10.4") &&
lines.get(1).contains("camel-kafka > kafka-clients"));
+ assertTrue(lines.get(2).contains("none"));
+ }
+
+ @Test
+ void theSarifReportHasARuleAndAResultPerArtifact() {
+ CveFinding f = finding("CVE-2022-42889", "CRITICAL",
"org.apache.commons:commons-text:1.9", "1.10.0");
+ f.affectedGavs().add("org.apache.commons:commons-text:1.8");
+
+ JsonObject doc = AuditReport.sarif(List.of(f), "app/pom.xml",
"4.24.0");
+
+ assertEquals("2.1.0", doc.getString("version"));
+ JsonObject run = (JsonObject) ((JsonArray) doc.get("runs")).get(0);
+ JsonObject driver = (JsonObject) ((JsonObject)
run.get("tool")).get("driver");
+ JsonObject rule = (JsonObject) ((JsonArray)
driver.get("rules")).get(0);
+ assertEquals("CVE-2022-42889", rule.getString("id"));
+ assertEquals("https://osv.dev/vulnerability/CVE-2022-42889",
rule.getString("helpUri"));
+ assertEquals("9.8", ((JsonObject)
rule.get("properties")).getString("security-severity"));
+ JsonArray results = (JsonArray) run.get("results");
+ assertEquals(2, results.size());
+ JsonObject result = (JsonObject) results.get(0);
+ assertEquals("error", result.getString("level"));
+ assertTrue(((JsonObject)
result.get("message")).getString("text").contains("fixed in 1.10.0"));
+ JsonObject location = (JsonObject) ((JsonArray)
result.get("locations")).get(0);
+ assertEquals("app/pom.xml",
+ ((JsonObject) ((JsonObject)
location.get("physicalLocation")).get("artifactLocation")).getString("uri"));
+ }
+
+ @Test
+ void theJsonReportHasTheSuppressedFindings() {
+ CveFinding listed = finding("CVE-1", "HIGH", "a:b:1", "2");
+ Map<CveFinding, String> hidden = new LinkedHashMap<>();
+ hidden.put(finding("CVE-2", "LOW", "c:d:1", null), "not used");
+
+ JsonObject doc = AuditReport.json("com.acme:app", 12, List.of(listed),
hidden, "high", true, null);
+
+ assertEquals(12, doc.getInteger("scanned"));
+ assertEquals(1, doc.getInteger("vulnerabilities"));
+ assertEquals(1, doc.getInteger("suppressed"));
+ assertTrue(doc.getBoolean("failed"));
+ JsonObject row = (JsonObject) ((JsonArray)
doc.get("suppressedFindings")).get(0);
+ assertEquals("not used", row.getString("suppression"));
+ }
+}
diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc
b/docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc
index c0623e49e64b..76fd385f2237 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang-projects.adoc
@@ -270,7 +270,9 @@ The command exits with 1 when it finds a vulnerability of
the `--fail-on` severi
CI job fails; `--fail-on=none` always exits with 0. When OSV.dev (or the OSV
database) cannot be used, the command
warns and checks the Apache Camel security advisories only; with
`--fail-on-error` it exits with 1 then, so a CI job
does not pass without the check. The CVE Audit screen of the
xref:camel-jbang-tui.adoc[Camel TUI]
-shows the same for a running integration, and explains a vulnerability with AI.
+shows the same for a running integration, and explains a vulnerability with
AI. For a Maven build in a CI/CD
+pipeline, the
xref:camel-report-maven-plugin.adoc#_camel_reportaudit[camel-report:audit] goal
does the same checks
+on the dependencies Maven resolved, fails the build on a severity, and writes
a SARIF report.
=== The offline OSV database
diff --git a/docs/user-manual/modules/ROOT/pages/camel-report-maven-plugin.adoc
b/docs/user-manual/modules/ROOT/pages/camel-report-maven-plugin.adoc
index 59bdf4bfc4c2..56b9e00527bb 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-report-maven-plugin.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-report-maven-plugin.adoc
@@ -4,6 +4,7 @@ The Camel Report Maven Plugin supports the following goals
- camel-report:validate - To validate your source code for invalid Camel
endpoint uris
- camel-report:route-coverage - To report the coverage of your Camel routes
after unit testing
+ - camel-report:audit - To check the dependencies for known vulnerabilities
(CVEs), and fail the build on them
== camel-report:validate
@@ -218,6 +219,129 @@ In particular, in order to use the validate plugin with
transitive dependencies,
</plugin>
----
+== camel-report:audit
+
+Checks the dependencies of the project for known vulnerabilities (CVEs), for a
CI/CD pipeline: every JAR against
+https://osv.dev[OSV.dev], and the Camel JARs against the Apache Camel security
advisories that ship with the Camel
+catalog. These are the same checks as `camel dependency audit` of the
xref:camel-jbang.adoc[Camel CLI]. The
+dependencies are those Maven resolved for the build, with the versions the
BOMs (`dependencyManagement`) chose.
+
+[source,bash]
+----
+mvn camel-report:audit
+----
+
+[source,text]
+----
+[WARNING] SEVERITY SCORE CVE ARTIFACT
FIX VIA SUMMARY
+[WARNING] CRITICAL 9.8 CVE-2022-42889 org.apache.commons:commons-text:1.9
1.10.0 Arbitrary code execution in Apache Commons Text
+[WARNING] MEDIUM 6.5 CVE-2025-48924
org.apache.commons:commons-lang3:3.11 3.18.0 commons-text Apache Commons
Lang is vulnerable to Uncontrolled Recursion…
+[WARNING] 2 vulnerabilities in 2 of 3 dependencies of com.acme:orders, 1
suppressed
+----
+
+*FIX* is the version that fixes the JAR, or the Camel release to upgrade to
for a Camel advisory, and *VIA* the
+dependency chain that brings it in.
+
+By default the goal only reports. To fail the build, set `failOn` to a
severity:
+
+[source,bash]
+----
+mvn camel-report:audit -Dcamel.audit.failOn=high
+----
+
+Or run it in every build, in the `verify` phase:
+
+[source,xml]
+----
+<plugin>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-report-maven-plugin</artifactId>
+ <version>${camel.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>audit</goal>
+ </goals>
+ <configuration>
+ <failOn>high</failOn>
+ <osvDatabase>true</osvDatabase>
+ </configuration>
+ </execution>
+ </executions>
+</plugin>
+----
+
+The Apache Camel security advisories are those of the catalog of the plugin,
so use the latest release of the plugin,
+whatever the Camel version of the project, to know the latest advisories.
+
+=== The offline OSV database
+
+By default the goal sends the coordinates (`groupId:artifactId:version`) of
the dependencies to the OSV.dev API. With
+`osvDatabase` it does not: it downloads the export of all the Maven
vulnerabilities of OSV.dev (one ZIP file of about
+10 MB, updated every day by OSV.dev) and matches the versions locally, so no
coordinates leave the machine. The ZIP is
+kept in `~/.camel/osv` (shared with the Camel CLI) and downloaded again once a
day.
+
+A build machine without internet access downloads it from the repository
manager of the company, such as a raw
+repository of Nexus or a generic remote repository of Artifactory that proxies
+`https://osv-vulnerabilities.storage.googleapis.com/Maven/all.zip`, or reads a
file:
+
+[source,bash]
+----
+mvn camel-report:audit
-Dcamel.audit.osvDatabaseUrl=https://nexus.corp.com/repository/osv/Maven/all.zip
+----
+
+The goal reaches OSV.dev, or the URL of the database, through the proxy of the
Maven settings (`settings.xml`, with its
+username, password and `nonProxyHosts`), else the `HTTPS_PROXY` and `NO_PROXY`
environment variables.
+
+=== Suppressions
+
+A vulnerability that does not apply to the project, such as one in a feature
the project does not use, goes in
+`camel-audit-suppressions.txt` beside the `pom.xml`, one per line with the
reason. It is then reported as suppressed,
+and does not fail the build:
+
+[source,text]
+----
+# the id of the CVE, or of its GHSA alias, and why
+CVE-2022-1471 the YAML comes from our own configuration only
+----
+
+=== Reports
+
+The goal writes `target/camel-audit.json` (in the shape of `camel dependency
audit --json`, with the suppressed
+findings and their reasons) and `target/camel-audit.sarif`. The SARIF report
can be uploaded to GitHub code scanning,
+which then shows the vulnerabilities in the Security tab of the repository:
+
+[source,yaml]
+----
+- run: mvn -B verify camel-report:audit
+- uses: github/codeql-action/upload-sarif@v4
+ if: always()
+ with:
+ sarif_file: target/camel-audit.sarif
+----
+
+=== Options
+
+[width="100%",cols="10%,10%,80%",options="header",]
+|===
+| Parameter | Default Value | Description
+| skip | false | Skips the audit.
+| scopes | compile,runtime | The scopes of the dependencies to check,
separated by commas.
+| severity | low | The lowest severity to list: critical, high, medium or low.
+| failOn | none | Fails the build when a vulnerability at or above this
severity is found (also one below `severity`): critical, high, medium, low, or
none to only report them.
+| failOnError | false | Fails the build when the dependencies could not be
checked with OSV.dev or the OSV database (not reachable, no database).
Otherwise only the Apache Camel security advisories are checked then, with a
warning.
+| offline | false | Checks the Apache Camel security advisories of the catalog
only, without OSV.dev.
+| osvDatabase | false | Checks with the offline OSV database instead of the
OSV.dev API.
+| osvDatabaseUrl | | Where the offline OSV database is downloaded from, or a
ZIP file on disk (default
`\https://osv-vulnerabilities.storage.googleapis.com/Maven/all.zip`). Implies
`osvDatabase`.
+| osvDatabaseCache | ~/.camel/osv | Where a downloaded OSV database is kept.
+| excludeGroupIds | | The groupIds that are not checked and not sent to
OSV.dev, such as those of the internal libraries of a company, separated by
commas; `com.acme` also leaves out `com.acme.billing`. The modules of the build
are never checked.
+| suppressions | camel-audit-suppressions.txt | The file of the
vulnerabilities that do not apply, beside the `pom.xml`.
+| jsonReport | target/camel-audit.json | The JSON report; empty for none.
+| sarifReport | target/camel-audit.sarif | The SARIF report; empty for none.
+|===
+
+Each option can be set as a property with the `camel.audit.` prefix, such as
`-Dcamel.audit.failOn=high`.
+
== camel-report:route-coverage
For generating a report of the coverage of your Camel routes from unit testing.