@@ -28,12 +28,17 @@ class SpringBootPom extends Pom {
2828}
2929
3030/** The properties file `application.properties`. */
31- class ApplicationProperties extends ConfigPair {
32- ApplicationProperties ( ) { this .getFile ( ) .getBaseName ( ) = "application.properties" }
31+ class ApplicationPropertiesFile extends File {
32+ ApplicationPropertiesFile ( ) { this .getBaseName ( ) = "application.properties" }
33+ }
34+
35+ /** A name-value pair stored in an `application.properties` file. */
36+ class ApplicationPropertiesConfigPair extends ConfigPair {
37+ ApplicationPropertiesConfigPair ( ) { this .getFile ( ) instanceof ApplicationPropertiesFile }
3338}
3439
3540/** The configuration property `management.security.enabled`. */
36- class ManagementSecurityConfig extends ApplicationProperties {
41+ class ManagementSecurityConfig extends ApplicationPropertiesConfigPair {
3742 ManagementSecurityConfig ( ) { this .getNameElement ( ) .getName ( ) = "management.security.enabled" }
3843
3944 /** Gets the whitespace-trimmed value of this property. */
@@ -47,7 +52,7 @@ class ManagementSecurityConfig extends ApplicationProperties {
4752}
4853
4954/** The configuration property `management.endpoints.web.exposure.include`. */
50- class ManagementEndPointInclude extends ApplicationProperties {
55+ class ManagementEndPointInclude extends ApplicationPropertiesConfigPair {
5156 ManagementEndPointInclude ( ) {
5257 this .getNameElement ( ) .getName ( ) = "management.endpoints.web.exposure.include"
5358 }
@@ -60,33 +65,35 @@ class ManagementEndPointInclude extends ApplicationProperties {
6065 * Holds if `ApplicationProperties` ap of a repository managed by `SpringBootPom` pom
6166 * has a vulnerable configuration of Spring Boot Actuator management endpoints.
6267 */
63- predicate hasConfidentialEndPointExposed ( SpringBootPom pom , ApplicationProperties ap ) {
68+ predicate hasConfidentialEndPointExposed ( SpringBootPom pom ) {
6469 pom .isSpringBootActuatorUsed ( ) and
6570 not pom .isSpringBootSecurityUsed ( ) and
66- ap .getFile ( )
67- .getParentContainer ( )
68- .getAbsolutePath ( )
69- .matches ( pom .getFile ( ) .getParentContainer ( ) .getAbsolutePath ( ) + "%" ) and // in the same sub-directory
70- exists ( string springBootVersion | springBootVersion = pom .getParentElement ( ) .getVersionString ( ) |
71- springBootVersion .regexpMatch ( "1\\.[0-4].*" ) and // version 1.0, 1.1, ..., 1.4
72- not exists ( ManagementSecurityConfig me |
73- me .hasSecurityEnabled ( ) and me .getFile ( ) = ap .getFile ( )
74- )
75- or
76- springBootVersion .matches ( "1.5%" ) and // version 1.5
77- exists ( ManagementSecurityConfig me | me .hasSecurityDisabled ( ) and me .getFile ( ) = ap .getFile ( ) )
78- or
79- springBootVersion .matches ( "2.%" ) and //version 2.x
80- exists ( ManagementEndPointInclude mi |
81- mi .getFile ( ) = ap .getFile ( ) and
82- (
83- mi .getValue ( ) = "*" // all endpoints are enabled
84- or
85- mi .getValue ( )
86- .matches ( [
87- "%dump%" , "%trace%" , "%logfile%" , "%shutdown%" , "%startup%" , "%mappings%" , "%env%" ,
88- "%beans%" , "%sessions%"
89- ] ) // confidential endpoints to check although all endpoints apart from '/health' and '/info' are considered sensitive by Spring
71+ exists ( ApplicationPropertiesFile apFile |
72+ apFile
73+ .getParentContainer ( )
74+ .getAbsolutePath ( )
75+ .matches ( pom .getFile ( ) .getParentContainer ( ) .getAbsolutePath ( ) + "%" ) and // in the same sub-directory
76+ exists ( string springBootVersion |
77+ springBootVersion = pom .getParentElement ( ) .getVersionString ( )
78+ |
79+ springBootVersion .regexpMatch ( "1\\.[0-4].*" ) and // version 1.0, 1.1, ..., 1.4
80+ not exists ( ManagementSecurityConfig me | me .hasSecurityEnabled ( ) and me .getFile ( ) = apFile )
81+ or
82+ springBootVersion .matches ( "1.5%" ) and // version 1.5
83+ exists ( ManagementSecurityConfig me | me .hasSecurityDisabled ( ) and me .getFile ( ) = apFile )
84+ or
85+ springBootVersion .matches ( "2.%" ) and //version 2.x
86+ exists ( ManagementEndPointInclude mi |
87+ mi .getFile ( ) = apFile and
88+ (
89+ mi .getValue ( ) = "*" // all endpoints are enabled
90+ or
91+ mi .getValue ( )
92+ .matches ( [
93+ "%dump%" , "%trace%" , "%logfile%" , "%shutdown%" , "%startup%" , "%mappings%" ,
94+ "%env%" , "%beans%" , "%sessions%"
95+ ] ) // confidential endpoints to check although all endpoints apart from '/health' and '/info' are considered sensitive by Spring
96+ )
9097 )
9198 )
9299 )
0 commit comments