Python: Replace '.prefix'/'.suffix' with '.matches'.

This commit is contained in:
Mathias Vorreiter Pedersen
2021-10-13 13:19:58 +01:00
parent f3bb0a676e
commit a80860cdc6
7 changed files with 8 additions and 8 deletions

View File

@@ -11,7 +11,7 @@ class HasTypeFact extends CustomPointsToOriginFact {
exists(FunctionObject func, string name |
func.getACall() = this and
name = func.getName() and
name.prefix("has_type_".length()) = "has_type_"
name.matches("has\\_type\\_%")
)
}
@@ -19,7 +19,7 @@ class HasTypeFact extends CustomPointsToOriginFact {
exists(FunctionObject func, string name |
func.getACall() = this and
name = func.getName() and
name.prefix("has_type_".length()) = "has_type_"
name.matches("has\\_type\\_%")
|
cls.getName() = name.suffix("has_type_".length())
) and

View File

@@ -104,7 +104,7 @@ predicate ssa_consistency(string clsname, string problem, string what) {
or
exists(EssaDefinition def |
clsname = def.getAQlClass() and
clsname.prefix(4) = "Essa" and
clsname.matches("Essa%") and
what = " at " + def.getLocation() and
problem = "not covered by Python-specific subclass."
)

View File

@@ -28,7 +28,7 @@ class SimpleSource extends TaintSource {
predicate visit_call(CallNode call, FunctionObject func) {
exists(AttrNode attr, ClassObject cls, string name |
name.prefix(6) = "visit_" and
name.matches("visit\\_%") and
func = cls.lookupAttribute(name) and
attr.getObject("visit").refersTo(_, cls, _) and
attr = call.getFunction()