Skip to content

Commit

Permalink
Expand ReplaceAll in sanitizer
Browse files Browse the repository at this point in the history
  • Loading branch information
owen-mc committed Apr 11, 2024
1 parent c3fefa8 commit a7c5e84
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions go/ql/lib/semmle/go/security/TaintedPathCustomizations.qll
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,8 @@ module TaintedPath {
* A replacement of the form `!strings.ReplaceAll(nd, "..")` or `!strings.ReplaceAll(nd, ".")`, considered as a sanitizer for
* path traversal.
*/
class DotDotReplace extends Sanitizer {
DotDotReplace() {
exists(DataFlow::CallNode cleanCall, DataFlow::Node valueNode |
cleanCall = any(Function f | f.hasQualifiedName("strings", "ReplaceAll")).getACall() and
valueNode = cleanCall.getArgument(1) and
valueNode.asExpr().(StringLit).getValue() = ["..", "."] and
this = cleanCall.getResult()
)
}
class DotDotReplaceAll extends StringOps::ReplaceAll, Sanitizer {
DotDotReplaceAll() { this.getReplacedString() = ["..", "."] }
}

/**
Expand Down

0 comments on commit a7c5e84

Please sign in to comment.