Skip to content

Commit 1c68c98

Browse files
committed
Python: Change all remaining occurrences of StrConst
Done using ``` git grep StrConst | xargs sed -i 's/StrConst/StringLiteral/g' ```
1 parent f6487d7 commit 1c68c98

File tree

101 files changed

+211
-211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+211
-211
lines changed

python/ql/examples/snippets/raw_string.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88

99
import python
1010

11-
from StrConst s
11+
from StringLiteral s
1212
where s.getPrefix().matches("%r%")
1313
select s

python/ql/examples/snippets/singlequotestring.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
import python
1111

12-
from StrConst s
12+
from StringLiteral s
1313
where s.getPrefix().charAt(_) = "'"
1414
select s

python/ql/lib/analysis/DefinitionTracking.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ private predicate sets_attribute(ArgumentRefinement def, string name) {
410410
call = def.getDefiningNode() and
411411
call.getFunction().refersTo(Object::builtin("setattr")) and
412412
def.getInput().getAUse() = call.getArg(0) and
413-
call.getArg(1).getNode().(StrConst).getText() = name
413+
call.getArg(1).getNode().(StringLiteral).getText() = name
414414
)
415415
}
416416

python/ql/lib/experimental/cryptography/modules/stdlib/HashlibModule.qll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ module Hashes {
2626
}
2727

2828
override string getName() {
29-
result = super.normalizeName(this.asExpr().(StrConst).getText())
29+
result = super.normalizeName(this.asExpr().(StringLiteral).getText())
3030
or
3131
// if not a known/static string, assume from an outside source and the algorithm is UNKNOWN
32-
not this.asExpr() instanceof StrConst and result = unknownAlgorithm()
32+
not this.asExpr() instanceof StringLiteral and result = unknownAlgorithm()
3333
}
3434
}
3535

@@ -49,10 +49,10 @@ module Hashes {
4949
}
5050

5151
override string getName() {
52-
result = super.normalizeName(this.asExpr().(StrConst).getText())
52+
result = super.normalizeName(this.asExpr().(StringLiteral).getText())
5353
or
5454
// if not a known/static string, assume from an outside source and the algorithm is UNKNOWN
55-
not this.asExpr() instanceof StrConst and result = unknownAlgorithm()
55+
not this.asExpr() instanceof StringLiteral and result = unknownAlgorithm()
5656
}
5757
}
5858

@@ -88,9 +88,9 @@ module Hashes {
8888
// Name is a string constant or consider the name unknown
8989
// NOTE: we are excluding hmac.new and hmac.HMAC constructor calls so we are expecting
9090
// a string or an outside configuration only
91-
result = super.normalizeName(this.asExpr().(StrConst).getText())
91+
result = super.normalizeName(this.asExpr().(StringLiteral).getText())
9292
or
93-
not this.asExpr() instanceof StrConst and
93+
not this.asExpr() instanceof StringLiteral and
9494
result = unknownAlgorithm()
9595
}
9696
}

python/ql/lib/experimental/cryptography/modules/stdlib/HmacModule.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ module Hashes {
6262
then result = super.normalizeName("MD5")
6363
else (
6464
// Else get the string name, if its a string constant, or UNKNOWN if otherwise
65-
result = super.normalizeName(this.asExpr().(StrConst).getText())
65+
result = super.normalizeName(this.asExpr().(StringLiteral).getText())
6666
or
67-
not this.asExpr() instanceof StrConst and result = unknownAlgorithm()
67+
not this.asExpr() instanceof StringLiteral and result = unknownAlgorithm()
6868
)
6969
}
7070
}

python/ql/lib/semmle/python/ApiGraphs.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ module API {
257257
*/
258258
Node getSubscript(string key) {
259259
exists(API::Node index | result = this.getSubscriptAt(index) |
260-
key = index.getAValueReachingSink().asExpr().(PY::StrConst).getText()
260+
key = index.getAValueReachingSink().asExpr().(PY::StringLiteral).getText()
261261
)
262262
}
263263

python/ql/lib/semmle/python/Concepts.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ module Http {
855855

856856
/** Gets the URL pattern for this route, if it can be statically determined. */
857857
string getUrlPattern() {
858-
exists(StrConst str |
858+
exists(StringLiteral str |
859859
this.getUrlPatternArg().getALocalSource() = DataFlow::exprNode(str) and
860860
result = str.getText()
861861
)
@@ -983,7 +983,7 @@ module Http {
983983

984984
/** Gets the mimetype of this HTTP response, if it can be statically determined. */
985985
string getMimetype() {
986-
exists(StrConst str |
986+
exists(StringLiteral str |
987987
this.getMimetypeOrContentTypeArg().getALocalSource() = DataFlow::exprNode(str) and
988988
result = str.getText().splitAt(";", 0)
989989
)

python/ql/lib/semmle/python/Files.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class File extends Container, Impl::File {
9393
exists(Stmt s | s.getLocation().getFile() = this)
9494
or
9595
// The file contains the usual `if __name__ == '__main__':` construction
96-
exists(If i, Name name, StrConst main, Cmpop op |
96+
exists(If i, Name name, StringLiteral main, Cmpop op |
9797
i.getScope().(Module).getFile() = this and
9898
op instanceof Eq and
9999
i.getTest().(Compare).compares(name, op, main) and
@@ -123,7 +123,7 @@ private predicate occupied_line(File f, int n) {
123123
exists(Location l | l.getFile() = f |
124124
l.getStartLine() = n
125125
or
126-
exists(StrConst s | s.getLocation() = l | n in [l.getStartLine() .. l.getEndLine()])
126+
exists(StringLiteral s | s.getLocation() = l | n in [l.getStartLine() .. l.getEndLine()])
127127
)
128128
}
129129

python/ql/lib/semmle/python/Module.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ class Module extends Module_, Scope, AstNode {
125125
a.getScope() = this and
126126
all.getId() = "__all__" and
127127
(
128-
a.getValue().(List).getAnElt().(StrConst).getText() = name
128+
a.getValue().(List).getAnElt().(StringLiteral).getText() = name
129129
or
130-
a.getValue().(Tuple).getAnElt().(StrConst).getText() = name
130+
a.getValue().(Tuple).getAnElt().(StringLiteral).getText() = name
131131
)
132132
)
133133
}

python/ql/lib/semmle/python/PrintAst.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,13 @@ class ParameterNode extends AstElementNode {
423423
}
424424

425425
/**
426-
* A print node for a `StrConst`.
426+
* A print node for a `StringLiteral`.
427427
*
428428
* The string has a child, if the child is used as a regular expression,
429429
* which is the root of the regular expression.
430430
*/
431-
class StrConstNode extends AstElementNode {
432-
override StrConst element;
431+
class StringLiteralNode extends AstElementNode {
432+
override StringLiteral element;
433433
}
434434

435435
/**
@@ -599,7 +599,7 @@ private module PrettyPrinting {
599599
or
600600
result = "class " + a.(Class).getName()
601601
or
602-
result = a.(StrConst).getText()
602+
result = a.(StringLiteral).getText()
603603
or
604604
result = "yield " + a.(Yield).getValue()
605605
or

0 commit comments

Comments
 (0)