Java: Diff-informed UnsafeHostnameVerification.ql

This commit also adds a test case that would fail under `codeql test run
--check-diff-informed` if not for the override of
`getASelectedSourceLocation`. There was no existing such test since all
the existing tests used anonymous classes whose location was on the same
line as the source.
This commit is contained in:
Jonas Jensen
2024-10-05 21:54:14 +02:00
parent 8224ef6929
commit fea260bd55
3 changed files with 29 additions and 0 deletions

View File

@@ -65,6 +65,17 @@ module TrustAllHostnameVerifierConfig implements DataFlow::ConfigSig {
"|(set)?(accept|trust|ignore|allow)(all|every|any)" +
"|(use|do|enable)insecure|(set|do|use)?no.*(check|validation|verify|verification)|disable).*$")
}
predicate observeDiffInformedIncrementalMode() { any() }
Location getASelectedSourceLocation(DataFlow::Node source) {
isSource(source) and
(
result = source.getLocation()
or
result = source.asExpr().(ClassInstanceExpr).getConstructedType().getLocation()
)
}
}
/** Data flow to model the flow of a `TrustAllHostnameVerifier` to a `set(Default)HostnameVerifier` call. */