Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 00ea023

Browse files
committed
Make ConditionalBypass use new API
1 parent 1b4fef9 commit 00ea023

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

go/ql/src/experimental/CWE-840/ConditionalBypass.ql

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@ import go
1515
/**
1616
* A taint-tracking configuration for reasoning about conditional bypass.
1717
*/
18-
class Configuration extends TaintTracking::Configuration {
19-
Configuration() { this = "ConditionalBypass" }
20-
21-
override predicate isSource(DataFlow::Node source) {
18+
module Config implements DataFlow::ConfigSig {
19+
predicate isSource(DataFlow::Node source) {
2220
source instanceof UntrustedFlowSource
2321
or
2422
source = any(Field f | f.hasQualifiedName("net/http", "Request", "Host")).getARead()
2523
}
2624

27-
override predicate isSink(DataFlow::Node sink) {
25+
predicate isSink(DataFlow::Node sink) {
2826
exists(ComparisonExpr c | c.getAnOperand() = sink.asExpr())
2927
}
3028
}
3129

30+
module Flow = TaintTracking::Global<Config>;
31+
3232
from
33-
Configuration config, DataFlow::PathNode lhsSource, DataFlow::PathNode lhs,
34-
DataFlow::PathNode rhsSource, DataFlow::PathNode rhs, ComparisonExpr c
33+
DataFlow::Node lhsSource, DataFlow::Node lhs, DataFlow::Node rhsSource, DataFlow::Node rhs,
34+
ComparisonExpr c
3535
where
36-
config.hasFlowPath(rhsSource, rhs) and
37-
rhs.getNode().asExpr() = c.getRightOperand() and
38-
config.hasFlowPath(lhsSource, lhs) and
39-
lhs.getNode().asExpr() = c.getLeftOperand()
40-
select c, "This comparison of a $@ with another $@ can be bypassed by a malicious user.",
41-
lhsSource.getNode(), "user-controlled value", rhsSource.getNode(), "user-controlled value"
36+
Flow::flow(rhsSource, rhs) and
37+
rhs.asExpr() = c.getRightOperand() and
38+
Flow::flow(lhsSource, lhs) and
39+
lhs.asExpr() = c.getLeftOperand()
40+
select c, "This comparison of a $@ with another $@ can be bypassed by a malicious user.", lhsSource,
41+
"user-controlled value", rhsSource, "user-controlled value"

0 commit comments

Comments
 (0)