Skip to content

WW-5631 Add opt-in @StrutsParameter enforcement to ChainingInterceptor#1719

Open
lukaszlenart wants to merge 9 commits into
mainfrom
WW-5631-chaining-require-annotations
Open

WW-5631 Add opt-in @StrutsParameter enforcement to ChainingInterceptor#1719
lukaszlenart wants to merge 9 commits into
mainfrom
WW-5631-chaining-require-annotations

Conversation

@lukaszlenart
Copy link
Copy Markdown
Member

Summary

Adds an opt-in flag struts.chaining.requireAnnotations (default false) that makes ChainingInterceptor only copy a property to the target action when that property's target member is authorized by @StrutsParameter, reusing the shared ParameterAuthorizer.

  • @StrutsParameter gates the HTTP-request-parameter channel via ParametersInterceptor; action chaining is a separate, developer-configured channel that copies properties between actions regardless of annotations. Some applications would prefer chaining to respect the same annotation boundary.
  • When the flag is false (default), behaviour and cost are unchanged — fully backward compatible.
  • When true, unauthorized target properties are skipped and logged at WARN. Enforcement reuses ParameterAuthorizer, so requireAnnotations, transitionMode and depth semantics stay consistent with ParametersInterceptor.
  • Fail-closed: if the target action cannot be introspected, nothing is copied for that object.
  • Global constant only (no per-interceptor-ref override). Targets main (7.2.0).

Fixes WW-5631

Changes

  • New constant StrutsConstants.STRUTS_CHAINING_REQUIRE_ANNOTATIONS and default.properties entry (default false).
  • ChainingInterceptor enforces @StrutsParameter on the target when enabled (excludes-based gating, so includes still works).
  • Updated ChainingInterceptor JavaDoc.

Test Plan

  • mvn test -DskipAssembly -pl core -Dtest=ChainingInterceptorTest — 14/14 pass
  • mvn test -DskipAssembly -pl core -Dtest='ChainingInterceptor*,ParametersInterceptorTest' — 49/49 pass
  • Covered: flag off (legacy copy), flag on + annotated target (copied), flag on + unannotated target (skipped + WARN), transition mode (depth-0 copied), global requireAnnotations=false (no-op), includes interaction, proxied target class resolution, fail-closed on introspection failure.

🤖 Generated with Claude Code

lukaszlenart and others added 9 commits May 27, 2026 08:54
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…leanUtils

Use BooleanUtils.toBoolean for the chaining requireAnnotations flag so it
accepts the same values (yes/on/1) as the sibling
struts.parameters.requireAnnotations switch, and unify the enforcement WARN
message prefix.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…et==action

Add a test asserting nothing is copied when the target action cannot be
introspected (fail-closed), and document why isAuthorized is called with
target == action for chaining (no ModelDriven exemption).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@lukaszlenart lukaszlenart force-pushed the WW-5631-chaining-require-annotations branch from a1740a4 to ab5b25f Compare May 27, 2026 06:54
@sonarqubecloud
Copy link
Copy Markdown

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