Skip to content

add IAST code injection tests for java - #7445

Open
claponcet wants to merge 5 commits into
mainfrom
clara.poncet/java-iast-code-injection
Open

add IAST code injection tests for java#7445
claponcet wants to merge 5 commits into
mainfrom
clara.poncet/java-iast-code-injection

Conversation

@claponcet

@claponcet claponcet commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Motivation

The IAST CODE_INJECTION sink was not covered by system-tests for the Java tracer. This adds the weblog endpoints and enables the existing test_code_injection.py tests so the Java library's code-injection detection (BeanShell sink) is validated end-to-end.

Changes

  • Add a shared CodeInjectionExamples helper in iast-common that triggers the sink by evaluating input through BeanShell (bsh.Interpreter.eval), with an insecure (tainted input) and secure (hardcoded literal) variant.
  • Expose POST /iast/code_injection/test_insecure and POST /iast/code_injection/test_secure in the weblogs that carry the full IAST sink surface: akka-http, jersey-grizzly2, resteasy-netty3, spring-boot, vertx3, vertx4.
  • Add the bsh dependency to iast-common (optional) and to each weblog that implements the endpoint.
  • Enable TestCodeInjection and TestCodeInjection_StackTrace in manifests/java.yml from v1.65.0-SNAPSHOT:
    • play / ratpack: incomplete_test_app (endpoint not implemented) — these weblogs do not implement the IAST sink endpoints.
    • spring-boot-3-native: irrelevant (GraalVM. Tracing support only).

Workflow

  1. ⚠️ Create your PR as draft ⚠️
  2. Work on you PR until the CI passes
  3. Mark it as ready for review
    • Test logic is modified? -> Get a review from RFC owner.
    • Framework is modified, or non obvious usage of it -> get a review from R&P team

🚀 Once your PR is reviewed and the CI green, you can merge it!

🛟 #apm-shared-testing 🛟

Reviewer checklist

  • Anything but tests/ or manifests/ is modified ? I have the approval from R&P team
  • A docker base image is modified?
    • the relevant build-XXX-image label is present
  • A scenario is added, removed or renamed?

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

CODEOWNERS have been resolved as:

utils/build/docker/java/iast-common/src/main/java/com/datadoghq/system_tests/iast/utils/CodeInjectionExamples.java  @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
manifests/java.yml                                                      @DataDog/asm-java @DataDog/apm-java
utils/build/docker/java/akka-http/pom.xml                               @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
utils/build/docker/java/akka-http/src/main/scala/com/datadoghq/akka_http/IastRoutes.scala  @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
utils/build/docker/java/iast-common/pom.xml                             @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
utils/build/docker/java/jersey-grizzly2/pom.xml                         @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
utils/build/docker/java/jersey-grizzly2/src/main/java/com/datadoghq/jersey/IastSinkResource.java  @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
utils/build/docker/java/play/pom.xml                                    @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
utils/build/docker/java/ratpack/pom.xml                                 @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
utils/build/docker/java/resteasy-netty3/pom.xml                         @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
utils/build/docker/java/resteasy-netty3/src/main/java/com/datadoghq/resteasy/IastSinkResource.java  @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
utils/build/docker/java/spring-boot/pom.xml                             @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
utils/build/docker/java/spring-boot/src/main/java/com/datadoghq/system_tests/springboot/AppSecIast.java  @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
utils/build/docker/java/vertx3/pom.xml                                  @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
utils/build/docker/java/vertx3/src/main/java/com/datadoghq/vertx3/iast/routes/IastSinkRouteProvider.java  @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
utils/build/docker/java/vertx4/pom.xml                                  @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
utils/build/docker/java/vertx4/src/main/java/com/datadoghq/vertx4/iast/routes/IastSinkRouteProvider.java  @DataDog/apm-java @DataDog/asm-java @DataDog/system-tests-core
utils/build/docker/java_otel/spring-boot/pom.xml                        @DataDog/opentelemetry @DataDog/system-tests-core

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Aug 4, 2026

Copy link
Copy Markdown

Pipelines  Tests

⚠️ Warnings

🚦 2 Pipeline jobs failed

Testing the test | System Tests (java, prod) / End-to-end #1 / spring-boot-openliberty 1   View in Datadog   GitHub Actions

See error 1 failed test. Assertion Error: Unexpected log found: '[dd.trace 2026-08-05 15:29:25:583 +0000] [dd-jmx-collector] WARN org.datadog.jmxfetch.tasks.TaskProcessor - JMXFetch...'

🧪 1 Test failed

All test failures are known flaky.

❄️ Known flaky: tests.test_library_logs.Test_NoExceptions.test_java_logs[spring-boot-openliberty] from system_tests_suite   View in Datadog
self = <tests.test_library_logs.Test_NoExceptions object at 0x7fa0844ab020>

    def test_java_logs(self):
        """Test Java logs for unexpected errors."""
        disallowed_patterns = [
            r".*ERROR.*",
        ]
        allowed_patterns = [
            r".*"
            + re.escape(
...

Not introduced in this PR.

Testing the test | all-jobs-are-green   View in Datadog   GitHub Actions

See error Check run failed: System Tests (java, prod) / End-to-end #1 / spring-boot-openliberty 1

ℹ️ Info

No other issues found (see more)

❄️ No new flaky tests detected

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 89915c1 | Docs | Datadog PR Page | Give us feedback!

@claponcet
claponcet marked this pull request as ready for review August 5, 2026 13:43
@claponcet
claponcet requested review from a team as code owners August 5, 2026 13:43

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2dac0de616

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

package com.datadoghq.system_tests.iast.utils;

import bsh.EvalError;
import bsh.Interpreter;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add BeanShell to the OTel Spring Boot build

When the java_otel Spring Boot image is built, utils/build/docker/java_otel/spring-boot-otel.Dockerfile copies the shared iast-common sources and that POM adds ../iast-common/src/main/java/ as compile sources, but utils/build/docker/java_otel/spring-boot/pom.xml does not declare the new BeanShell dependency. This new import therefore makes that supported weblog fail compilation with package bsh does not exist; add the same org.apache-extras.beanshell:bsh dependency there or keep this helper out of sources used by the OTel weblog.

Useful? React with 👍 / 👎.

@claponcet
claponcet requested a review from a team as a code owner August 5, 2026 15:12
@claponcet
claponcet requested a review from peschinskiy August 5, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant