Skip to content

Commit

Permalink
Ruby: Fix StringSubstitutionCall charpred
Browse files Browse the repository at this point in the history
Some missing parens meant this class targeted way more things than
intended.
  • Loading branch information
hmac committed May 1, 2024
1 parent 397e641 commit f7fc2e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ruby/ql/lib/codeql/ruby/frameworks/core/String.qll
Original file line number Diff line number Diff line change
Expand Up @@ -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())
)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f7fc2e0

Please sign in to comment.