mirror of
https://github.com/github/codeql.git
synced 2026-04-26 17:25:19 +02:00
Java: handle example in Spring docs
This commit is contained in:
@@ -142,5 +142,14 @@ predicate permitsSpringBootActuators(PermitAllCall permitAllCall) {
|
||||
registryRequestMatchersCall.getQualifier() = authorizeCall and
|
||||
permitAllCall.getQualifier() = registryRequestMatchersCall
|
||||
)
|
||||
or
|
||||
exists(Variable v, MatcherCall matcherCall |
|
||||
// http.securityMatcher(EndpointRequest.toAnyEndpoint());
|
||||
// http.authorizeRequests([...].permitAll())
|
||||
v.getAnAccess() = authorizeCall.getQualifier() and
|
||||
v.getAnAccess() = matcherCall.getQualifier() and
|
||||
authorizeCall.getArgument(0).(LambdaExpr).getExprBody() = permitAllCall and
|
||||
permitAllCall.getQualifier() instanceof AnyRequestCall
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -264,4 +264,11 @@ public class SpringBootActuatorsTest {
|
||||
protected void configureOkNoPermitAll7_securityMatchers(HttpSecurity http) throws Exception {
|
||||
http.securityMatchers(matcher -> EndpointRequest.toAnyEndpoint()).authorizeHttpRequests().anyRequest();
|
||||
}
|
||||
|
||||
// Spring doc example
|
||||
// https://docs.spring.io/spring-boot/reference/actuator/endpoints.html#actuator.endpoints.security
|
||||
public void securityFilterChain(HttpSecurity http) throws Exception {
|
||||
http.securityMatcher(EndpointRequest.toAnyEndpoint());
|
||||
http.authorizeHttpRequests((requests) -> requests.anyRequest().permitAll()); // $ hasExposedSpringBootActuator
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user