Convert model to QL

This commit is contained in:
Owen Mansel-Chan
2024-11-28 13:44:55 +00:00
parent b5fbf2e944
commit ba3f9d6134
2 changed files with 18 additions and 3 deletions

View File

@@ -16,9 +16,6 @@ extensions:
- ["org.springframework.web.client", "RestTemplate", False, "execute", "", "", "Argument[0]", "request-forgery", "manual"]
- ["org.springframework.web.client", "RestTemplate", False, "getForEntity", "", "", "Argument[0]", "request-forgery", "manual"]
- ["org.springframework.web.client", "RestTemplate", False, "getForObject", "", "", "Argument[0]", "request-forgery", "manual"]
- ["org.springframework.web.client", "RestTemplate", False, "getForObject", "", "", "Argument[2]", "request-forgery", "manual"] # This is a workaround for the fact that sink model can't currently have access paths
# - ["org.springframework.web.client", "RestTemplate", False, "getForObject", "", "", "Argument[2].ArrayElement", "request-forgery", "manual"]
# - ["org.springframework.web.client", "RestTemplate", False, "getForObject", "", "", "Argument[2].MapValue", "request-forgery", "manual"]
- ["org.springframework.web.client", "RestTemplate", False, "headForHeaders", "", "", "Argument[0]", "request-forgery", "manual"]
- ["org.springframework.web.client", "RestTemplate", False, "optionsForAllow", "", "", "Argument[0]", "request-forgery", "manual"]
- ["org.springframework.web.client", "RestTemplate", False, "patchForObject", "", "", "Argument[0]", "request-forgery", "manual"]

View File

@@ -27,3 +27,21 @@ class SpringWebClient extends Interface {
this.hasQualifiedName("org.springframework.web.reactive.function.client", "WebClient")
}
}
private import semmle.code.java.security.RequestForgery
private class SpringWebClientRestTemplateGetForObject extends RequestForgerySink {
SpringWebClientRestTemplateGetForObject() {
exists(Method m, MethodCall mc, int i |
m.getDeclaringType() instanceof SpringRestTemplate and
m.hasName("getForObject") and
mc.getMethod() = m
|
// Deal with two overloads, with third parameter type `Object...` and
// `Map<String, ?>`. We cannot deal with mapvalue content easily but
// there is a default implicit taint read at sinks that will catch it.
this.asExpr() = mc.getArgument(i) and
i >= 2
)
}
}