Skip to content

Commit 1da1e89

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: convert SpringModelAndViewSink to MaD
1 parent 8d66097 commit 1da1e89

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extensions:
2+
- addsTo:
3+
pack: codeql/java-all
4+
extensible: sinkModel
5+
data:
6+
- ["org.springframework.web.portlet", "ModelAndView", False, "ModelAndView", "", "", "Argument[0]", "url-forward", "manual"]
7+
- ["org.springframework.web.portlet", "ModelAndView", False, "setViewName", "", "", "Argument[0]", "url-forward", "manual"]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extensions:
2+
- addsTo:
3+
pack: codeql/java-all
4+
extensible: sinkModel
5+
data:
6+
- ["org.springframework.web.servlet", "ModelAndView", False, "ModelAndView", "", "", "Argument[0]", "url-forward", "manual"]
7+
- ["org.springframework.web.servlet", "ModelAndView", False, "setViewName", "", "", "Argument[0]", "url-forward", "manual"]

java/ql/lib/semmle/code/java/security/UnsafeUrlForward.qll

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,6 @@ private class DefaultUnsafeUrlForwardSink extends UnsafeUrlForwardSink {
1515
DefaultUnsafeUrlForwardSink() { sinkNode(this, "url-forward") }
1616
}
1717

18-
/** An argument to `new ModelAndView` or `ModelAndView.setViewName`. */
19-
private class SpringModelAndViewSink extends UnsafeUrlForwardSink {
20-
SpringModelAndViewSink() {
21-
exists(ClassInstanceExpr cie |
22-
cie.getConstructedType() instanceof ModelAndView and
23-
cie.getArgument(0) = this.asExpr()
24-
)
25-
or
26-
exists(SpringModelAndViewSetViewNameCall smavsvnc | smavsvnc.getArgument(0) = this.asExpr())
27-
}
28-
}
29-
3018
private class PrimitiveSanitizer extends UnsafeUrlForwardSanitizer {
3119
PrimitiveSanitizer() {
3220
this.getType() instanceof PrimitiveType or

shared/mad/codeql/mad/ModelValidation.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ module KindValidation<KindValidationConfigSig Config> {
3333
"bean-validation", "fragment-injection", "groovy-injection", "hostname-verification",
3434
"information-leak", "intent-redirection", "jexl-injection", "jndi-injection",
3535
"mvel-injection", "notification", "ognl-injection", "pending-intents",
36-
"response-splitting", "trust-boundary-violation", "template-injection", "xpath-injection",
37-
"xslt-injection",
36+
"response-splitting", "trust-boundary-violation", "template-injection", "url-forward",
37+
"xpath-injection", "xslt-injection",
3838
// JavaScript-only currently, but may be shared in the future
3939
"mongodb.sink", "nosql-injection", "unsafe-deserialization",
4040
// Swift-only currently, but may be shared in the future

0 commit comments

Comments
 (0)