Skip to content

Commit

Permalink
fix trim misuse
Browse files Browse the repository at this point in the history
  • Loading branch information
GrosQuildu authored and mschwager committed Jul 8, 2024
1 parent 3737840 commit 37062f5
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions go/src/security/TrimMisuse/TrimMisuse.ql
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,23 @@
*/

import go
import DataFlow
import DataFlow2

/*
* Flows from a string to TrimFamilyCall cutSet argument
*/
class Trim2ndArg extends DataFlow::Configuration {
Trim2ndArg() { this = "Trim2ndArg" }

override predicate isSource(DataFlow::Node source) {
module Trim2ndArgConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
source.asExpr() instanceof StringLit
}

override predicate isSink(DataFlow::Node sink) {
predicate isSink(DataFlow::Node sink) {
exists(TrimFamilyCall trimCall |
sink.asExpr() = trimCall.getCutSetArg()
)
}
}
module Trim2ndArgFlow = DataFlow::Global<Trim2ndArgConfig>;

/*
* Calls to Trim methods that we are interested in
Expand All @@ -49,8 +48,8 @@ class TrimFamilyCall extends CallNode {
from TrimFamilyCall trimCall, StringLit cutset
where
// get 2nd argument value, if possible
exists(Trim2ndArg config, DataFlow::Node source, DataFlow::Node sink |
config.hasFlow(source, sink)
exists(DataFlow::Node source, DataFlow::Node sink |
Trim2ndArgFlow::flow(source, sink)
and source.asExpr() = cutset
and sink.asExpr() = trimCall.getCutSetArg()
)
Expand Down

0 comments on commit 37062f5

Please sign in to comment.