Skip to content

Add fail-closed blocking test coverage ahead of #12601's overload migration - #12629

Draft
jandro996 wants to merge 8 commits into
masterfrom
appsec-test-1
Draft

jandro996 wants to merge 8 commits into
masterfrom
appsec-test-1

Conversation

@jandro996

@jandro996 jandro996 commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

What Does This Do

Adds unit/integration test coverage for AppSec blocking behavior that today has no test guarding it, so PR #12601's migration from the tryCommitBlockingResponse(TraceSegment, RBA) overload to the (RequestContext, RBA) default cannot silently regress it.

  • ProcessImplInstrumentationHelpersBlockingTest — pins the fail-closed behavior of ProcessImplInstrumentationHelpers.cmdiRaspCheck/shiRaspCheck (CMDI/SHI RASP), with and without a BlockResponseFunction.
  • FileIORaspHelperBlockingTest — same coverage for FileIORaspHelper's entry points (LFI RASP). Also fixes test-order flakiness: pre-existing Groovy specs in java-io-1.8 replace FileIORaspHelper.INSTANCE with a mock and never restore it, leaking it into whichever test runs next in the same JVM. The new test now saves/restores the real singleton via reflection around each case.
  • URLSinkCallSiteBlockingTest — same coverage for URLSinkCallSite (SSRF RASP).
  • AppSecEventTrackerTest — new case asserting dispatch() calls tryCommitBlockingResponse and throws when a real BlockResponseFunction is configured.
  • StoredCharBodyTest — migrated from Groovy to Java (JUnit 5) and extended with a case covering maybeNotifyAndBlock() against a real BlockResponseFunction.
  • BlockResponseFunctionTest — direct coverage of the (TraceSegment, RBA) overload's status code / content type / extra headers / security response id mapping.
  • play-appsec-common's PathExtractionHelpersTest (new test module) pins the current fail-closed behavior as a deliberate tripwire: it documents the behavior expected to flip once Migrate AppSec blocking glue to the RequestContext tryCommitBlockingResponse overload #12601 rebases onto this branch.
  • Play 2.5/2.6: new coverage for the ResultsStatus/StatusHeaderSendJson advices (ignoring commit result today) and BodyParserHelpers (filenames/file-content/XML blocking), plus a PlayServerTest x-block-response:body integration case.
  • vertx-web 3.4/4.0/5.0: new unit coverage for RoutingContextSessionAdvice (including the fail-open path without a BRF) and FileUploadHelper.commitBlockingResponse, plus a RoutingContextJsonResponseAdvice BODY_JSON integration case (4.0/5.0).
  • jax-rs-annotations-2.0 / jakarta-rs-annotations-3.0: new unit coverage for the MessageBodyWriter advice.
  • Ratpack 1.5: new JsonRendererAdvice BODY_JSON integration case.

Motivation

#12601 migrates ~59 AppSec blocking call sites onto the (RequestContext, RBA) overload. The migration is mechanically a no-behavior-change for nearly all of them, but several of the touched modules had no test asserting the blocking behavior at all, so a mistake in that migration would only be caught in production. This lands ahead of #12601 so CI catches any regression from that overload migration.

Additional Notes

