@@ -28,12 +28,17 @@ class SpringBootPom extends Pom {
28
28
}
29
29
30
30
/** 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 }
33
38
}
34
39
35
40
/** The configuration property `management.security.enabled`. */
36
- class ManagementSecurityConfig extends ApplicationProperties {
41
+ class ManagementSecurityConfig extends ApplicationPropertiesConfigPair {
37
42
ManagementSecurityConfig ( ) { this .getNameElement ( ) .getName ( ) = "management.security.enabled" }
38
43
39
44
/** Gets the whitespace-trimmed value of this property. */
@@ -47,7 +52,7 @@ class ManagementSecurityConfig extends ApplicationProperties {
47
52
}
48
53
49
54
/** The configuration property `management.endpoints.web.exposure.include`. */
50
- class ManagementEndPointInclude extends ApplicationProperties {
55
+ class ManagementEndPointInclude extends ApplicationPropertiesConfigPair {
51
56
ManagementEndPointInclude ( ) {
52
57
this .getNameElement ( ) .getName ( ) = "management.endpoints.web.exposure.include"
53
58
}
@@ -60,33 +65,35 @@ class ManagementEndPointInclude extends ApplicationProperties {
60
65
* Holds if `ApplicationProperties` ap of a repository managed by `SpringBootPom` pom
61
66
* has a vulnerable configuration of Spring Boot Actuator management endpoints.
62
67
*/
63
- predicate hasConfidentialEndPointExposed ( SpringBootPom pom , ApplicationProperties ap ) {
68
+ predicate hasConfidentialEndPointExposed ( SpringBootPom pom ) {
64
69
pom .isSpringBootActuatorUsed ( ) and
65
70
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
+ )
90
97
)
91
98
)
92
99
)
0 commit comments