Skip to content

Commit cc4fe73

Browse files
authored
Merge pull request github#5953 from github/sauyon/java/spring-webutil
Java: Add models for the Spring `web.util` package
2 parents 27df272 + 17cef3f commit cc4fe73

File tree

75 files changed

+4341
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+4341
-17
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
lgtm,codescanning
2+
* Additional flow steps in the `org.springframework.web.util` package of the Spring framework have
3+
been modelled. This may result in additional results for security queries on projects using this
4+
framework.

java/ql/src/semmle/code/java/dataflow/ExternalFlow.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ private module Frameworks {
9595
private import semmle.code.java.frameworks.spring.SpringWebClient
9696
private import semmle.code.java.frameworks.spring.SpringBeans
9797
private import semmle.code.java.frameworks.spring.SpringWebMultipart
98+
private import semmle.code.java.frameworks.spring.SpringWebUtil
9899
private import semmle.code.java.security.ResponseSplitting
99100
private import semmle.code.java.security.InformationLeak
100101
private import semmle.code.java.security.GroovyInjection

java/ql/src/semmle/code/java/frameworks/spring/Spring.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import semmle.code.java.frameworks.spring.SpringUtil
3939
import semmle.code.java.frameworks.spring.SpringValidation
4040
import semmle.code.java.frameworks.spring.SpringValue
4141
import semmle.code.java.frameworks.spring.SpringWebMultipart
42+
import semmle.code.java.frameworks.spring.SpringWebUtil
4243
import semmle.code.java.frameworks.spring.SpringXMLElement
4344
import semmle.code.java.frameworks.spring.metrics.MetricSpringBean
4445
import semmle.code.java.frameworks.spring.metrics.MetricSpringBeanFile

java/ql/src/semmle/code/java/frameworks/spring/SpringWebUtil.qll

Lines changed: 176 additions & 0 deletions
Large diffs are not rendered by default.

java/ql/src/semmle/code/java/security/XSS.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ private class DefaultXssSink extends XssSink {
9393
/** A default sanitizer that considers numeric and boolean typed data safe for writing to output. */
9494
private class DefaultXSSSanitizer extends XssSanitizer {
9595
DefaultXSSSanitizer() {
96-
this.getType() instanceof NumericType or this.getType() instanceof BooleanType
96+
this.getType() instanceof NumericType or
97+
this.getType() instanceof BooleanType or
98+
// Match `org.springframework.web.util.HtmlUtils.htmlEscape` and possibly other methods like it.
99+
this.asExpr().(MethodAccess).getMethod().getName().regexpMatch("(?i)html_?escape.*")
97100
}
98101
}
99102

0 commit comments

Comments
 (0)