You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "kusalk (via GitHub)" <gi...@apache.org> on 2023/03/02 04:08:52 UTC

[GitHub] [struts] kusalk commented on a diff in pull request #664: WW-5288 Make excluded package exemption logic more strict

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: issues-unsubscribe@struts.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org