GeezerVison is showing github.com — Python: Change all remaining occurrences of `StrConst` · github/codeql@1c68c98
File treeExpand file treeCollapse file tree Open diff view settings experimental/cryptography/modules/stdlib
CWE-287-ConstantSecretKey
extractor-tests/multibyte
library-tests/locations/general
locations/implicit_concatenation
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: python/ql/examples/snippets/raw_string.ql +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 8 | 8 |
| 9 | 9 | import python | 10 | 10 |
| 11 | | -from StrConst s | | 11 | +from StringLiteral s | 12 | 12 | where s.getPrefix().matches("%r%") | 13 | 13 | select s |
Collapse file Copy file name to clipboardExpand all lines: python/ql/examples/snippets/singlequotestring.ql +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 |
| 10 | 10 | import python | 11 | 11 |
| 12 | | -from StrConst s | | 12 | +from StringLiteral s | 13 | 13 | where s.getPrefix().charAt(_) = "'" | 14 | 14 | select s |
Collapse file Copy file name to clipboardExpand all lines: python/ql/lib/analysis/DefinitionTracking.qll +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -410,7 +410,7 @@ private predicate sets_attribute(ArgumentRefinement def, string name) { | 410 | 410 | call = def.getDefiningNode() and | 411 | 411 | call.getFunction().refersTo(Object::builtin("setattr")) and | 412 | 412 | def.getInput().getAUse() = call.getArg(0) and | 413 | | - call.getArg(1).getNode().(StrConst).getText() = name | | 413 | + call.getArg(1).getNode().(StringLiteral).getText() = name | 414 | 414 | ) | 415 | 415 | } | 416 | 416 |
| |
Collapse file Copy file name to clipboardExpand all lines: python/ql/lib/experimental/cryptography/modules/stdlib/HashlibModule.qll +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -26,10 +26,10 @@ module Hashes { | 26 | 26 | } | 27 | 27 |
| 28 | 28 | override string getName() { | 29 | | - result = super.normalizeName(this.asExpr().(StrConst).getText()) | | 29 | + result = super.normalizeName(this.asExpr().(StringLiteral).getText()) | 30 | 30 | or | 31 | 31 | // 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() | 33 | 33 | } | 34 | 34 | } | 35 | 35 |
| @@ -49,10 +49,10 @@ module Hashes { | 49 | 49 | } | 50 | 50 |
| 51 | 51 | override string getName() { | 52 | | - result = super.normalizeName(this.asExpr().(StrConst).getText()) | | 52 | + result = super.normalizeName(this.asExpr().(StringLiteral).getText()) | 53 | 53 | or | 54 | 54 | // 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() | 56 | 56 | } | 57 | 57 | } | 58 | 58 |
| @@ -88,9 +88,9 @@ module Hashes { | 88 | 88 | // Name is a string constant or consider the name unknown | 89 | 89 | // NOTE: we are excluding hmac.new and hmac.HMAC constructor calls so we are expecting | 90 | 90 | // a string or an outside configuration only | 91 | | - result = super.normalizeName(this.asExpr().(StrConst).getText()) | | 91 | + result = super.normalizeName(this.asExpr().(StringLiteral).getText()) | 92 | 92 | or | 93 | | - not this.asExpr() instanceof StrConst and | | 93 | + not this.asExpr() instanceof StringLiteral and | 94 | 94 | result = unknownAlgorithm() | 95 | 95 | } | 96 | 96 | } | |
Collapse file Copy file name to clipboardExpand all lines: python/ql/lib/experimental/cryptography/modules/stdlib/HmacModule.qll +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -62,9 +62,9 @@ module Hashes { | 62 | 62 | then result = super.normalizeName("MD5") | 63 | 63 | else ( | 64 | 64 | // 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()) | 66 | 66 | or | 67 | | - not this.asExpr() instanceof StrConst and result = unknownAlgorithm() | | 67 | + not this.asExpr() instanceof StringLiteral and result = unknownAlgorithm() | 68 | 68 | ) | 69 | 69 | } | 70 | 70 | } | |
Collapse file Copy file name to clipboardExpand all lines: python/ql/lib/semmle/python/ApiGraphs.qll +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -257,7 +257,7 @@ module API { | 257 | 257 | */ | 258 | 258 | Node getSubscript(string key) { | 259 | 259 | exists(API::Node index | result = this.getSubscriptAt(index) | | 260 | | - key = index.getAValueReachingSink().asExpr().(PY::StrConst).getText() | | 260 | + key = index.getAValueReachingSink().asExpr().(PY::StringLiteral).getText() | 261 | 261 | ) | 262 | 262 | } | 263 | 263 |
| |
Collapse file Copy file name to clipboardExpand all lines: python/ql/lib/semmle/python/Concepts.qll +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -855,7 +855,7 @@ module Http { | 855 | 855 |
| 856 | 856 | /** Gets the URL pattern for this route, if it can be statically determined. */ | 857 | 857 | string getUrlPattern() { | 858 | | - exists(StrConst str | | | 858 | + exists(StringLiteral str | | 859 | 859 | this.getUrlPatternArg().getALocalSource() = DataFlow::exprNode(str) and | 860 | 860 | result = str.getText() | 861 | 861 | ) | @@ -983,7 +983,7 @@ module Http { | 983 | 983 |
| 984 | 984 | /** Gets the mimetype of this HTTP response, if it can be statically determined. */ | 985 | 985 | string getMimetype() { | 986 | | - exists(StrConst str | | | 986 | + exists(StringLiteral str | | 987 | 987 | this.getMimetypeOrContentTypeArg().getALocalSource() = DataFlow::exprNode(str) and | 988 | 988 | result = str.getText().splitAt(";", 0) | 989 | 989 | ) | |
Collapse file Copy file name to clipboardExpand all lines: python/ql/lib/semmle/python/Files.qll +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -93,7 +93,7 @@ class File extends Container, Impl::File { | 93 | 93 | exists(Stmt s | s.getLocation().getFile() = this) | 94 | 94 | or | 95 | 95 | // 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 | | 97 | 97 | i.getScope().(Module).getFile() = this and | 98 | 98 | op instanceof Eq and | 99 | 99 | i.getTest().(Compare).compares(name, op, main) and | @@ -123,7 +123,7 @@ private predicate occupied_line(File f, int n) { | 123 | 123 | exists(Location l | l.getFile() = f | | 124 | 124 | l.getStartLine() = n | 125 | 125 | 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()]) | 127 | 127 | ) | 128 | 128 | } | 129 | 129 |
| |
Collapse file Copy file name to clipboardExpand all lines: python/ql/lib/semmle/python/Module.qll +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -125,9 +125,9 @@ class Module extends Module_, Scope, AstNode { | 125 | 125 | a.getScope() = this and | 126 | 126 | all.getId() = "__all__" and | 127 | 127 | ( | 128 | | - a.getValue().(List).getAnElt().(StrConst).getText() = name | | 128 | + a.getValue().(List).getAnElt().(StringLiteral).getText() = name | 129 | 129 | or | 130 | | - a.getValue().(Tuple).getAnElt().(StrConst).getText() = name | | 130 | + a.getValue().(Tuple).getAnElt().(StringLiteral).getText() = name | 131 | 131 | ) | 132 | 132 | ) | 133 | 133 | } | |
Collapse file Copy file name to clipboardExpand all lines: python/ql/lib/semmle/python/PrintAst.qll +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -423,13 +423,13 @@ class ParameterNode extends AstElementNode { | 423 | 423 | } | 424 | 424 |
| 425 | 425 | /** | 426 | | - * A print node for a `StrConst`. | | 426 | + * A print node for a `StringLiteral`. | 427 | 427 | * | 428 | 428 | * The string has a child, if the child is used as a regular expression, | 429 | 429 | * which is the root of the regular expression. | 430 | 430 | */ | 431 | | -class StrConstNode extends AstElementNode { | 432 | | - override StrConst element; | | 431 | +class StringLiteralNode extends AstElementNode { | | 432 | + override StringLiteral element; | 433 | 433 | } | 434 | 434 |
| 435 | 435 | /** | @@ -599,7 +599,7 @@ private module PrettyPrinting { | 599 | 599 | or | 600 | 600 | result = "class " + a.(Class).getName() | 601 | 601 | or | 602 | | - result = a.(StrConst).getText() | | 602 | + result = a.(StringLiteral).getText() | 603 | 603 | or | 604 | 604 | result = "yield " + a.(Yield).getValue() | 605 | 605 | or | |
|