Skip to content

Commit

Permalink
Use regex-use[receiver] instead of regex-use[-1]
Browse files Browse the repository at this point in the history
  • Loading branch information
owen-mc committed Aug 10, 2024
1 parent 2fe74a8 commit 1df81db
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions go/ql/lib/semmle/go/frameworks/stdlib/Regexp.qll
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ module Regexp {
/**
* Holds if `kind` is an external sink kind that is relevant for regex flow.
* `strArg` is the index of the argument to methods with this sink kind that
* contain the string to be matched against, where -1 is the qualifier; or -2
* if no such argument exists and the function compiles the regex; or -3 if
* no such argument exists and the function does not compile the regex.
* contain the string to be matched against, where "receiver" indicates the
* receiver; or -2 if no such argument exists and the function compiles the
* regex; or -3 if no such argument exists and the function does not compile
* the regex.
*
* So `regex-use[0]` indicates that argument 0 contains the string to matched
* against, `regex-use[c]` indicates that there is no string to be matched
Expand All @@ -25,8 +26,12 @@ module Regexp {
or
sinkModel(_, _, _, _, _, _, _, kind, _, _) and
exists(string strArgStr |
strArg >= 0 and
strArgStr.toInt() = strArg
or
strArg = -1 and
strArgStr = "receiver"
or
strArg = -2 and
strArgStr = "c"
|
Expand Down

0 comments on commit 1df81db

Please sign in to comment.