@@ -20,21 +20,34 @@ abstract class FlagKind extends string {
2020 bindingset [ result ]
2121 abstract string getAFlagName ( ) ;
2222
23+ private predicate flagFlowStepTC ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
24+ node2 = node1 and
25+ isFlagWithName ( node1 )
26+ or
27+ exists ( DataFlow:: Node nodeMid |
28+ flagFlowStep ( nodeMid , node2 ) and
29+ flagFlowStepTC ( node1 , nodeMid )
30+ )
31+ }
32+
33+ private predicate isFlagWithName ( DataFlow:: Node flag ) {
34+ exists ( VarAccess v | v .getVariable ( ) .getName ( ) = getAFlagName ( ) |
35+ flag .asExpr ( ) = v and v .getType ( ) instanceof FlagType
36+ )
37+ or
38+ exists ( StringLiteral s | s .getValue ( ) = getAFlagName ( ) | flag .asExpr ( ) = s )
39+ or
40+ exists ( MethodAccess ma | ma .getMethod ( ) .getName ( ) = getAFlagName ( ) |
41+ flag .asExpr ( ) = ma and
42+ ma .getType ( ) instanceof FlagType
43+ )
44+ }
45+
2346 /** Gets a node representing a (likely) security flag. */
2447 DataFlow:: Node getAFlag ( ) {
2548 exists ( DataFlow:: Node flag |
26- exists ( VarAccess v | v .getVariable ( ) .getName ( ) = getAFlagName ( ) |
27- flag .asExpr ( ) = v and v .getType ( ) instanceof FlagType
28- )
29- or
30- exists ( StringLiteral s | s .getValue ( ) = getAFlagName ( ) | flag .asExpr ( ) = s )
31- or
32- exists ( MethodAccess ma | ma .getMethod ( ) .getName ( ) = getAFlagName ( ) |
33- flag .asExpr ( ) = ma and
34- ma .getType ( ) instanceof FlagType
35- )
36- |
37- flagFlowStep * ( flag , result )
49+ isFlagWithName ( flag ) and
50+ flagFlowStepTC ( flag , result )
3851 )
3952 }
4053}
0 commit comments