Skip to content

Commit 79e01a2

Browse files
author
Max Schaefer
authored
Merge pull request #1305 from aschackmull/java/abstract-flowsources
Java: Introduce an abstract class RemoteFlowSource to ease customization.
2 parents 9653fbd + 66813a9 commit 79e01a2

File tree

16 files changed

+109
-41
lines changed

16 files changed

+109
-41
lines changed

java/ql/src/Security/CWE/CWE-022/TaintedPath.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import DataFlow::PathGraph
2020
class TaintedPathConfig extends TaintTracking::Configuration {
2121
TaintedPathConfig() { this = "TaintedPathConfig" }
2222

23-
override predicate isSource(DataFlow::Node source) { source instanceof RemoteUserInput }
23+
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
2424

2525
override predicate isSink(DataFlow::Node sink) {
2626
exists(Expr e | e = sink.asExpr() | e = any(PathCreation p).getInput() and not guarded(e))

java/ql/src/Security/CWE/CWE-078/ExecCommon.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ private class RemoteUserInputToArgumentToExecFlowConfig extends TaintTracking::C
66
this = "ExecCommon::RemoteUserInputToArgumentToExecFlowConfig"
77
}
88

9-
override predicate isSource(DataFlow::Node src) { src instanceof RemoteUserInput }
9+
override predicate isSource(DataFlow::Node src) { src instanceof RemoteFlowSource }
1010

1111
override predicate isSink(DataFlow::Node sink) { sink.asExpr() instanceof ArgumentToExec }
1212

java/ql/src/Security/CWE/CWE-079/XSS.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import DataFlow2::PathGraph
1818
class XSSConfig extends TaintTracking::Configuration2 {
1919
XSSConfig() { this = "XSSConfig" }
2020

21-
override predicate isSource(DataFlow::Node source) { source instanceof RemoteUserInput }
21+
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
2222

2323
override predicate isSink(DataFlow::Node sink) { sink instanceof XssSink }
2424

java/ql/src/Security/CWE/CWE-089/SqlInjectionLib.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class PersistenceQueryInjectionSink extends QueryInjectionSink {
4949
private class QueryInjectionFlowConfig extends TaintTracking::Configuration {
5050
QueryInjectionFlowConfig() { this = "SqlInjectionLib::QueryInjectionFlowConfig" }
5151

52-
override predicate isSource(DataFlow::Node src) { src instanceof RemoteUserInput }
52+
override predicate isSource(DataFlow::Node src) { src instanceof RemoteFlowSource }
5353

5454
override predicate isSink(DataFlow::Node sink) { sink instanceof QueryInjectionSink }
5555

java/ql/src/Security/CWE/CWE-113/ResponseSplitting.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ResponseSplittingConfig extends TaintTracking::Configuration {
1818
ResponseSplittingConfig() { this = "ResponseSplittingConfig" }
1919

2020
override predicate isSource(DataFlow::Node source) {
21-
source instanceof RemoteUserInput and
21+
source instanceof RemoteFlowSource and
2222
not source instanceof WhitelistedSource
2323
}
2424

java/ql/src/Security/CWE/CWE-113/ResponseSplitting.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class HeaderSplittingSink extends DataFlow::ExprNode {
3030
}
3131
}
3232

33-
class WhitelistedSource extends RemoteUserInput {
33+
class WhitelistedSource extends DataFlow::ExprNode {
3434
WhitelistedSource() {
3535
this.asExpr().(MethodAccess).getMethod() instanceof HttpServletRequestGetHeaderMethod or
3636
this.asExpr().(MethodAccess).getMethod() instanceof CookieGetNameMethod

java/ql/src/Security/CWE/CWE-129/ImproperValidationOfArrayConstruction.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import DataFlow::PathGraph
1717
class Conf extends TaintTracking::Configuration {
1818
Conf() { this = "RemoteUserInputTocanThrowOutOfBoundsDueToEmptyArrayConfig" }
1919

20-
override predicate isSource(DataFlow::Node source) { source instanceof RemoteUserInput }
20+
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
2121

2222
override predicate isSink(DataFlow::Node sink) {
2323
any(CheckableArrayAccess caa).canThrowOutOfBoundsDueToEmptyArray(sink.asExpr(), _)

java/ql/src/Security/CWE/CWE-129/ImproperValidationOfArrayIndex.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import DataFlow::PathGraph
1717
class Conf extends TaintTracking::Configuration {
1818
Conf() { this = "RemoteUserInputTocanThrowOutOfBoundsDueToEmptyArrayConfig" }
1919

20-
override predicate isSource(DataFlow::Node source) { source instanceof RemoteUserInput }
20+
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
2121

2222
override predicate isSink(DataFlow::Node sink) {
2323
any(CheckableArrayAccess caa).canThrowOutOfBounds(sink.asExpr())

java/ql/src/Security/CWE/CWE-134/ExternallyControlledFormatString.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import DataFlow::PathGraph
1717
class ExternallyControlledFormatStringConfig extends TaintTracking::Configuration {
1818
ExternallyControlledFormatStringConfig() { this = "ExternallyControlledFormatStringConfig" }
1919

20-
override predicate isSource(DataFlow::Node source) { source instanceof RemoteUserInput }
20+
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
2121

2222
override predicate isSink(DataFlow::Node sink) {
2323
sink.asExpr() = any(StringFormat formatCall).getFormatArgument()

java/ql/src/Security/CWE/CWE-190/ArithmeticTainted.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ predicate sink(ArithExpr exp, VarAccess tainted, string effect) {
3232
class RemoteUserInputConfig extends TaintTracking::Configuration {
3333
RemoteUserInputConfig() { this = "ArithmeticTainted.ql:RemoteUserInputConfig" }
3434

35-
override predicate isSource(DataFlow::Node source) { source instanceof RemoteUserInput }
35+
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
3636

3737
override predicate isSink(DataFlow::Node sink) { sink(_, sink.asExpr(), _) }
3838

0 commit comments

Comments
 (0)