File tree Expand file tree Collapse file tree
its/autoscan/src/test/resources/autoscan/diffs
java-checks-test-sources/default
src/main/java/checks/security
java-checks/src/main/java/org/sonar/java/checks/security Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "ruleKey" : " S5804" ,
33 "hasTruePositives" : false ,
4- "falseNegatives" : 9 ,
4+ "falseNegatives" : 11 ,
55 "falsePositives" : 0
6- }
6+ }
Original file line number Diff line number Diff line change 206206 <type >jar</type >
207207 <scope >provided</scope >
208208 </dependency >
209+ <dependency >
210+ <groupId >org.springframework.security</groupId >
211+ <artifactId >spring-security-ldap</artifactId >
212+ <version >6.2.3</version >
213+ </dependency >
209214 <dependency >
210215 <groupId >org.springframework</groupId >
211216 <artifactId >spring-aop</artifactId >
Original file line number Diff line number Diff line change 1212import org .springframework .security .core .userdetails .UserDetailsService ;
1313import org .springframework .security .core .userdetails .UsernameNotFoundException ;
1414import org .springframework .security .crypto .bcrypt .BCryptPasswordEncoder ;
15+ import org .springframework .security .ldap .authentication .LdapAuthenticationProvider ;
1516
1617public class UserEnumerationCheck {
1718
@@ -93,6 +94,13 @@ public void config() {
9394 throw new UsernameNotFoundException ("userName not found" ); // Noncompliant
9495 }
9596
97+ void ldap (LdapAuthenticationProvider ldapAuthenticationProvider ) {
98+ ldapAuthenticationProvider .setHideUserNotFoundExceptions (false ); // Noncompliant
99+ ldapAuthenticationProvider .setHideUserNotFoundExceptions (MY_CONSTANT ); // Noncompliant
100+ boolean variableFalse = false ;
101+ ldapAuthenticationProvider .setHideUserNotFoundExceptions (variableFalse ); // Compliant, not a constant
102+ }
103+
96104 public void compliantConfig () {
97105 boolean b = false ;
98106
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ public class UserEnumerationCheck extends IssuableSubscriptionVisitor {
4141
4242 private static final String MESSAGE = "Make sure allowing user enumeration is safe here." ;
4343 private static final String ABSTRACT_USER_DETAILS_AUTHENTICATION_PROVIDER = "org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider" ;
44+ private static final String SPRING_SEC_LDAP_AUTHENTICATION_PROVIDER = "org.springframework.security.ldap.authentication.LdapAuthenticationProvider" ;
4445 private static final String USER_DETAILS_SERVICE = "org.springframework.security.core.userdetails.UserDetailsService" ;
4546 private static final String USERNAME_NOT_FOUND_EXCEPTION = "org.springframework.security.core.userdetails.UsernameNotFoundException" ;
4647 private static final String HIDE_USER_NOT_FOUND_EXCEPTIONS = "setHideUserNotFoundExceptions" ;
@@ -52,7 +53,7 @@ public class UserEnumerationCheck extends IssuableSubscriptionVisitor {
5253 private final Deque <MethodTree > stack = new ArrayDeque <>();
5354
5455 private static final MethodMatchers SET_HIDE_USER_MATCHER = MethodMatchers .create ()
55- .ofSubTypes (ABSTRACT_USER_DETAILS_AUTHENTICATION_PROVIDER )
56+ .ofSubTypes (ABSTRACT_USER_DETAILS_AUTHENTICATION_PROVIDER , SPRING_SEC_LDAP_AUTHENTICATION_PROVIDER )
5657 .names (HIDE_USER_NOT_FOUND_EXCEPTIONS )
5758 .addParametersMatcher (BOOLEAN )
5859 .build ();
You can’t perform that action at this time.
0 commit comments