Fix performance change in SecurityFlag

This commit is contained in:
Tamas Vajk
2022-06-21 15:17:02 +02:00
parent 79ec998636
commit 579bfc22f3

View File

@@ -20,9 +20,17 @@ abstract class FlagKind extends string {
bindingset[result] bindingset[result]
abstract string getAFlagName(); abstract string getAFlagName();
/** Gets a node representing a (likely) security flag. */ private predicate flagFlowStepTC(DataFlow::Node node1, DataFlow::Node node2) {
DataFlow::Node getAFlag() { node2 = node1 and
exists(DataFlow::Node flag | isFlagWithName(node1)
or
exists(DataFlow::Node nodeMid |
flagFlowStep(nodeMid, node2) and
flagFlowStepTC(node1, nodeMid)
)
}
private predicate isFlagWithName(DataFlow::Node flag) {
exists(VarAccess v | v.getVariable().getName() = getAFlagName() | exists(VarAccess v | v.getVariable().getName() = getAFlagName() |
flag.asExpr() = v and v.getType() instanceof FlagType flag.asExpr() = v and v.getType() instanceof FlagType
) )
@@ -33,8 +41,13 @@ abstract class FlagKind extends string {
flag.asExpr() = ma and flag.asExpr() = ma and
ma.getType() instanceof FlagType ma.getType() instanceof FlagType
) )
| }
flagFlowStep*(flag, result)
/** Gets a node representing a (likely) security flag. */
DataFlow::Node getAFlag() {
exists(DataFlow::Node flag |
isFlagWithName(flag) and
flagFlowStepTC(flag, result)
) )
} }
} }