|
19 | 19 | package org.apache.struts2.interceptor.parameter;
|
20 | 20 |
|
21 | 21 | import org.apache.commons.lang3.BooleanUtils;
|
22 |
| -import org.apache.commons.lang3.ClassUtils; |
23 | 22 | import org.apache.logging.log4j.LogManager;
|
24 | 23 | import org.apache.logging.log4j.Logger;
|
25 | 24 | import org.apache.struts2.ActionContext;
|
@@ -358,9 +357,8 @@ protected boolean isParameterAnnotatedAndAllowlist(String name, Object action) {
|
358 | 357 | long paramDepth = name.codePoints().mapToObj(c -> (char) c).filter(NESTING_CHARS::contains).count();
|
359 | 358 |
|
360 | 359 | if (action instanceof ModelDriven<?> && !ActionContext.getContext().getValueStack().peek().equals(action)) {
|
361 |
| - LOG.debug("Model driven Action detected, exempting from @StrutsParameter annotation requirement and OGNL allowlisting model type"); |
362 |
| - // (Exempted by annotation on org.apache.struts2.ModelDriven#getModel) |
363 |
| - return hasValidAnnotatedMember("model", action, paramDepth + 1); |
| 360 | + LOG.debug("Model driven Action detected, exempting from @StrutsParameter annotation requirement"); |
| 361 | + return true; |
364 | 362 | }
|
365 | 363 |
|
366 | 364 | if (requireAnnotationsTransitionMode && paramDepth == 0) {
|
@@ -447,15 +445,13 @@ protected void allowlistParameterizedTypeArg(Type genericType) {
|
447 | 445 | }
|
448 | 446 |
|
449 | 447 | protected void allowlistParamType(Type paramType) {
|
450 |
| - if (paramType instanceof Class) { |
451 |
| - allowlistClass((Class<?>) paramType); |
| 448 | + if (paramType instanceof Class<?> clazz) { |
| 449 | + allowlistClass(clazz); |
452 | 450 | }
|
453 | 451 | }
|
454 | 452 |
|
455 | 453 | protected void allowlistClass(Class<?> clazz) {
|
456 |
| - threadAllowlist.allowClass(clazz); |
457 |
| - ClassUtils.getAllSuperclasses(clazz).forEach(threadAllowlist::allowClass); |
458 |
| - ClassUtils.getAllInterfaces(clazz).forEach(threadAllowlist::allowClass); |
| 454 | + threadAllowlist.allowClassHierarchy(clazz); |
459 | 455 | }
|
460 | 456 |
|
461 | 457 | protected boolean hasValidAnnotatedField(Object action, String fieldName, long paramDepth) {
|
@@ -527,10 +523,11 @@ protected Class<?> ultimateClass(Object action) {
|
527 | 523 | }
|
528 | 524 |
|
529 | 525 | protected BeanInfo getBeanInfo(Object action) {
|
| 526 | + Class<?> actionClass = ultimateClass(action); |
530 | 527 | try {
|
531 |
| - return ognlUtil.getBeanInfo(ultimateClass(action)); |
| 528 | + return ognlUtil.getBeanInfo(actionClass); |
532 | 529 | } catch (IntrospectionException e) {
|
533 |
| - LOG.warn("Error introspecting Action {} for parameter injection validation", action.getClass(), e); |
| 530 | + LOG.warn("Error introspecting Action {} for parameter injection validation", actionClass, e); |
534 | 531 | return null;
|
535 | 532 | }
|
536 | 533 | }
|
|
0 commit comments