Skip to content

Commit 658b88e

Browse files
Sim4n6yoff
andcommitted
Update python/ql/src/experimental/Security/CWE-770/UnicodeDoS.ql
update the Config API Co-authored-by: yoff <[email protected]>
1 parent 1f767b8 commit 658b88e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

python/ql/src/experimental/Security/CWE-770/UnicodeDoS.ql

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,15 @@ predicate underAValue(DataFlow::GuardNode g, ControlFlowNode node, boolean branc
8686
)
8787
}
8888

89-
class Configuration extends TaintTracking::Configuration {
90-
Configuration() { this = "RemoteSourcesReachUnicodeCharacters" }
89+
private module UnicodeDoSConfig implements DataFlow::ConfigSig {
90+
predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
9191

92-
override predicate isSource(DataFlow::Node source) { source instanceof RemoteFlowSource }
93-
94-
override predicate isSanitizer(DataFlow::Node sanitizer) {
92+
predicate isBarrier(DataFlow::Node sanitizer) {
9593
// underAValue is a check to ensure that the length of the user-provided value is limited to a certain amount
9694
sanitizer = DataFlow::BarrierGuard<underAValue/3>::getABarrierNode()
9795
}
9896

99-
override predicate isSink(DataFlow::Node sink) {
97+
predicate isSink(DataFlow::Node sink) {
10098
// Any call to the Unicode compatibility normalization is a costly operation
10199
sink = any(UnicodeCompatibilityNormalize ucn).getPathArg()
102100
or
@@ -113,9 +111,11 @@ class Configuration extends TaintTracking::Configuration {
113111
}
114112
}
115113

116-
import DataFlow::PathGraph
114+
module UnicodeDoSFlow = TaintTracking::Global<UnicodeDoSConfig>;
115+
116+
import UnicodeDoSFlow::PathGraph
117117

118-
from Configuration config, DataFlow::PathNode source, DataFlow::PathNode sink
119-
where config.hasFlowPath(source, sink)
118+
from UnicodeDoSFlow::PathNode source, UnicodeDoSFlow::PathNode sink
119+
where UnicodeDoSFlow::flowPath(source, sink)
120120
select sink.getNode(), source, sink, "This $@ can reach a $@.", source.getNode(),
121121
"user-provided value", sink.getNode(), "costly Unicode normalization operation"

0 commit comments

Comments
 (0)