Ruby: Fix StringSubstitutionCall charpred

Some missing parens meant this class targeted way more things than
intended.
This commit is contained in:
Harry Maclean
2024-05-01 16:13:39 +01:00
parent 397e641f2f
commit f7fc2e0b00
2 changed files with 10 additions and 3 deletions

View File

@@ -19,9 +19,11 @@ class StringSubstitutionCall extends DataFlow::CallNode {
StringSubstitutionCall() {
this.getMethodName() = ["sub", "sub!", "gsub", "gsub!"] and
exists(this.getReceiver()) and
this.getNumberOfArguments() = 2
or
this.getNumberOfArguments() = 1 and exists(this.getBlock())
(
this.getNumberOfArguments() = 2
or
this.getNumberOfArguments() = 1 and exists(this.getBlock())
)
}
/**

View File

@@ -268,3 +268,8 @@ def bad_path_sanitizer(p1, p2)
p1.sub! "/../", "" # NOT OK
p2.sub "/../", "" # NOT OK
end
def each_line_sanitizer(p1)
p1.each_line("\n") do |l| # OK - does no sanitization
end
end