@@ -22,64 +22,56 @@ abstract class SensitiveData extends DataFlow::Node {
22
22
}
23
23
24
24
/**
25
- * A function that might produce sensitive data.
26
- */
27
- private class SensitiveDataFunction extends Function {
28
- SensitiveDataClassification classification ;
29
-
30
- SensitiveDataFunction ( ) {
31
- HeuristicNames:: nameIndicatesSensitiveData ( this .getName ( ) .getText ( ) , classification )
32
- }
33
-
34
- SensitiveDataClassification getClassification ( ) { result = classification }
35
- }
36
-
37
- /**
38
- * A function call data flow node that might produce sensitive data.
25
+ * A function call or enum variant data flow node that might produce sensitive data.
39
26
*/
40
27
private class SensitiveDataCall extends SensitiveData {
41
28
SensitiveDataClassification classification ;
42
29
43
30
SensitiveDataCall ( ) {
44
- classification =
45
- this .asExpr ( )
46
- .getAstNode ( )
47
- .( CallExprBase )
48
- .getStaticTarget ( )
49
- .( SensitiveDataFunction )
50
- .getClassification ( )
31
+ exists ( CallExprBase call , string name |
32
+ call = this .asExpr ( ) .getExpr ( ) and
33
+ name =
34
+ [
35
+ call .getStaticTarget ( ) .( Function ) .getName ( ) .getText ( ) ,
36
+ call .( CallExpr ) .getVariant ( ) .getName ( ) .getText ( ) ,
37
+ ] and
38
+ HeuristicNames:: nameIndicatesSensitiveData ( name , classification )
39
+ )
51
40
}
52
41
53
42
override SensitiveDataClassification getClassification ( ) { result = classification }
54
43
}
55
44
56
45
/**
57
- * A variable that might contain sensitive data.
46
+ * A variable access data flow node that might be sensitive data.
58
47
*/
59
- private class SensitiveDataVariable extends Variable {
48
+ private class SensitiveVariableAccess extends SensitiveData {
60
49
SensitiveDataClassification classification ;
61
50
62
- SensitiveDataVariable ( ) {
63
- HeuristicNames:: nameIndicatesSensitiveData ( this .getText ( ) , classification )
51
+ SensitiveVariableAccess ( ) {
52
+ HeuristicNames:: nameIndicatesSensitiveData ( this .asExpr ( )
53
+ .getExpr ( )
54
+ .( VariableAccess )
55
+ .getVariable ( )
56
+ .( Variable )
57
+ .getText ( ) , classification )
64
58
}
65
59
66
- SensitiveDataClassification getClassification ( ) { result = classification }
60
+ override SensitiveDataClassification getClassification ( ) { result = classification }
67
61
}
68
62
63
+ private Expr fieldExprParentField ( FieldExpr fe ) { result = fe .getParentNode ( ) }
64
+
69
65
/**
70
- * A variable access data flow node that might produce sensitive data.
66
+ * A field access data flow node that might be sensitive data.
71
67
*/
72
- private class SensitiveVariableAccess extends SensitiveData {
68
+ private class SensitiveFieldAccess extends SensitiveData {
73
69
SensitiveDataClassification classification ;
74
70
75
- SensitiveVariableAccess ( ) {
76
- classification =
77
- this .asExpr ( )
78
- .getAstNode ( )
79
- .( VariableAccess )
80
- .getVariable ( )
81
- .( SensitiveDataVariable )
82
- .getClassification ( )
71
+ SensitiveFieldAccess ( ) {
72
+ exists ( FieldExpr fe | fieldExprParentField * ( fe ) = this .asExpr ( ) .getExpr ( ) |
73
+ HeuristicNames:: nameIndicatesSensitiveData ( fe .getIdentifier ( ) .getText ( ) , classification )
74
+ )
83
75
}
84
76
85
77
override SensitiveDataClassification getClassification ( ) { result = classification }
0 commit comments