No behavior change in production code in this PR: test-only, except for the Groovy→Java migration of StoredCharBodyTest and the new play-appsec-common test source set (build.gradle/lockfile additions to add a mockito test dependency where one didn't exist).

Contributor Checklist

Jira ticket: APPSEC-70201

Note: Once your PR is ready to merge, add it to the merge queue by commenting /merge. /merge -c cancels the queue request. /merge -f --reason "reason" skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.

…gration

PR #12601 (APPSEC-70201) migrates ~59 AppSec blocking call sites from the
(TraceSegment, RBA) overload to the (RequestContext, RBA) default added by
#12519. This is a mechanical no-behavior-change migration for nearly all
sites, but it currently lacks test coverage in several modules, so a silent
regression there would only surface as a production incident.

Adds unit and integration tests that pin the current fail-closed blocking
behavior across the untested surface, so any regression introduced by the
overload migration is caught by CI instead of production:

- ProcessImplInstrumentationHelpers (CMDI/SHI RASP)
- FileIORaspHelper (LFI RASP) and URLSinkCallSite (SSRF RASP)
- AppSecEventTracker.dispatch()
- StoredCharBody.maybeNotifyAndBlock() (migrated from Groovy to Java)
- BlockResponseFunction's (TraceSegment, RBA) overload directly
- play-appsec-common PathExtractionHelpers (deliberate tripwire: documents
  the fail-closed behavior expected to flip after #12601's rebase)
- Play 2.5/2.6 ResultsStatus/StatusHeader advices and BodyParserHelpers
- vertx-web RoutingContextSessionAdvice, FileUploadHelper and the
  RoutingContextJsonResponseAdvice BODY_JSON integration path
- jax-rs-annotations-2.0 / jakarta-rs-annotations-3.0 MessageBodyWriter
- Ratpack JsonRendererAdvice BODY_JSON integration path

Also fixes FileIORaspHelperBlockingTest flakiness caused by pre-existing
Groovy specs in java-io-1.8 leaking a mocked FileIORaspHelper.INSTANCE
across the shared test JVM: the new test now saves and restores the real
singleton around each test case via reflection.
@jandro996 jandro996 added type: refactoring comp: asm waf Application Security Management (WAF) tag: no release notes Changes to exclude from release notes labels Sep 24, 2026
@jandro996

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-25T13:13:37.946243Z 836bdf6 Manual request
🔒 Security Review ✅ Completed 2026-09-25T13:13:12.185200Z 836bdf6 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 8c1b6c0203

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: 8c1b6c0203

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@datadog-prod-us1-6

This comment has been minimized.

@dd-octo-sts

dd-octo-sts Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

🟢 Java Benchmark SLOs — All performance SLOs passed

Suite Status
Startup 🟢 pass

SLO thresholds are defined here based on automatically generated metrics. A warning is raised when results are within 5% of the threshold.

PR vs. master results
Scenario Candidate master Δ (95% CI of mean)
startup:insecure-bank:iast:Agent 14.84 s 14.63 s [+0.5%; +2.4%] (maybe worse)
startup:insecure-bank:tracing:Agent 13.68 s 13.78 s [-1.6%; +0.1%] (no difference)
startup:petclinic:appsec:Agent 16.39 s 16.90 s [-7.2%; +1.2%] (no difference)
startup:petclinic:iast:Agent 16.89 s 16.95 s [-1.1%; +0.5%] (no difference)
startup:petclinic:profiling:Agent 16.51 s 16.90 s [-3.2%; -1.3%] (significantly better)
startup:petclinic:sca:Agent 16.54 s 16.24 s [-4.3%; +8.1%] (unstable)
startup:petclinic:tracing:Agent 16.14 s 16.02 s [-0.3%; +1.7%] (no difference)

Commit: a4b51044 · CI Pipeline · Benchmarking Platform UI


Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion.

…S pattern

- RoutingContextSessionAdviceTest -> RoutingContextSessionAdviceAppSecTest (vertx-web 3.4, 4.0)
- FileUploadHelperTest -> FileUploadHelperAppSecTest (vertx-web 3.4, 4.0, 5.0)
- MessageBodyWriterAdviceTest -> MessageBodyWriterAdviceAppSecTest (jakarta-rs-annotations-3.0, jax-rs-annotations-2.0)
Move the "test blocking on json response body" feature out of
RatpackHttpServerTest, VertxHttpServerForkedTest (4.0, 5.0) and PlayServerTest
(2.5, 2.6) into new *AppSec* test classes, so they match the CODEOWNERS
*AppSec* pattern without editing CODEOWNERS or renaming the shared,
general-purpose contract-test files.

The new classes extend the original test class to reuse its server bootstrap
and helpers, and are annotated with the new @ExcludeInheritedFeatures Spock
extension (utils/test-utils) so the ~22 inherited generic contract tests are
excluded at discovery time instead of re-running.
@jandro996 jandro996 added the tag: override groovy enforcement Override the "Enforce Groovy Migration" check label Sep 25, 2026
@jandro996

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: a93f057be8

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: a93f057be8

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- Add cleanup: blocks restoring original IG callbacks after reset()+registerCallback() in
  play-appsec-2.5/2.6 and vertx-web-3.4/4.0/5.0 AppSec tests, preventing state leak across
  tests in the same forked JVM
- Fix FQN inline okhttp3.Response -> import + Response in Play AppSec tests
- Add missing blank line between Spock blocks for consistency
@jandro996

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review · Automatically triggered

Security review completed. No security issues were found in this pull request.

Reviewed commit: 836bdf6e82

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 836bdf6e82

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- Rename local `request` variable to `req` in play-appsec-2.5 and
  play-appsec-2.6 PlayServerAppSecTest's multipart file upload test,
  which shadowed the inherited `request()` method once Spock's
  `where:` block hoisted the local variable declaration.
Local variable `request` shadowed the inherited request() method,
causing Groovy to desugar the call to request.call(args) on the null
local var. Unlike the earlier play-appsec fix, the trigger here is a
cleanup: block (not a where: block): sibling tests without cleanup:
using the same def request = request(...) pattern were unaffected.
Renamed to req in vertx-web-3.4/4.0/5.0.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: asm waf Application Security Management (WAF) tag: no release notes Changes to exclude from release notes tag: override groovy enforcement Override the "Enforce Groovy Migration" check type: refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant