@@ -20,21 +20,34 @@ abstract class FlagKind extends string {
20
20
bindingset [ result ]
21
21
abstract string getAFlagName ( ) ;
22
22
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
+
23
46
/** Gets a node representing a (likely) security flag. */
24
47
DataFlow:: Node getAFlag ( ) {
25
48
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 )
38
51
)
39
52
}
40
53
}
0 commit comments