Skip to content

Commit 37062f5

Browse files
GrosQuildumschwager
authored andcommitted
fix trim misuse
1 parent 3737840 commit 37062f5

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

go/src/security/TrimMisuse/TrimMisuse.ql

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,23 @@
1111
*/
1212

1313
import go
14-
import DataFlow
14+
import DataFlow2
1515

1616
/*
1717
* Flows from a string to TrimFamilyCall cutSet argument
1818
*/
19-
class Trim2ndArg extends DataFlow::Configuration {
20-
Trim2ndArg() { this = "Trim2ndArg" }
21-
22-
override predicate isSource(DataFlow::Node source) {
19+
module Trim2ndArgConfig implements DataFlow::ConfigSig {
20+
predicate isSource(DataFlow::Node source) {
2321
source.asExpr() instanceof StringLit
2422
}
2523

26-
override predicate isSink(DataFlow::Node sink) {
24+
predicate isSink(DataFlow::Node sink) {
2725
exists(TrimFamilyCall trimCall |
2826
sink.asExpr() = trimCall.getCutSetArg()
2927
)
3028
}
3129
}
30+
module Trim2ndArgFlow = DataFlow::Global<Trim2ndArgConfig>;
3231

3332
/*
3433
* Calls to Trim methods that we are interested in
@@ -49,8 +48,8 @@ class TrimFamilyCall extends CallNode {
4948
from TrimFamilyCall trimCall, StringLit cutset
5049
where
5150
// get 2nd argument value, if possible
52-
exists(Trim2ndArg config, DataFlow::Node source, DataFlow::Node sink |
53-
config.hasFlow(source, sink)
51+
exists(DataFlow::Node source, DataFlow::Node sink |
52+
Trim2ndArgFlow::flow(source, sink)
5453
and source.asExpr() = cutset
5554
and sink.asExpr() = trimCall.getCutSetArg()
5655
)

0 commit comments

Comments
 (0)