@@ -48,9 +48,6 @@ class ManagementSecurityConfig extends ApplicationPropertiesConfigPair {
48
48
49
49
/** Holds if `management.security.enabled` is set to `false`. */
50
50
predicate hasSecurityDisabled ( ) { this .getValue ( ) = "false" }
51
-
52
- /** Holds if `management.security.enabled` is set to `true`. */
53
- predicate hasSecurityEnabled ( ) { this .getValue ( ) = "true" }
54
51
}
55
52
56
53
/** The configuration property `management.endpoints.web.exposure.include`. */
@@ -63,11 +60,37 @@ class ManagementEndPointInclude extends ApplicationPropertiesConfigPair {
63
60
string getValue ( ) { result = this .getValueElement ( ) .getValue ( ) .trim ( ) }
64
61
}
65
62
63
+ private newtype TOption =
64
+ TNone ( ) or
65
+ TSome ( ApplicationPropertiesConfigPair ap )
66
+
67
+ /**
68
+ * An option type that is either a singleton `None` or a `Some` wrapping
69
+ * the `ApplicationPropertiesConfigPair` type.
70
+ */
71
+ class ApplicationPropertiesOption extends TOption {
72
+ /** Gets a textual representation of this element. */
73
+ string toString ( ) {
74
+ this = TNone ( ) and result = "(none)"
75
+ or
76
+ result = this .asSome ( ) .toString ( )
77
+ }
78
+
79
+ /** Gets the location of this element. */
80
+ Location getLocation ( ) { result = this .asSome ( ) .getLocation ( ) }
81
+
82
+ /** Gets the wrapped element, if any. */
83
+ ApplicationPropertiesConfigPair asSome ( ) { this = TSome ( result ) }
84
+
85
+ /** Holds if this option is the singleton `None`. */
86
+ predicate isNone ( ) { this = TNone ( ) }
87
+ }
88
+
66
89
/**
67
90
* Holds if `ApplicationProperties` ap of a repository managed by `SpringBootPom` pom
68
91
* has a vulnerable configuration of Spring Boot Actuator management endpoints.
69
92
*/
70
- predicate hasConfidentialEndPointExposed ( SpringBootPom pom ) {
93
+ predicate hasConfidentialEndPointExposed ( SpringBootPom pom , ApplicationPropertiesOption apOption ) {
71
94
pom .isSpringBootActuatorUsed ( ) and
72
95
not pom .isSpringBootSecurityUsed ( ) and
73
96
exists ( ApplicationPropertiesFile apFile |
@@ -79,14 +102,18 @@ predicate hasConfidentialEndPointExposed(SpringBootPom pom) {
79
102
springBootVersion = pom .getParentElement ( ) .getVersionString ( )
80
103
|
81
104
springBootVersion .regexpMatch ( "1\\.[0-4].*" ) and // version 1.0, 1.1, ..., 1.4
82
- not exists ( ManagementSecurityConfig me | me .hasSecurityEnabled ( ) and me .getFile ( ) = apFile )
105
+ not exists ( ManagementSecurityConfig me | me .getFile ( ) = apFile ) and
106
+ apOption .isNone ( )
83
107
or
84
- springBootVersion .matches ( "1.5%" ) and // version 1.5
85
- exists ( ManagementSecurityConfig me | me .hasSecurityDisabled ( ) and me .getFile ( ) = apFile )
108
+ springBootVersion .regexpMatch ( "1\\.[0-5].*" ) and // version 1.0, 1.1, ..., 1.5
109
+ exists ( ManagementSecurityConfig me |
110
+ me .hasSecurityDisabled ( ) and me .getFile ( ) = apFile and me = apOption .asSome ( )
111
+ )
86
112
or
87
113
springBootVersion .matches ( "2.%" ) and //version 2.x
88
114
exists ( ManagementEndPointInclude mi |
89
115
mi .getFile ( ) = apFile and
116
+ mi = apOption .asSome ( ) and
90
117
(
91
118
mi .getValue ( ) = "*" // all endpoints are enabled
92
119
or
0 commit comments