mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Move source and sink into importable library
This commit is contained in:
@@ -11,7 +11,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import java
|
import java
|
||||||
import ServletResponseSplitting
|
import semmle.code.java.dataflow.FlowSources
|
||||||
|
import semmle.code.java.security.ResponseSplitting
|
||||||
import DataFlow::PathGraph
|
import DataFlow::PathGraph
|
||||||
|
|
||||||
class ResponseSplittingConfig extends TaintTracking::Configuration {
|
class ResponseSplittingConfig extends TaintTracking::Configuration {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
import java
|
import java
|
||||||
import semmle.code.java.dataflow.FlowSources
|
import semmle.code.java.dataflow.FlowSources
|
||||||
import ServletResponseSplitting
|
import semmle.code.java.security.ResponseSplitting
|
||||||
import DataFlow::PathGraph
|
import DataFlow::PathGraph
|
||||||
|
|
||||||
class ResponseSplittingLocalConfig extends TaintTracking::Configuration {
|
class ResponseSplittingLocalConfig extends TaintTracking::Configuration {
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
import java
|
|
||||||
import semmle.code.java.frameworks.Servlets
|
|
||||||
import semmle.code.java.dataflow.FlowSources
|
|
||||||
import semmle.code.java.security.ResponseSplitting
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Header-splitting sinks. Expressions that end up in an HTTP header.
|
|
||||||
*/
|
|
||||||
class ServletHeaderSplittingSink extends HeaderSplittingSink {
|
|
||||||
ServletHeaderSplittingSink() {
|
|
||||||
exists(ResponseAddCookieMethod m, MethodAccess ma |
|
|
||||||
ma.getMethod() = m and
|
|
||||||
this.asExpr() = ma.getArgument(0)
|
|
||||||
)
|
|
||||||
or
|
|
||||||
exists(ResponseAddHeaderMethod m, MethodAccess ma |
|
|
||||||
ma.getMethod() = m and
|
|
||||||
this.asExpr() = ma.getAnArgument()
|
|
||||||
)
|
|
||||||
or
|
|
||||||
exists(ResponseSetHeaderMethod m, MethodAccess ma |
|
|
||||||
ma.getMethod() = m and
|
|
||||||
this.asExpr() = ma.getAnArgument()
|
|
||||||
)
|
|
||||||
or
|
|
||||||
exists(JaxRsResponseBuilder builder, Method m |
|
|
||||||
m = builder.getAMethod() and m.getName() = "header"
|
|
||||||
|
|
|
||||||
this.asExpr() = m.getAReference().getArgument(1)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ServletSafeHeaderSplittingSource extends SafeHeaderSplittingSource {
|
|
||||||
ServletSafeHeaderSplittingSource() {
|
|
||||||
this.asExpr().(MethodAccess).getMethod() instanceof HttpServletRequestGetHeaderMethod or
|
|
||||||
this.asExpr().(MethodAccess).getMethod() instanceof CookieGetNameMethod
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
import semmle.code.java.dataflow.DataFlow
|
import semmle.code.java.dataflow.DataFlow
|
||||||
|
import semmle.code.java.frameworks.Servlets
|
||||||
|
import semmle.code.java.frameworks.JaxWS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Header-splitting sinks. Expressions that end up in an HTTP header.
|
* Header-splitting sinks. Expressions that end up in an HTTP header.
|
||||||
@@ -9,3 +11,38 @@ abstract class HeaderSplittingSink extends DataFlow::Node { }
|
|||||||
* Sources that cannot be used to perform a header splitting attack.
|
* Sources that cannot be used to perform a header splitting attack.
|
||||||
*/
|
*/
|
||||||
abstract class SafeHeaderSplittingSource extends DataFlow::Node { }
|
abstract class SafeHeaderSplittingSource extends DataFlow::Node { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Header-splitting sinks. Expressions that end up in an HTTP header.
|
||||||
|
*/
|
||||||
|
private class ServletHeaderSplittingSink extends HeaderSplittingSink {
|
||||||
|
ServletHeaderSplittingSink() {
|
||||||
|
exists(ResponseAddCookieMethod m, MethodAccess ma |
|
||||||
|
ma.getMethod() = m and
|
||||||
|
this.asExpr() = ma.getArgument(0)
|
||||||
|
)
|
||||||
|
or
|
||||||
|
exists(ResponseAddHeaderMethod m, MethodAccess ma |
|
||||||
|
ma.getMethod() = m and
|
||||||
|
this.asExpr() = ma.getAnArgument()
|
||||||
|
)
|
||||||
|
or
|
||||||
|
exists(ResponseSetHeaderMethod m, MethodAccess ma |
|
||||||
|
ma.getMethod() = m and
|
||||||
|
this.asExpr() = ma.getAnArgument()
|
||||||
|
)
|
||||||
|
or
|
||||||
|
exists(JaxRsResponseBuilder builder, Method m |
|
||||||
|
m = builder.getAMethod() and m.getName() = "header"
|
||||||
|
|
|
||||||
|
this.asExpr() = m.getAReference().getArgument(1)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ServletSafeHeaderSplittingSource extends SafeHeaderSplittingSource {
|
||||||
|
ServletSafeHeaderSplittingSource() {
|
||||||
|
this.asExpr().(MethodAccess).getMethod() instanceof HttpServletRequestGetHeaderMethod or
|
||||||
|
this.asExpr().(MethodAccess).getMethod() instanceof CookieGetNameMethod
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user