[
https://issues.apache.org/jira/browse/WW-5761?focusedWorklogId=1056515&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1056515
]
ASF GitHub Bot logged work on WW-5761:
--------------------------------------
Author: ASF GitHub Bot
Created on: 22/Nov/26 14:12
Start Date: 22/Nov/26 14:12
Worklog Time Spent: 10m
Work Description: lukaszlenart commented on code in PR #2109:
URL: https://github.com/apache/struts/pull/2109#discussion_r4658446727
##########
core/src/main/java/org/apache/struts2/interceptor/parameter/StrutsParameterMemberGuard.java:
##########
@@ -0,0 +1,125 @@
+/*
+ * 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 org.apache.struts2.interceptor.parameter;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.Collection;
+
+import static java.lang.String.format;
+import static org.apache.struts2.util.DebugUtils.notifyDeveloperOfError;
+
+/**
+ * The guard {@link StrutsParameterAuthorizer#memberGuard} creates for one
parameter. Only objects standing in the
+ * value stack root are judged, since a deeper object is reached through a
root member whose annotation depth already
+ * covers it, and the {@link org.apache.struts2.ModelDriven} model is exempt
by identity as it is in
+ * {@link StrutsParameterAuthorizer#isAuthorized}.
+ *
+ * @since 7.6.0
+ */
+final class StrutsParameterMemberGuard implements ParameterMemberGuard {
+
+ private static final Logger LOG =
LogManager.getLogger(StrutsParameterMemberGuard.class);
+
+ private final StrutsParameterAuthorizer authorizer;
+ private final long paramDepth;
+ private final Object exemptModel;
+ private final Collection<?> root;
+ private final boolean devMode;
+ private Object authorizedOwner;
+ private String authorizedProperty;
+
+ StrutsParameterMemberGuard(StrutsParameterAuthorizer authorizer, long
paramDepth, Object exemptModel,
+ Collection<?> root, boolean devMode) {
+ this.authorizer = authorizer;
+ this.paramDepth = paramDepth;
+ this.exemptModel = exemptModel;
+ this.root = root;
+ this.devMode = devMode;
+ }
+
+ @Override
+ public boolean permits(Object owner, Member member, String propertyName) {
+ if (owner == null || owner == exemptModel ||
root.stream().noneMatch(candidate -> candidate == owner)) {
+ return true;
+ }
+ if (isCreatingMissingRoot(owner, member, propertyName)) {
+ return true;
+ }
+ if (!isResolvedMemberAuthorized(owner, member, propertyName)) {
+ String logMessage = format(
+ "Parameter injection through member [%s] on target [%s]
rejected. Ensure it is annotated with @StrutsParameter with an appropriate
'depth'.",
+ member.getName(),
+ member.getDeclaringClass().getName());
+ if (devMode) {
+ notifyDeveloperOfError(LOG, owner, logMessage);
+ } else {
+ LOG.debug(logMessage);
+ }
+ return false;
Review Comment:
Returning `false` here refuses this one member, but not the parameter.
`CompoundRootAccessor` then moves on to the next root object, and a `Map`
further down (e.g. one left by a chain result) stores the value through
`put()`, which never goes through `isAccessible`. So a value the guard refused
can still end up bound.
Suggestion: once the guard has refused a member for a parameter, refuse the
whole parameter (record it on the guard and have `applyParametersOnStack` skip
it), or document that a `Map` in the root is outside what the guard covers.
##########
core/src/main/java/org/apache/struts2/interceptor/parameter/StrutsParameterMemberGuard.java:
##########
@@ -0,0 +1,125 @@
+/*
+ * 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 org.apache.struts2.interceptor.parameter;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.Collection;
+
+import static java.lang.String.format;
+import static org.apache.struts2.util.DebugUtils.notifyDeveloperOfError;
+
+/**
+ * The guard {@link StrutsParameterAuthorizer#memberGuard} creates for one
parameter. Only objects standing in the
+ * value stack root are judged, since a deeper object is reached through a
root member whose annotation depth already
+ * covers it, and the {@link org.apache.struts2.ModelDriven} model is exempt
by identity as it is in
+ * {@link StrutsParameterAuthorizer#isAuthorized}.
+ *
+ * @since 7.6.0
+ */
+final class StrutsParameterMemberGuard implements ParameterMemberGuard {
+
+ private static final Logger LOG =
LogManager.getLogger(StrutsParameterMemberGuard.class);
+
+ private final StrutsParameterAuthorizer authorizer;
+ private final long paramDepth;
+ private final Object exemptModel;
+ private final Collection<?> root;
+ private final boolean devMode;
+ private Object authorizedOwner;
+ private String authorizedProperty;
+
+ StrutsParameterMemberGuard(StrutsParameterAuthorizer authorizer, long
paramDepth, Object exemptModel,
+ Collection<?> root, boolean devMode) {
+ this.authorizer = authorizer;
+ this.paramDepth = paramDepth;
+ this.exemptModel = exemptModel;
+ this.root = root;
+ this.devMode = devMode;
+ }
+
+ @Override
+ public boolean permits(Object owner, Member member, String propertyName) {
+ if (owner == null || owner == exemptModel ||
root.stream().noneMatch(candidate -> candidate == owner)) {
Review Comment:
With the flag on, a valid nested parameter can be dropped when the nested
object is also in the stack root. The guard treats any root object as the start
of the path and checks its setter against the full `paramDepth`, even when OGNL
reached it through an annotated getter.
Example: a non-ModelDriven action has `@StrutsParameter(depth = 1)
getHelper()`, and `prepare()` or an interceptor also pushed that same `helper`
onto the stack. `helper.name=x` passes `isAuthorized` (the getter has depth 1),
then OGNL calls `helper.setName`. The owner is in the root and `setName` has no
depth >= 1 annotation, so the guard returns `false` and the value is silently
not bound.
Suggestion: apply the depth check only to the first member resolved (the
root segment), or follow the OGNL path instead of testing whether the owner is
in the root. A test pushing the nested object onto the stack would cover it.
##########
core/src/main/java/org/apache/struts2/ognl/SecurityMemberAccess.java:
##########
@@ -25,6 +25,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsConstants;
import org.apache.struts2.inject.Inject;
+import org.apache.struts2.interceptor.parameter.ParameterMemberGuard;
Review Comment:
This adds a package cycle: `ognl` (and `util.MemberAccessValueStack`) now
import `interceptor.parameter.ParameterMemberGuard`, while
`interceptor.parameter.StrutsParameterAuthorizer` already depends on `ognl`.
Moving `ParameterMemberGuard` into `org.apache.struts2.ognl`, next to the
member-access types it plugs into, would keep the dependency one-way.
##########
core/src/main/java/org/apache/struts2/interceptor/parameter/StrutsParameterMemberGuard.java:
##########
@@ -0,0 +1,125 @@
+/*
+ * 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 org.apache.struts2.interceptor.parameter;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.Collection;
+
+import static java.lang.String.format;
+import static org.apache.struts2.util.DebugUtils.notifyDeveloperOfError;
+
+/**
+ * The guard {@link StrutsParameterAuthorizer#memberGuard} creates for one
parameter. Only objects standing in the
+ * value stack root are judged, since a deeper object is reached through a
root member whose annotation depth already
+ * covers it, and the {@link org.apache.struts2.ModelDriven} model is exempt
by identity as it is in
+ * {@link StrutsParameterAuthorizer#isAuthorized}.
+ *
+ * @since 7.6.0
+ */
+final class StrutsParameterMemberGuard implements ParameterMemberGuard {
+
+ private static final Logger LOG =
LogManager.getLogger(StrutsParameterMemberGuard.class);
+
+ private final StrutsParameterAuthorizer authorizer;
+ private final long paramDepth;
+ private final Object exemptModel;
+ private final Collection<?> root;
+ private final boolean devMode;
+ private Object authorizedOwner;
+ private String authorizedProperty;
+
+ StrutsParameterMemberGuard(StrutsParameterAuthorizer authorizer, long
paramDepth, Object exemptModel,
+ Collection<?> root, boolean devMode) {
+ this.authorizer = authorizer;
+ this.paramDepth = paramDepth;
+ this.exemptModel = exemptModel;
+ this.root = root;
+ this.devMode = devMode;
+ }
+
+ @Override
+ public boolean permits(Object owner, Member member, String propertyName) {
+ if (owner == null || owner == exemptModel ||
root.stream().noneMatch(candidate -> candidate == owner)) {
+ return true;
+ }
+ if (isCreatingMissingRoot(owner, member, propertyName)) {
+ return true;
+ }
+ if (!isResolvedMemberAuthorized(owner, member, propertyName)) {
+ String logMessage = format(
+ "Parameter injection through member [%s] on target [%s]
rejected. Ensure it is annotated with @StrutsParameter with an appropriate
'depth'.",
+ member.getName(),
+ member.getDeclaringClass().getName());
+ if (devMode) {
+ notifyDeveloperOfError(LOG, owner, logMessage);
+ } else {
+ LOG.debug(logMessage);
+ }
+ return false;
+ }
+ authorizedOwner = owner;
+ authorizedProperty = propertyName;
+ return true;
+ }
+
+ /**
+ * A nested parameter whose root getter returned {@code null} makes the
null handler create that object and store
+ * it through the setter. That setter takes a new instance, never the
request value, and the annotation of a nested
+ * parameter belongs on the getter, so having passed the getter is what
authorizes it.
+ */
+ private boolean isCreatingMissingRoot(Object owner, Member member, String
propertyName) {
+ return paramDepth > 0
+ && owner == authorizedOwner
+ && propertyName != null
+ && propertyName.equals(authorizedProperty)
+ && member instanceof Method method
+ && method.getParameterCount() == 1;
+ }
+
+ /**
+ * Whether {@code member}, which OGNL resolved on {@code owner}, may be
used for a parameter of this depth. Three
+ * things authorize it, matching {@link
StrutsParameterAuthorizer#hasValidAnnotatedMember}: its own annotation, the
+ * annotation of an overload or of the proxied class's method of that
name, and the annotation of a public field of
+ * that property.
+ */
+ private boolean isResolvedMemberAuthorized(Object owner, Member member,
String propertyName) {
+ if (member instanceof AnnotatedElement element &&
authorizer.getPermittedInjectionDepth(element) >= paramDepth) {
+ return true;
+ }
+ Class<?> ownerClass = authorizer.ultimateClass(owner);
+ if (member instanceof Method method &&
Arrays.stream(ownerClass.getMethods())
+ .anyMatch(candidate ->
candidate.getName().equals(method.getName())
+ && candidate.getParameterCount() ==
method.getParameterCount()
+ && !Modifier.isStatic(candidate.getModifiers())
+ && authorizer.getPermittedInjectionDepth(candidate) >=
paramDepth)) {
+ return true;
+ }
+ return propertyName != null && Arrays.stream(ownerClass.getFields())
Review Comment:
`isAuthorized` decapitalizes the name (`Introspector.decapitalize`) before
looking up the field, but this compares OGNL's raw `propertyName`. With an
annotated public field `fieldBacked` and an unannotated setter, `FieldBacked=x`
is approved by `isAuthorized` and then refused here. Decapitalizing
`propertyName` before the comparison would keep the two in sync.
##########
core/src/main/java/org/apache/struts2/interceptor/parameter/ParametersInterceptor.java:
##########
@@ -325,14 +338,27 @@ protected HttpParameters
initNewHttpParameters(HttpParameters parameters) {
}
protected void applyParametersOnStack(ValueStack stack, Map<String,
Parameter> parameters, Object action) {
- for (Map.Entry<String, Parameter> entry : parameters.entrySet()) {
- try {
- stack.setParameter(entry.getKey(),
entry.getValue().getObject());
- } catch (RuntimeException e) {
- if (devMode) {
- notifyDeveloperParameterException(action, entry.getKey(),
e.getMessage());
+ MemberAccessValueStack guardedStack = requireAnnotations &&
requireAnnotationsOnResolvedMember
Review Comment:
When the flag is on but the stack is not a `MemberAccessValueStack`, the
guard is silently skipped. The same happens with a custom
`MemberAccessValueStack` that doesn't override `useParameterMemberGuard`, since
the default method does nothing. Someone setting
`struts.parameters.requireAnnotations.enforceOnResolvedMember=true` gets no
guard and no hint. Could we log a warning once in that case, or make
`useParameterMemberGuard` abstract?
##########
core/src/main/java/org/apache/struts2/interceptor/parameter/StrutsParameterMemberGuard.java:
##########
@@ -0,0 +1,125 @@
+/*
+ * 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 org.apache.struts2.interceptor.parameter;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.Collection;
+
+import static java.lang.String.format;
+import static org.apache.struts2.util.DebugUtils.notifyDeveloperOfError;
+
+/**
+ * The guard {@link StrutsParameterAuthorizer#memberGuard} creates for one
parameter. Only objects standing in the
+ * value stack root are judged, since a deeper object is reached through a
root member whose annotation depth already
+ * covers it, and the {@link org.apache.struts2.ModelDriven} model is exempt
by identity as it is in
+ * {@link StrutsParameterAuthorizer#isAuthorized}.
+ *
+ * @since 7.6.0
+ */
+final class StrutsParameterMemberGuard implements ParameterMemberGuard {
+
+ private static final Logger LOG =
LogManager.getLogger(StrutsParameterMemberGuard.class);
+
+ private final StrutsParameterAuthorizer authorizer;
+ private final long paramDepth;
+ private final Object exemptModel;
+ private final Collection<?> root;
+ private final boolean devMode;
+ private Object authorizedOwner;
+ private String authorizedProperty;
+
+ StrutsParameterMemberGuard(StrutsParameterAuthorizer authorizer, long
paramDepth, Object exemptModel,
+ Collection<?> root, boolean devMode) {
+ this.authorizer = authorizer;
+ this.paramDepth = paramDepth;
+ this.exemptModel = exemptModel;
+ this.root = root;
+ this.devMode = devMode;
+ }
+
+ @Override
+ public boolean permits(Object owner, Member member, String propertyName) {
+ if (owner == null || owner == exemptModel ||
root.stream().noneMatch(candidate -> candidate == owner)) {
+ return true;
+ }
+ if (isCreatingMissingRoot(owner, member, propertyName)) {
+ return true;
+ }
+ if (!isResolvedMemberAuthorized(owner, member, propertyName)) {
+ String logMessage = format(
+ "Parameter injection through member [%s] on target [%s]
rejected. Ensure it is annotated with @StrutsParameter with an appropriate
'depth'.",
+ member.getName(),
+ member.getDeclaringClass().getName());
+ if (devMode) {
+ notifyDeveloperOfError(LOG, owner, logMessage);
Review Comment:
OGNL calls `isAccessible` several times per member (`hasSetProperty`, then
`setMethodValue` / `callAppropriateMethod`), and for each root object it walks
past, so one refused parameter adds two or more identical action errors in
devMode. Notifying at most once per guard instance (a boolean field) would
avoid the duplicates.
##########
core/src/main/java/org/apache/struts2/interceptor/parameter/StrutsParameterMemberGuard.java:
##########
@@ -0,0 +1,125 @@
+/*
+ * 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 org.apache.struts2.interceptor.parameter;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.lang.reflect.AnnotatedElement;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.Collection;
+
+import static java.lang.String.format;
+import static org.apache.struts2.util.DebugUtils.notifyDeveloperOfError;
+
+/**
+ * The guard {@link StrutsParameterAuthorizer#memberGuard} creates for one
parameter. Only objects standing in the
+ * value stack root are judged, since a deeper object is reached through a
root member whose annotation depth already
+ * covers it, and the {@link org.apache.struts2.ModelDriven} model is exempt
by identity as it is in
+ * {@link StrutsParameterAuthorizer#isAuthorized}.
+ *
+ * @since 7.6.0
+ */
+final class StrutsParameterMemberGuard implements ParameterMemberGuard {
+
+ private static final Logger LOG =
LogManager.getLogger(StrutsParameterMemberGuard.class);
+
+ private final StrutsParameterAuthorizer authorizer;
+ private final long paramDepth;
+ private final Object exemptModel;
+ private final Collection<?> root;
+ private final boolean devMode;
+ private Object authorizedOwner;
+ private String authorizedProperty;
+
+ StrutsParameterMemberGuard(StrutsParameterAuthorizer authorizer, long
paramDepth, Object exemptModel,
+ Collection<?> root, boolean devMode) {
+ this.authorizer = authorizer;
+ this.paramDepth = paramDepth;
+ this.exemptModel = exemptModel;
+ this.root = root;
+ this.devMode = devMode;
+ }
+
+ @Override
+ public boolean permits(Object owner, Member member, String propertyName) {
+ if (owner == null || owner == exemptModel ||
root.stream().noneMatch(candidate -> candidate == owner)) {
+ return true;
+ }
+ if (isCreatingMissingRoot(owner, member, propertyName)) {
+ return true;
+ }
+ if (!isResolvedMemberAuthorized(owner, member, propertyName)) {
+ String logMessage = format(
+ "Parameter injection through member [%s] on target [%s]
rejected. Ensure it is annotated with @StrutsParameter with an appropriate
'depth'.",
+ member.getName(),
+ member.getDeclaringClass().getName());
+ if (devMode) {
+ notifyDeveloperOfError(LOG, owner, logMessage);
+ } else {
+ LOG.debug(logMessage);
+ }
+ return false;
+ }
+ authorizedOwner = owner;
+ authorizedProperty = propertyName;
+ return true;
+ }
+
+ /**
+ * A nested parameter whose root getter returned {@code null} makes the
null handler create that object and store
+ * it through the setter. That setter takes a new instance, never the
request value, and the annotation of a nested
+ * parameter belongs on the getter, so having passed the getter is what
authorizes it.
+ */
+ private boolean isCreatingMissingRoot(Object owner, Member member, String
propertyName) {
Review Comment:
This lets through any one-argument method with the authorized property name
on the same owner, without confirming it is the null handler storing a new
instance. Could it also require a `set` prefix and a parameter type assignable
from the getter's return type? Alternatively, mark null-handler creation
explicitly via `ReflectionContextState`.
Issue Time Tracking
-------------------
Worklog Id: (was: 1056515)
Time Spent: 40m (was: 0.5h)
> Enforce @StrutsParameter on the member OGNL resolves during parameter binding
> -----------------------------------------------------------------------------
>
> Key: WW-5761
> URL: https://issues.apache.org/jira/browse/WW-5761
> Project: Struts 2
> Issue Type: Improvement
> Components: Core
> Reporter: Lukasz Lenart
> Priority: Major
> Fix For: 7.6.0
>
> Time Spent: 40m
> Remaining Estimate: 0h
>
> {{@StrutsParameter}} is enforced once, before OGNL runs:
> {{StrutsParameterAuthorizer}} takes the parameter name and predicts which
> accessor or field OGNL will go through, then checks that member for the
> annotation. {{SecurityMemberAccess}}, which OGNL consults for every member it
> actually touches, does not know about the annotation at all.
> Every time OGNL's resolution rules and the prediction drift apart, the
> authorizer has to be taught again:
> * WW-5709: fluent (non-void) setters, which {{java.beans}} does not treat as
> write methods but OGNL binds through
> * WW-5759: OGNL 3.4.14's JavaBeans-style accessor names ({{setuRange}} before
> {{setURange}}), and getters whose {{java.beans}} property name differs from
> the name OGNL reaches them by ({{getURL()}})
> The prediction is a hand-written copy of OGNL internals
> ({{accessorBaseNames}}, set/is/get order, overload choice), so the next OGNL
> change to name resolution needs the same follow-up.
> h3. Proposal
> Enforce the annotation where OGNL resolves the member, during parameter
> binding only.
> Binding already runs on its own value stack
> ({{ParametersInterceptor.toNewStack}}). Its {{SecurityMemberAccess}} already
> receives binding-only settings ({{useAcceptProperties}} /
> {{useExcludeProperties}} via {{MemberAccessValueStack}}). A binding mode on
> that instance could require {{@StrutsParameter}} on the actual
> {{Method}}/{{Field}} OGNL is about to use on the action, whatever name it was
> reached by. The authorizer's prediction would remain a fast pre-check and
> would no longer be the only gate.
> h3. Open design questions
> * *Depth*: {{isAccessible}} sees one member at a time, not its position in
> the expression. The required {{depth}} of the root getter is known only to
> the caller, so it has to be tracked per binding (e.g. the authorizer records
> the authorized root and depth in the binding context).
> * *ModelDriven*: model members are exempt, so {{SecurityMemberAccess}} needs
> to know which object is the model, by identity, as
> {{StrutsParameterAuthorizer.resolveTarget}} already does.
> * *Paths that never call {{isAccessible}}*: Map-backed models and custom
> {{PropertyAccessor}}s keep relying on the authorizer.
> * *Transition mode, {{ParameterNameAware}}, the JSON/REST deserialization
> paths* (WW-5624) and {{CookieInterceptor}} (WW-5627) share
> {{ParameterAuthorizer}} and need a consistent story.
> * *Cost*: an annotation lookup per member access during binding; cacheable
> per {{Member}}.
> Fits 8.0.0 together with the other {{SecurityMemberAccess}} changes (WW-5678)
> and the OGNL 3.5 upgrade (WW-5326).
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)