Skip to content

Commit cf92e1e

Browse files
committed
Python: move getStringArgIndex
1 parent 61008fd commit cf92e1e

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

python/ql/lib/semmle/python/frameworks/Stdlib.qll

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,15 +1584,15 @@ private module StdlibPrivate {
15841584
RegexExecutionMethod() {
15851585
this in ["match", "fullmatch", "search", "split", "findall", "finditer", "sub", "subn"]
15861586
}
1587-
}
15881587

1589-
/** Gets the index of the argument representing the string to be searched by a regex. */
1590-
int getStringArgIndex(RegexExecutionMethod method) {
1591-
method in ["match", "fullmatch", "search", "split", "findall", "finditer"] and
1592-
result = 1
1593-
or
1594-
method in ["sub", "subn"] and
1595-
result = 2
1588+
/** Gets the index of the argument representing the string to be searched by a regex. */
1589+
int getStringArgIndex() {
1590+
this in ["match", "fullmatch", "search", "split", "findall", "finditer"] and
1591+
result = 1
1592+
or
1593+
this in ["sub", "subn"] and
1594+
result = 2
1595+
}
15961596
}
15971597

15981598
/**
@@ -1608,7 +1608,7 @@ private module StdlibPrivate {
16081608
override DataFlow::Node getRegex() { result in [this.getArg(0), this.getArgByName("pattern")] }
16091609

16101610
override DataFlow::Node getString() {
1611-
result in [this.getArg(getStringArgIndex(method)), this.getArgByName("string")]
1611+
result in [this.getArg(method.getStringArgIndex()), this.getArgByName("string")]
16121612
}
16131613

16141614
override string getName() { result = "re." + method }
@@ -1656,17 +1656,17 @@ private module StdlibPrivate {
16561656
*/
16571657
private class CompiledRegexExecution extends DataFlow::MethodCallNode, RegexExecution::Range {
16581658
DataFlow::Node regexNode;
1659-
RegexExecutionMethod methodName;
1659+
RegexExecutionMethod method;
16601660

1661-
CompiledRegexExecution() { this.calls(compiledRegex(regexNode), methodName) }
1661+
CompiledRegexExecution() { this.calls(compiledRegex(regexNode), method) }
16621662

16631663
override DataFlow::Node getRegex() { result = regexNode }
16641664

16651665
override DataFlow::Node getString() {
1666-
result in [this.getArg(getStringArgIndex(methodName) - 1), this.getArgByName("string")]
1666+
result in [this.getArg(method.getStringArgIndex() - 1), this.getArgByName("string")]
16671667
}
16681668

1669-
override string getName() { result = "re." + methodName }
1669+
override string getName() { result = "re." + method }
16701670
}
16711671

16721672
/**

0 commit comments

Comments
 (0)