Skip to content

Commit 1a2e341

Browse files
committed
Refactor the business logic of the query into a separate predicate
1 parent c8b1bc3 commit 1a2e341

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

java/ql/src/experimental/Security/CWE/CWE-016/InsecureSpringActuatorConfig.ql

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ class ManagementEndPointInclude extends ApplicationProperties {
6060
string getValue() { result = this.getValueElement().getValue().trim() }
6161
}
6262

63-
from SpringBootPom pom, ApplicationProperties ap, Dependency d
64-
where
63+
/**
64+
* Holds if `ApplicationProperties` ap of a repository managed by `SpringBootPom` pom
65+
* has a vulnerable configuration of Spring Boot Actuator management endpoints.
66+
*/
67+
predicate hasConfidentialEndPointExposed(SpringBootPom pom, ApplicationProperties ap) {
6568
pom.isSpringBootActuatorUsed() and
6669
not pom.isSpringBootSecurityUsed() and
6770
ap.getFile()
@@ -90,7 +93,12 @@ where
9093
]) // confidential endpoints to check although all endpoints apart from '/health' and '/info' are considered sensitive by Spring
9194
)
9295
)
93-
) and
96+
)
97+
}
98+
99+
from SpringBootPom pom, ApplicationProperties ap, Dependency d
100+
where
101+
hasConfidentialEndPointExposed(pom, ap) and
94102
d = pom.getADependency() and
95103
d.getArtifact().getValue() = "spring-boot-starter-actuator"
96104
select d, "Insecure configuration of Spring Boot Actuator exposes sensitive endpoints."

0 commit comments

Comments
 (0)