mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
C++/Java/Python: Allow Python string prefix in InlineExpectationsTest
I've been writing tests for crypto libraries in Python, and have wanted to write code along the lines of ```py md5.hash(b"some message") # $ HashInput=b"some message" ``` which didn't work before this commit, forcing me to store my text in a variable like below. This turned out to be really annoying when dealing with more complex examples, so therefore I'm adding this new functionality to allow this behavior. ```py msg = b"some message" md5.hash(msg) # $ HashInput=msg ```
This commit is contained in:
@@ -233,7 +233,9 @@ private string expectationPattern() {
|
||||
exists(string tag, string tags, string value |
|
||||
tag = "[A-Za-z-_][A-Za-z-_0-9]*" and
|
||||
tags = "((?:" + tag + ")(?:\\s*,\\s*" + tag + ")*)" and
|
||||
value = "((?:\"[^\"]*\"|'[^']*'|\\S+)*)" and
|
||||
// In Python, we allow both `"` and `'` for strings, as well as the prefixes `bru`.
|
||||
// For example, `b"foo"`.
|
||||
value = "((?:[bru]*\"[^\"]*\"|[bru]*'[^']*'|\\S+)*)" and
|
||||
result = tags + "(?:=" + value + ")?"
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user