WW-5343 Address SonarCloud code smells

This commit is contained in:
Kusal Kithul-Godage
2023-11-26 17:02:34 +11:00
parent 85d2c742cd
commit 7929d8634c
3 changed files with 12 additions and 1 deletions
@@ -161,6 +161,7 @@ public class OgnlUtil {
*/
@Deprecated
protected void setExcludedClasses(String commaDelimitedClasses) {
// Must be set directly on SecurityMemberAccess
}
@Inject(value = StrutsConstants.STRUTS_DEV_MODE_EXCLUDED_CLASSES, required = false)
@@ -173,6 +174,7 @@ public class OgnlUtil {
*/
@Deprecated
protected void setExcludedPackageNamePatterns(String commaDelimitedPackagePatterns) {
// Must be set directly on SecurityMemberAccess
}
@Inject(value = StrutsConstants.STRUTS_DEV_MODE_EXCLUDED_PACKAGE_NAME_PATTERNS, required = false)
@@ -185,6 +187,7 @@ public class OgnlUtil {
*/
@Deprecated
protected void setExcludedPackageNames(String commaDelimitedPackageNames) {
// Must be set directly on SecurityMemberAccess
}
@Inject(value = StrutsConstants.STRUTS_DEV_MODE_EXCLUDED_PACKAGE_NAMES, required = false)
@@ -197,6 +200,7 @@ public class OgnlUtil {
*/
@Deprecated
public void setExcludedPackageExemptClasses(String commaDelimitedClasses) {
// Must be set directly on SecurityMemberAccess
}
@Inject(value = StrutsConstants.STRUTS_DEV_MODE_EXCLUDED_PACKAGE_EXEMPT_CLASSES, required = false)
@@ -246,6 +250,7 @@ public class OgnlUtil {
*/
@Deprecated
protected void setAllowStaticFieldAccess(String allowStaticFieldAccess) {
// Must be set directly on SecurityMemberAccess
}
/**
@@ -253,6 +258,7 @@ public class OgnlUtil {
*/
@Deprecated
protected void setDisallowProxyMemberAccess(String disallowProxyMemberAccess) {
// Must be set directly on SecurityMemberAccess
}
/**
@@ -260,6 +266,7 @@ public class OgnlUtil {
*/
@Deprecated
protected void setDisallowDefaultPackageAccess(String disallowDefaultPackageAccess) {
// Must be set directly on SecurityMemberAccess
}
/**
@@ -34,6 +34,9 @@ import static org.apache.commons.lang3.StringUtils.strip;
public class ConfigParseUtil {
private ConfigParseUtil() {
}
public static Set<String> toClassesSet(String newDelimitedClasses) throws ConfigurationException {
Set<String> classNames = commaDelimitedStringToSet(newDelimitedClasses);
validateClasses(classNames, OgnlUtil.class.getClassLoader());
@@ -95,7 +95,8 @@ public class SecurityMemberAccessTest {
Collection<String> fieldVal = reflectField(field);
assertThrows(UnsupportedOperationException.class, () -> fieldVal.add("foo"));
if (!fieldVal.isEmpty()) {
assertThrows(UnsupportedOperationException.class, () -> fieldVal.remove(fieldVal.iterator().next()));
String firstVal = fieldVal.iterator().next();
assertThrows(UnsupportedOperationException.class, () -> fieldVal.remove(firstVal));
assertThrows(UnsupportedOperationException.class, fieldVal::clear);
}
}