-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Java: Promote Spring Boot Actuators query from experimental #18793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jcogs33
merged 17 commits into
github:main
from
jcogs33:jcogs33/java/spring-boot-actuators-promo
Mar 11, 2025
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2ce5920
Java: copy out of experimental
978834b
Java: remove deprecations
089a491
Java: fix tests; update for non-experimental directory
5e5bc2a
Java: remove experimental files
8064e8f
Java: convert tests to inline expectations
8dfb920
Java: refactor QL, move code to libraries
b2469ff
Java: add APIs and tests for more recent Spring versions: authorizeHt…
9e51b01
Java: handle example in Spring docs
f65a5b9
Java: add test for qhelp good example
6fe7c7a
Java: some refactoring
53cb30d
Java: update metadata, move from CWE-016 to CWE-200
26e3967
Java: edit qhelp
c2e859c
Java: add change note
746f022
Java: add 'Spring' prefix to public class names
82062e2
Java: update test
0eec951
Java: update change note to mention removal from Community Packs
ad63dd9
Apply suggestions from docs review
jcogs33 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Java: edit qhelp
- Loading branch information
There are no files selected for viewing
33 changes: 18 additions & 15 deletions
33
java/ql/src/Security/CWE/CWE-200/SpringBootActuators.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
@Configuration(proxyBeanMethods = false) | ||
public class SpringBootActuators extends WebSecurityConfigurerAdapter { | ||
public class CustomSecurityConfiguration { | ||
|
||
@Bean | ||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { | ||
// BAD: Unauthenticated access to Spring Boot actuator endpoints is allowed | ||
http.securityMatcher(EndpointRequest.toAnyEndpoint()); | ||
http.authorizeHttpRequests((requests) -> requests.anyRequest().permitAll()); | ||
return http.build(); | ||
} | ||
|
||
@Override | ||
protected void configure(HttpSecurity http) throws Exception { | ||
// BAD: Unauthenticated access to Spring Boot actuator endpoints is allowed | ||
http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests((requests) -> | ||
requests.anyRequest().permitAll()); | ||
} | ||
} | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
public class ActuatorSecurity extends WebSecurityConfigurerAdapter { | ||
public class CustomSecurityConfiguration { | ||
|
||
@Bean | ||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { | ||
// GOOD: only users with ENDPOINT_ADMIN role are allowed to access the actuator endpoints | ||
http.securityMatcher(EndpointRequest.toAnyEndpoint()); | ||
http.authorizeHttpRequests((requests) -> requests.anyRequest().hasRole("ENDPOINT_ADMIN")); | ||
return http.build(); | ||
} | ||
|
||
@Override | ||
protected void configure(HttpSecurity http) throws Exception { | ||
// GOOD: only users with ENDPOINT_ADMIN role are allowed to access the actuator endpoints | ||
http.requestMatcher(EndpointRequest.toAnyEndpoint()).authorizeRequests((requests) -> | ||
requests.anyRequest().hasRole("ENDPOINT_ADMIN")); | ||
http.httpBasic(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.