Skip to content

Commit 72e6853

Browse files
author
Merdan Aziz
committed
address the review comments
1 parent 7072ab9 commit 72e6853

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

go/ql/src/experimental/CWE-770/DenialOfService.ql

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,21 @@
1313

1414
import go
1515

16-
class BuiltInMake extends DataFlow::Node {
17-
BuiltInMake() { this = Builtin::make().getACall().getArgument(0) }
18-
}
1916

2017
/**
21-
* Holds if `g` is a barrier-guard which checks `e` is nonzero on `branch`.
18+
* Class for defining a predicate to check for denial of service sanitizer guard.
2219
*/
2320
predicate denialOfServiceSanitizerGuard(DataFlow::Node g, Expr e, boolean branch) {
2421
exists(DataFlow::Node lesser |
2522
e = lesser.asExpr() and
26-
g.(DataFlow::RelationalComparisonNode).leq(branch, lesser, _, _)
27-
)
28-
or
29-
exists(LogicalBinaryExpr lbe, DataFlow::Node lesser |
30-
lbe.getAnOperand() = g.(DataFlow::RelationalComparisonNode).asExpr() and
31-
e = lesser.asExpr() and
32-
g.(DataFlow::RelationalComparisonNode).leq(branch, lesser, _, _)
23+
g.(DataFlow::RelationalComparisonNode).leq(branch, lesser, _, _) and
24+
not e.isConst()
3325
)
3426
}
3527

28+
/*
29+
* Module for defining predicates and tracking taint flow related to denial of service issues.
30+
*/
3631
module Config implements DataFlow::ConfigSig {
3732
predicate isSource(DataFlow::Node source) { source instanceof UntrustedFlowSource }
3833

@@ -48,7 +43,7 @@ module Config implements DataFlow::ConfigSig {
4843
node = DataFlow::BarrierGuard<denialOfServiceSanitizerGuard/3>::getABarrierNode()
4944
}
5045

51-
predicate isSink(DataFlow::Node sink) { sink instanceof BuiltInMake }
46+
predicate isSink(DataFlow::Node sink) { sink = Builtin::make().getACall().getArgument(0) }
5247
}
5348

5449
/**

0 commit comments

Comments
 (0)