mirror of
https://github.com/github/codeql.git
synced 2026-04-29 10:45:15 +02:00
Python: Support short mode flags (e.g. re.M) in regexes.
This commit is contained in:
@@ -128,6 +128,20 @@ class BottleRoutePointToExtension extends PointsToExtension {
|
||||
|
||||
/* Python 3.6+ regex module constants */
|
||||
|
||||
string short_flag(string flag) {
|
||||
(flag = "ASCII" or
|
||||
flag = "IGNORECASE" or
|
||||
flag = "LOCALE" or
|
||||
flag = "UNICODE" or
|
||||
flag = "MULTILINE" or
|
||||
flag = "TEMPLATE")
|
||||
and result = flag.prefix(1)
|
||||
or
|
||||
flag = "DOTALL" and result = "S"
|
||||
or
|
||||
flag = "VERBOSE" and result = "X"
|
||||
}
|
||||
|
||||
class ReModulePointToExtension extends PointsToExtension {
|
||||
|
||||
string name;
|
||||
@@ -139,9 +153,10 @@ class ReModulePointToExtension extends PointsToExtension {
|
||||
}
|
||||
|
||||
override predicate pointsTo(Context context, ObjectInternal value, ControlFlowNode origin) {
|
||||
exists(ModuleObjectInternal sre_constants, CfgOrigin orig |
|
||||
exists(ModuleObjectInternal sre_constants, CfgOrigin orig, string flag |
|
||||
(name = flag or name = short_flag(flag)) and
|
||||
sre_constants.getName() = "sre_constants" and
|
||||
sre_constants.attribute("SRE_FLAG_" + name, value, orig) and
|
||||
sre_constants.attribute("SRE_FLAG_" + flag, value, orig) and
|
||||
origin = orig.asCfgNodeOrHere(this)
|
||||
)
|
||||
and pointsTo_helper(context)
|
||||
|
||||
Reference in New Issue
Block a user