kusalk commented on code in PR #664:
URL: https://github.com/apache/struts/pull/664#discussion_r1122577804
##########
core/src/main/java/com/opensymphony/xwork2/ognl/SecurityMemberAccess.java:
##########
@@ -197,51 +208,61 @@ protected boolean checkEnumAccess(Object target, Member
member) {
return false;
}
- protected boolean isPackageExcluded(Package targetPackage, Package
memberPackage) {
- if (targetPackage == null || memberPackage == null) {
- LOG.warn("The use of the default (unnamed) package is
discouraged!");
+ protected boolean isPackageExcluded(Class<?> targetClass, Class<?>
memberClass) {
+ if (targetClass == null || memberClass == null) {
+ throw new IllegalArgumentException(
+ "Parameters should never be null - if member is static,
targetClass should be the same as memberClass.");
}
- String targetPackageName = targetPackage == null ? "" :
targetPackage.getName();
- String memberPackageName = memberPackage == null ? "" :
memberPackage.getName();
+ Set<Class<?>> classesToCheck = new HashSet<>();
+ classesToCheck.add(targetClass);
+ classesToCheck.add(memberClass);
- for (Pattern pattern : excludedPackageNamePatterns) {
- if (pattern.matcher(targetPackageName).matches() ||
pattern.matcher(memberPackageName).matches()) {
+ for (Class<?> clazz : classesToCheck) {
+ if (!isExcludedPackageExempt(clazz) &&
(isExcludedPackageNamePatterns(clazz) || isExcludedPackageNames(clazz))) {
Review Comment:
Exemption must now exist for both classes (target and member) if they both
match a banned package
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]