@@ -48,9 +48,6 @@ class ManagementSecurityConfig extends ApplicationPropertiesConfigPair {
4848
4949 /** Holds if `management.security.enabled` is set to `false`. */
5050 predicate hasSecurityDisabled ( ) { this .getValue ( ) = "false" }
51-
52- /** Holds if `management.security.enabled` is set to `true`. */
53- predicate hasSecurityEnabled ( ) { this .getValue ( ) = "true" }
5451}
5552
5653/** The configuration property `management.endpoints.web.exposure.include`. */
@@ -63,11 +60,37 @@ class ManagementEndPointInclude extends ApplicationPropertiesConfigPair {
6360 string getValue ( ) { result = this .getValueElement ( ) .getValue ( ) .trim ( ) }
6461}
6562
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+
6689/**
6790 * Holds if `ApplicationProperties` ap of a repository managed by `SpringBootPom` pom
6891 * has a vulnerable configuration of Spring Boot Actuator management endpoints.
6992 */
70- predicate hasConfidentialEndPointExposed ( SpringBootPom pom ) {
93+ predicate hasConfidentialEndPointExposed ( SpringBootPom pom , ApplicationPropertiesOption apOption ) {
7194 pom .isSpringBootActuatorUsed ( ) and
7295 not pom .isSpringBootSecurityUsed ( ) and
7396 exists ( ApplicationPropertiesFile apFile |
@@ -79,14 +102,18 @@ predicate hasConfidentialEndPointExposed(SpringBootPom pom) {
79102 springBootVersion = pom .getParentElement ( ) .getVersionString ( )
80103 |
81104 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 ( )
83107 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+ )
86112 or
87113 springBootVersion .matches ( "2.%" ) and //version 2.x
88114 exists ( ManagementEndPointInclude mi |
89115 mi .getFile ( ) = apFile and
116+ mi = apOption .asSome ( ) and
90117 (
91118 mi .getValue ( ) = "*" // all endpoints are enabled
92119 or
0 commit comments