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-jbang-examples.git
The following commit(s) were added to refs/heads/main by this push:
new e636b1f security/cve-audit: outdated libraries on purpose, to audit
their CVEs and ask the AI whether the integration is affected (#143)
e636b1f is described below
commit e636b1fcad26b962befa8cda0e19c9ee9de45a15
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat Nov 21 13:00:38 2026 +0100
security/cve-audit: outdated libraries on purpose, to audit their CVEs and
ask the AI whether the integration is affected (#143)
* security/cve-audit - outdated libraries on purpose, to audit their CVEs
and ask the AI whether the integration is affected (CAMEL-27328)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Claus Ibsen <[email protected]>
* security/cve-audit - the README audits the example with camel dependency
audit (CAMEL-27340)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Claus Ibsen <[email protected]>
---------
Signed-off-by: Claus Ibsen <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.github/workflows/build.yml | 2 +
security/cve-audit/OrderNote.java | 36 ++++++
security/cve-audit/README.md | 153 +++++++++++++++++++++++
security/cve-audit/application.properties | 26 ++++
security/cve-audit/beans.yaml | 3 +
security/cve-audit/cve-audit.camel.yaml | 35 ++++++
security/cve-audit/metadata.json | 13 ++
security/cve-audit/test/cve-audit.citrus.it.yaml | 19 +++
8 files changed, 287 insertions(+)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index c03f94d..e257d4c 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -113,6 +113,8 @@ jobs:
path: transformation/edi-x12-as2
- name: Smart log analyzer
path: showcase/smart-log-analyzer/first-iteration
+ - name: CVE audit
+ path: security/cve-audit
fail-fast: false
name: ${{ matrix.name }}
steps:
diff --git a/security/cve-audit/OrderNote.java
b/security/cve-audit/OrderNote.java
new file mode 100644
index 0000000..26feb80
--- /dev/null
+++ b/security/cve-audit/OrderNote.java
@@ -0,0 +1,36 @@
+/*
+ * 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 camel.example;
+
+import java.util.Map;
+
+import org.apache.commons.text.StringSubstitutor;
+
+/**
+ * Writes the note of an order from a template with commons-text. It uses a
StringSubstitutor with a map of
+ * values: the variables of the template are looked up in the map only. The
interpolator of commons-text
+ * (StringSubstitutor.createInterpolator()), whose script, dns and url lookups
CVE-2022-42889 is about, is not
+ * used, which is what the AI should find when asked whether the integration
is affected.
+ */
+public class OrderNote {
+
+ private static final String TEMPLATE = "order ${orderId} for customer
${customer} is paid";
+
+ public String note(String orderId, String customer) {
+ return new StringSubstitutor(Map.of("orderId", orderId, "customer",
customer)).replace(TEMPLATE);
+ }
+}
diff --git a/security/cve-audit/README.md b/security/cve-audit/README.md
new file mode 100644
index 0000000..f033cc5
--- /dev/null
+++ b/security/cve-audit/README.md
@@ -0,0 +1,153 @@
+# CVE Audit
+
+The shop's order feed, with libraries that have known CVEs on purpose. Run it,
open the CVE Audit screen of the
+Camel TUI, and see which versions fix them, whether the routes use them, and
what the AI says about whether the
+integration is affected.
+
+> **Deliberately vulnerable.** `application.properties` declares commons-text
1.9 and snakeyaml 1.33, versions
+> with known CVEs. Never copy them into a real project. The example has no
HTTP endpoint or other input from the
+> outside: the orders come from a timer.
+
+## What you will see
+
+The integration logs an order every five seconds, with a note that a bean
writes with commons-text:
+
+```text
+INFO ... cve-audit.camel.yaml:34 : New order ORD-1: order ORD-1 for customer
C-842 is paid
+INFO ... cve-audit.camel.yaml:34 : New order ORD-2: order ORD-2 for customer
C-296 is paid
+```
+
+In the Camel TUI, More > Project > CVE Audit lists the vulnerabilities of the
JARs on its classpath (OSV.dev adds
+new ones over time, so the list grows):
+
+```text
+SEVERITY SCORE CVE ID ARTIFACT FIX
VIA USED
+CRITICAL 9.8 CVE-2022-42889 org.apache.commons:commons-text:1.9
1.10.0
+HIGH 8.3 CVE-2022-1471 org.yaml:snakeyaml:1.33 2.0
+MEDIUM 6.5 CVE-2025-48924 org.apache.commons:commons-lang3:3.11
3.18.0 commons-text
+```
+
+- **FIX** is the version that fixes the JAR, on the line its version is in.
+- **VIA** is how a JAR comes in: commons-lang3 3.11 is not declared by the
project, commons-text 1.9 brings it.
+- **USED** is `yes` or `no` when a Camel component brings a JAR in, and
whether the routes have an endpoint of
+ it; it is empty here, as the project adds these libraries itself.
+
+Press `g` to group by artifact: one row per JAR with the version that fixes
all its CVEs, which is what to
+upgrade.
+
+## Install Camel CLI
+
+Install [JBang](https://www.jbang.dev/download/) and the Camel CLI as
described in the
+[root README](../../README.md#install-the-camel-cli); `camel --version`
confirms the install.
+
+## Run it
+
+```shell
+camel run *
+```
+
+In another terminal, start the TUI, select the `cve-audit` integration, and
open More > Project > CVE Audit:
+
+```shell
+camel tui
+```
+
+The first scan queries [OSV.dev](https://osv.dev), so it needs network access;
the Apache Camel security
+advisories are checked too, from the Camel catalog.
+
+Stop the integration with `ctrl` + `c`, or with `camel stop cve-audit`.
+
+## How it works
+
+- `cve-audit.camel.yaml` is the route: a `timer` creates an order, and a
`setVariable` asks the `orderNote` bean
+ for the note of the order with a method expression, which the `log` prints.
+- `OrderNote.java` writes the note from a template with commons-text's
`StringSubstitutor`, with a map of the
+ values. `beans.yaml` declares it as the bean `orderNote`.
+- `application.properties` declares the two outdated libraries with
`camel.jbang.dependencies`, and the period of
+ the timer.
+
+## Ask the AI
+
+Select a vulnerability and press `Shift+F8`: the AI panel opens with a
question made of the CVE, the JAR and the
+version that fixes it, how the JAR comes in, and the change that fixes it.
Things to look for in the answers:
+
+- **CVE-2022-42889** (Text4Shell) is about the interpolator of commons-text
+ (`StringSubstitutor.createInterpolator()`) and its script, dns and url
lookups. `OrderNote.java` uses a
+ `StringSubstitutor` with a map, which looks up the variables in the map
only, and its values come from the
+ timer, not from the outside. The library is vulnerable but the integration
is not exposed; upgrading to 1.10.0
+ is still the fix.
+- **CVE-2022-1471** is in snakeyaml 1.33, which nothing in the integration
uses: the fix is to remove it from
+ `camel.jbang.dependencies`. Camel brings snakeyaml 2.x itself, so both
versions are on the classpath, which the
+ Classpath tab shows.
+- **CVE-2025-48924** is in commons-lang3 3.11, which commons-text 1.9 brings
in. commons-text 1.10.0 fixes
+ Text4Shell but still brings commons-lang3 3.12.0, which is affected too;
commons-text 1.14.0 is the first to bring
+ commons-lang3 3.18.0. So the change that fixes all three is commons-text
1.14.0 or later, and no snakeyaml.
+
+The AI offers the change, and makes it only when you agree. After the
integration restarts, press `r` on the CVE
+Audit screen to scan again.
+
+## Audit from the command line
+
+The same audit without the TUI, for a script, a CI job or an AI agent:
+
+```shell
+camel dependency audit cve-audit.camel.yaml beans.yaml OrderNote.java
application.properties
+```
+
+```text
+ SEVERITY SCORE CVE ARTIFACT FIX
VIA USED SUMMARY
+ CRITICAL 9.8 CVE-2022-42889 org.apache.commons:commons-text:1.9
1.10.0 Arbitrary code execution in Apache Commons Text
+ HIGH 8.3 CVE-2022-1471 org.yaml:snakeyaml:1.33 2.0
SnakeYaml Constructor Deserialization Remote Code Executi…
+ 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
Recursi…
+
+3 vulnerabilities in 3 of 27 dependencies of the project (1 CRITICAL, 1 HIGH,
1 MEDIUM)
+```
+
+It audits the dependencies of the files with the ones they bring in. While the
integration runs,
+`camel dependency audit --integration=cve-audit` audits the JARs it actually
loaded instead. `--by-artifact` shows
+one row per JAR with the version that fixes all its CVEs, and `--json` one
JSON document. The command exits with 1
+when it finds a vulnerability, so a CI job fails; `--fail-on=critical` fails
on critical ones only, and
+`--fail-on=none` never.
+
+## Build it step by step
+
+Ask your assistant, or type it yourself, one step at a time, and run after
each:
+
+1. A timer route that creates an order every five seconds, with the order id
from the timer counter, and logs it.
+2. Add a Java class `OrderNote` with a method `note(orderId, customer)` that
fills the template
+ `order ${orderId} for customer ${customer} is paid` with commons-text's
`StringSubstitutor`, declare it in
+ `beans.yaml`, and log the note.
+3. Declare commons-text 1.9 in `application.properties` with
`camel.jbang.dependencies`.
+4. Add snakeyaml 1.33 to the dependencies, which nothing uses.
+5. Open the CVE Audit screen of the TUI and ask the AI about each
vulnerability.
+
+## Try changing
+
+- Upgrade commons-text to 1.10.0, and scan again with `r`: CVE-2022-42889 is
gone, but commons-lang3 3.12.0 still
+ has CVE-2025-48924. With commons-text 1.14.0 or later, it is gone too.
+- Remove snakeyaml from `camel.jbang.dependencies`, and check on the Classpath
tab that only the version Camel
+ brings is left.
+- Run `camel dependency audit --fail-on=critical` after each change: it exits
with 0 once commons-text is upgraded.
+- Add a component that brings libraries of its own, such as `camel-kafka`,
with an older version of one of them,
+ to see a chain such as `camel-kafka > kafka-clients` in the VIA column, and
`yes` or `no` in USED.
+
+## Integration testing
+
+The example comes with a test in the [Citrus](https://citrusframework.org/)
YAML DSL,
+`test/cve-audit.citrus.it.yaml`, which the Camel CLI runs:
+
+```shell
+camel test run test/cve-audit.citrus.it.yaml
+```
+
+The test starts the route and verifies the logged note, written with
commons-text.
+
+## Help and contributions
+
+If you hit any problem using Camel or have some feedback, then please
+[let us know](https://camel.apache.org/community/support/).
+
+We also love contributors, so
+[get involved](https://camel.apache.org/community/contributing/) :-)
+
+The Camel riders!
diff --git a/security/cve-audit/application.properties
b/security/cve-audit/application.properties
new file mode 100644
index 0000000..b8f5183
--- /dev/null
+++ b/security/cve-audit/application.properties
@@ -0,0 +1,26 @@
+# 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.
+
+# DELIBERATELY OUTDATED: two libraries with known CVEs, so the CVE Audit
screen of the Camel TUI
+# (and the AI behind Shift+F8) has something to find. Never copy these
versions into a real project.
+#
+# commons-text 1.9 has CVE-2022-42889 (Text4Shell, fixed in 1.10.0); the route
uses it to write
+# the note of each order. snakeyaml 1.33 has CVE-2022-1471 (fixed in 2.0);
nothing uses it.
+camel.jbang.dependencies=org.apache.commons:commons-text:1.9,org.yaml:snakeyaml:1.33
+
+# How often a new order is created, in milliseconds
+order.period=5000
diff --git a/security/cve-audit/beans.yaml b/security/cve-audit/beans.yaml
new file mode 100644
index 0000000..be0f744
--- /dev/null
+++ b/security/cve-audit/beans.yaml
@@ -0,0 +1,3 @@
+- beans:
+ - name: orderNote
+ type: "camel.example.OrderNote"
diff --git a/security/cve-audit/cve-audit.camel.yaml
b/security/cve-audit/cve-audit.camel.yaml
new file mode 100644
index 0000000..4335326
--- /dev/null
+++ b/security/cve-audit/cve-audit.camel.yaml
@@ -0,0 +1,35 @@
+# The shop's order feed, with a note for each order written by a bean that
uses commons-text.
+# application.properties declares commons-text and snakeyaml in versions with
known CVEs, on purpose.
+- route:
+ id: cve-audit
+ from:
+ uri: timer
+ parameters:
+ timerName: orders
+ period: "{{order.period}}"
+ includeMetadata: true
+ steps:
+ - setVariable:
+ name: orderId
+ expression:
+ simple:
+ expression: "ORD-${exchangeProperty.CamelTimerCounter}"
+ - setVariable:
+ name: customer
+ expression:
+ simple:
+ expression: "C-${random(100,999)}"
+ - setBody:
+ expression:
+ simple:
+ expression: |-
+ {"orderId": "${variable.orderId}", "customer":
"${variable.customer}", "country": "DK",
+ "lines": [{"sku": "CAMEL-TSHIRT", "qty": ${random(1,3)},
"price": 19.95}], "status": "paid"}
+ - setVariable:
+ name: note
+ expression:
+ method:
+ ref: orderNote
+ method: "note(${variable.orderId}, ${variable.customer})"
+ - log:
+ message: "New order ${variable.orderId}: ${variable.note}"
diff --git a/security/cve-audit/metadata.json b/security/cve-audit/metadata.json
new file mode 100644
index 0000000..9e6d1ab
--- /dev/null
+++ b/security/cve-audit/metadata.json
@@ -0,0 +1,13 @@
+{
+ "title": "CVE Audit",
+ "description": "A shop order feed that declares two libraries with known
CVEs on purpose, so the CVE Audit screen of the Camel TUI shows the version
that fixes each, whether the routes use it, and the AI explains whether the
integration is affected.",
+ "tags": [
+ "security",
+ "cve",
+ "tui",
+ "dependencies"
+ ],
+ "bundled": false,
+ "level": "advanced",
+ "exclude": true
+}
diff --git a/security/cve-audit/test/cve-audit.citrus.it.yaml
b/security/cve-audit/test/cve-audit.citrus.it.yaml
new file mode 100644
index 0000000..2f02719
--- /dev/null
+++ b/security/cve-audit/test/cve-audit.citrus.it.yaml
@@ -0,0 +1,19 @@
+name: cve-audit-test
+description: The order feed writes the note of each order with commons-text
+actions:
+ - camel:
+ cli:
+ run:
+ integration:
+ name: "cve-audit"
+ file: "../cve-audit.camel.yaml"
+ systemProperties:
+ file: "../application.properties"
+ resources:
+ - "beans.yaml"
+ - "OrderNote.java"
+ - camel:
+ cli:
+ verify:
+ integration: "cve-audit"
+ logMessage: "New order ORD-1: order ORD-1 for customer C-"