|
| 1 | +deprecated module; |
| 2 | + |
| 3 | +import java |
| 4 | + |
| 5 | +/** The class `org.springframework.security.config.annotation.web.builders.HttpSecurity`. */ |
| 6 | +class TypeHttpSecurity extends Class { |
| 7 | + TypeHttpSecurity() { |
| 8 | + this.hasQualifiedName("org.springframework.security.config.annotation.web.builders", |
| 9 | + "HttpSecurity") |
| 10 | + } |
| 11 | +} |
| 12 | + |
| 13 | +/** |
| 14 | + * The class |
| 15 | + * `org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer`. |
| 16 | + */ |
| 17 | +class TypeAuthorizedUrl extends Class { |
| 18 | + TypeAuthorizedUrl() { |
| 19 | + this.hasQualifiedName("org.springframework.security.config.annotation.web.configurers", |
| 20 | + "ExpressionUrlAuthorizationConfigurer<HttpSecurity>$AuthorizedUrl<>") |
| 21 | + } |
| 22 | +} |
| 23 | + |
| 24 | +/** |
| 25 | + * The class `org.springframework.security.config.annotation.web.AbstractRequestMatcherRegistry`. |
| 26 | + */ |
| 27 | +class TypeAbstractRequestMatcherRegistry extends Class { |
| 28 | + TypeAbstractRequestMatcherRegistry() { |
| 29 | + this.hasQualifiedName("org.springframework.security.config.annotation.web", |
| 30 | + "AbstractRequestMatcherRegistry<AuthorizedUrl<>>") |
| 31 | + } |
| 32 | +} |
| 33 | + |
| 34 | +/** |
| 35 | + * The class `org.springframework.boot.actuate.autoconfigure.security.servlet.EndpointRequest`. |
| 36 | + */ |
| 37 | +class TypeEndpointRequest extends Class { |
| 38 | + TypeEndpointRequest() { |
| 39 | + this.hasQualifiedName("org.springframework.boot.actuate.autoconfigure.security.servlet", |
| 40 | + "EndpointRequest") |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +/** A call to `EndpointRequest.toAnyEndpoint` method. */ |
| 45 | +class ToAnyEndpointCall extends MethodCall { |
| 46 | + ToAnyEndpointCall() { |
| 47 | + this.getMethod().hasName("toAnyEndpoint") and |
| 48 | + this.getMethod().getDeclaringType() instanceof TypeEndpointRequest |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +/** |
| 53 | + * A call to `HttpSecurity.requestMatcher` method with argument `RequestMatcher.toAnyEndpoint()`. |
| 54 | + */ |
| 55 | +class RequestMatcherCall extends MethodCall { |
| 56 | + RequestMatcherCall() { |
| 57 | + this.getMethod().hasName("requestMatcher") and |
| 58 | + this.getMethod().getDeclaringType() instanceof TypeHttpSecurity and |
| 59 | + this.getArgument(0) instanceof ToAnyEndpointCall |
| 60 | + } |
| 61 | +} |
| 62 | + |
| 63 | +/** |
| 64 | + * A call to `HttpSecurity.requestMatchers` method with lambda argument |
| 65 | + * `RequestMatcher.toAnyEndpoint()`. |
| 66 | + */ |
| 67 | +class RequestMatchersCall extends MethodCall { |
| 68 | + RequestMatchersCall() { |
| 69 | + this.getMethod().hasName("requestMatchers") and |
| 70 | + this.getMethod().getDeclaringType() instanceof TypeHttpSecurity and |
| 71 | + this.getArgument(0).(LambdaExpr).getExprBody() instanceof ToAnyEndpointCall |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | +/** A call to `HttpSecurity.authorizeRequests` method. */ |
| 76 | +class AuthorizeRequestsCall extends MethodCall { |
| 77 | + AuthorizeRequestsCall() { |
| 78 | + this.getMethod().hasName("authorizeRequests") and |
| 79 | + this.getMethod().getDeclaringType() instanceof TypeHttpSecurity |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +/** A call to `AuthorizedUrl.permitAll` method. */ |
| 84 | +class PermitAllCall extends MethodCall { |
| 85 | + PermitAllCall() { |
| 86 | + this.getMethod().hasName("permitAll") and |
| 87 | + this.getMethod().getDeclaringType() instanceof TypeAuthorizedUrl |
| 88 | + } |
| 89 | + |
| 90 | + /** Holds if `permitAll` is called on request(s) mapped to actuator endpoint(s). */ |
| 91 | + predicate permitsSpringBootActuators() { |
| 92 | + exists(AuthorizeRequestsCall authorizeRequestsCall | |
| 93 | + // .requestMatcher(EndpointRequest).authorizeRequests([...]).[...] |
| 94 | + authorizeRequestsCall.getQualifier() instanceof RequestMatcherCall |
| 95 | + or |
| 96 | + // .requestMatchers(matcher -> EndpointRequest).authorizeRequests([...]).[...] |
| 97 | + authorizeRequestsCall.getQualifier() instanceof RequestMatchersCall |
| 98 | + | |
| 99 | + // [...].authorizeRequests(r -> r.anyRequest().permitAll()) or |
| 100 | + // [...].authorizeRequests(r -> r.requestMatchers(EndpointRequest).permitAll()) |
| 101 | + authorizeRequestsCall.getArgument(0).(LambdaExpr).getExprBody() = this and |
| 102 | + ( |
| 103 | + this.getQualifier() instanceof AnyRequestCall or |
| 104 | + this.getQualifier() instanceof RegistryRequestMatchersCall |
| 105 | + ) |
| 106 | + or |
| 107 | + // [...].authorizeRequests().requestMatchers(EndpointRequest).permitAll() or |
| 108 | + // [...].authorizeRequests().anyRequest().permitAll() |
| 109 | + authorizeRequestsCall.getNumArgument() = 0 and |
| 110 | + exists(RegistryRequestMatchersCall registryRequestMatchersCall | |
| 111 | + registryRequestMatchersCall.getQualifier() = authorizeRequestsCall and |
| 112 | + this.getQualifier() = registryRequestMatchersCall |
| 113 | + ) |
| 114 | + or |
| 115 | + exists(AnyRequestCall anyRequestCall | |
| 116 | + anyRequestCall.getQualifier() = authorizeRequestsCall and |
| 117 | + this.getQualifier() = anyRequestCall |
| 118 | + ) |
| 119 | + ) |
| 120 | + or |
| 121 | + exists(AuthorizeRequestsCall authorizeRequestsCall | |
| 122 | + // http.authorizeRequests([...]).[...] |
| 123 | + authorizeRequestsCall.getQualifier() instanceof VarAccess |
| 124 | + | |
| 125 | + // [...].authorizeRequests(r -> r.requestMatchers(EndpointRequest).permitAll()) |
| 126 | + authorizeRequestsCall.getArgument(0).(LambdaExpr).getExprBody() = this and |
| 127 | + this.getQualifier() instanceof RegistryRequestMatchersCall |
| 128 | + or |
| 129 | + // [...].authorizeRequests().requestMatchers(EndpointRequest).permitAll() or |
| 130 | + authorizeRequestsCall.getNumArgument() = 0 and |
| 131 | + exists(RegistryRequestMatchersCall registryRequestMatchersCall | |
| 132 | + registryRequestMatchersCall.getQualifier() = authorizeRequestsCall and |
| 133 | + this.getQualifier() = registryRequestMatchersCall |
| 134 | + ) |
| 135 | + ) |
| 136 | + } |
| 137 | +} |
| 138 | + |
| 139 | +/** A call to `AbstractRequestMatcherRegistry.anyRequest` method. */ |
| 140 | +class AnyRequestCall extends MethodCall { |
| 141 | + AnyRequestCall() { |
| 142 | + this.getMethod().hasName("anyRequest") and |
| 143 | + this.getMethod().getDeclaringType() instanceof TypeAbstractRequestMatcherRegistry |
| 144 | + } |
| 145 | +} |
| 146 | + |
| 147 | +/** |
| 148 | + * A call to `AbstractRequestMatcherRegistry.requestMatchers` method with an argument |
| 149 | + * `RequestMatcher.toAnyEndpoint()`. |
| 150 | + */ |
| 151 | +class RegistryRequestMatchersCall extends MethodCall { |
| 152 | + RegistryRequestMatchersCall() { |
| 153 | + this.getMethod().hasName("requestMatchers") and |
| 154 | + this.getMethod().getDeclaringType() instanceof TypeAbstractRequestMatcherRegistry and |
| 155 | + this.getAnArgument() instanceof ToAnyEndpointCall |
| 156 | + } |
| 157 | +} |
0 commit comments