[ 
https://issues.apache.org/jira/browse/WW-5626?focusedWorklogId=1018682&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1018682
 ]

ASF GitHub Bot logged work on WW-5626:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 05/May/26 04:20
            Start Date: 05/May/26 04:20
    Worklog Time Spent: 10m 
      Work Description: sonarqubecloud[bot] commented on PR #1674:
URL: https://github.com/apache/struts/pull/1674#issuecomment-4376506890

   ## [![Quality Gate 
Failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-failed-20px.png
 'Quality Gate 
Failed')](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=1674) 
**Quality Gate failed**  
   Failed conditions  
   
![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/failed-16px.png
 '') [65.2% Coverage on New 
Code](https://sonarcloud.io/component_measures?id=apache_struts&pullRequest=1674&metric=new_coverage&view=list)
 (required ≥ 80%)  
     
   [See analysis details on SonarQube 
Cloud](https://sonarcloud.io/dashboard?id=apache_struts&pullRequest=1674)
   
   




Issue Time Tracking
-------------------

    Worklog Id:     (was: 1018682)
    Time Spent: 50m  (was: 40m)

> Refactor JSON/REST @StrutsParameter enforcement to per-property authorization
> -----------------------------------------------------------------------------
>
>                 Key: WW-5626
>                 URL: https://issues.apache.org/jira/browse/WW-5626
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Plugin - JSON, Plugin - REST
>            Reporter: Lukasz Lenart
>            Assignee: Lukasz Lenart
>            Priority: Major
>             Fix For: 7.2.0
>
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
>   Follow-up to WW-5624. The initial fix enforces {{@StrutsParameter}} on 
> JSON/REST request bodies via post-hoc reflection — {{ContentTypeInterceptor}} 
> deserializes into a fresh instance, then recursively copies only authorized 
> properties. This works but has several drawbacks:
>   * ~250 lines of reflection-based copy logic in {{ContentTypeInterceptor}} 
> ({{copyAuthorizedProperties}}, {{deepCopyAuthorizedCollection}}, 
> {{deepCopyAuthorizedMap}}, {{deepCopyAuthorizedArray}})
>   * Requires a public no-arg constructor on target types; otherwise body 
> deserialization is rejected entirely
>   * Relies on a fragile package-name heuristic ({{isNestedBeanType}}) to 
> distinguish nested beans from leaf types — may misclassify third-party value 
> types
>   h2. Proposed solution
>   Replace the two-phase copy with per-property authorization performed 
> _during_ deserialization, so unauthorized fields are never set.
>   * New optional interface {{AuthorizationAwareContentTypeHandler}} extending 
> {{ContentTypeHandler}}, exposing a property-level authorization callback
>   * {{ContentTypeInterceptor}} checks {{instanceof}} and uses property-level 
> filtering when available; falls back to the existing two-phase copy for 
> handlers that don't implement it (backward compatible)
>   * Jackson handlers ({{JacksonJsonHandler}}, {{JacksonXmlHandler}}) register 
> a {{SimpleModule}} with a {{BeanDeserializerModifier}} that wraps each 
> {{SettableBeanProperty}} with an authorizing decorator, consulting 
> {{ParameterAuthorizer.isAuthorized(path, target, action)}} before 
> {{deserializeAndSet()}}
>   * {{XStreamHandler}} uses an equivalent mechanism (e.g. 
> {{xstream.omitField()}} pre-pass or a custom {{ReflectionConverter}})
>   * Authorization context propagated via {{ThreadLocal}}, consistent with the 
> existing {{ActionContext}} pattern
>   h2. Cleanup also included
>   Minor follow-ups from the WW-5624 review:
>   * Remove redundant {{ModelDriven}} resolution in 
> {{ParametersInterceptor.isParameterAnnotatedAndAllowlist}} (now handled by 
> {{StrutsParameterAuthorizer}})
>   * Replace mock-based REST integration tests with real 
> {{JacksonJsonHandler}} tests that assert actual property filtering behavior
>   * Guard the unchecked {{String}} cast on JSON map keys in 
> {{JSONInterceptor.filterUnauthorizedKeysRecursive}}
>   h2. Outcome
>   * Removes ~200 lines of reflection-based copy logic
>   * Lifts the no-arg constructor requirement
>   * Authorization happens at the right layer (the deserializer), matching 
> {{ParametersInterceptor}}'s per-parameter check semantics



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to