Skip to content

Commit 1df81db

Browse files
committed
Use regex-use[receiver] instead of regex-use[-1]
1 parent 2fe74a8 commit 1df81db

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

go/ql/lib/semmle/go/frameworks/stdlib/Regexp.qll

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ module Regexp {
99
/**
1010
* Holds if `kind` is an external sink kind that is relevant for regex flow.
1111
* `strArg` is the index of the argument to methods with this sink kind that
12-
* contain the string to be matched against, where -1 is the qualifier; or -2
13-
* if no such argument exists and the function compiles the regex; or -3 if
14-
* no such argument exists and the function does not compile the regex.
12+
* contain the string to be matched against, where "receiver" indicates the
13+
* receiver; or -2 if no such argument exists and the function compiles the
14+
* regex; or -3 if no such argument exists and the function does not compile
15+
* the regex.
1516
*
1617
* So `regex-use[0]` indicates that argument 0 contains the string to matched
1718
* against, `regex-use[c]` indicates that there is no string to be matched
@@ -25,8 +26,12 @@ module Regexp {
2526
or
2627
sinkModel(_, _, _, _, _, _, _, kind, _, _) and
2728
exists(string strArgStr |
29+
strArg >= 0 and
2830
strArgStr.toInt() = strArg
2931
or
32+
strArg = -1 and
33+
strArgStr = "receiver"
34+
or
3035
strArg = -2 and
3136
strArgStr = "c"
3237
|

0 commit comments

Comments
 (0)