@@ -28,24 +28,37 @@ abstract class SensitiveNode extends DataFlow::Node {
28
28
}
29
29
30
30
/** A method call that might produce sensitive data. */
31
- class SensitiveCall extends SensitiveNode instanceof DataFlow:: CallNode {
31
+ abstract class SensitiveCall extends SensitiveNode { }
32
+
33
+ private class SensitiveDataMethodNameCall extends SensitiveCall instanceof DataFlow:: CallNode {
32
34
SensitiveDataClassification classification ;
33
35
34
- SensitiveCall ( ) {
36
+ SensitiveDataMethodNameCall ( ) {
35
37
classification = this .getMethodName ( ) .( SensitiveDataMethodName ) .getClassification ( )
36
- or
37
- // This is particularly to pick up methods with an argument like "password", which
38
- // may indicate a lookup.
39
- exists ( string s | super .getArgument ( _) .asExpr ( ) .getConstantValue ( ) .isStringlikeValue ( s ) |
40
- nameIndicatesSensitiveData ( s , classification )
41
- )
42
38
}
43
39
44
40
override string describe ( ) { result = "a call to " + super .getMethodName ( ) }
45
41
46
42
override SensitiveDataClassification getClassification ( ) { result = classification }
47
43
}
48
44
45
+ private class SensitiveArgumentCall extends SensitiveCall instanceof DataFlow:: CallNode {
46
+ string argName ;
47
+
48
+ SensitiveArgumentCall ( ) {
49
+ // This is particularly to pick up methods with an argument like "password", which may indicate
50
+ // a lookup.
51
+ super .getArgument ( _) .asExpr ( ) .getConstantValue ( ) .isStringlikeValue ( argName ) and
52
+ nameIndicatesSensitiveData ( argName )
53
+ }
54
+
55
+ override string describe ( ) { result = "a call to " + super .getMethodName ( ) }
56
+
57
+ override SensitiveDataClassification getClassification ( ) {
58
+ nameIndicatesSensitiveData ( argName , result )
59
+ }
60
+ }
61
+
49
62
/** An access to a variable or hash value that might contain sensitive data. */
50
63
abstract class SensitiveVariableAccess extends SensitiveNode {
51
64
string name ;
@@ -93,7 +106,7 @@ private string unprefixedVariableName(string name) { result = name.regexpReplace
93
106
94
107
/** A write to a variable or property that might contain sensitive data. */
95
108
private class BasicSensitiveWrite extends SensitiveWrite {
96
- SensitiveDataClassification classification ;
109
+ string unprefixedName ;
97
110
98
111
BasicSensitiveWrite ( ) {
99
112
exists ( string name |
@@ -111,23 +124,29 @@ private class BasicSensitiveWrite extends SensitiveWrite {
111
124
*/
112
125
113
126
writesProperty ( this , name ) and
114
- nameIndicatesSensitiveData ( unprefixedVariableName ( name ) , classification )
127
+ unprefixedName = unprefixedVariableName ( name ) and
128
+ nameIndicatesSensitiveData ( unprefixedName )
115
129
)
116
130
}
117
131
118
132
/** Gets a classification of the kind of sensitive data the write might handle. */
119
- SensitiveDataClassification getClassification ( ) { result = classification }
133
+ SensitiveDataClassification getClassification ( ) {
134
+ nameIndicatesSensitiveData ( unprefixedName , result )
135
+ }
120
136
}
121
137
122
138
/** An access to a variable or hash value that might contain sensitive data. */
123
139
private class BasicSensitiveVariableAccess extends SensitiveVariableAccess {
124
- SensitiveDataClassification classification ;
140
+ string unprefixedName ;
125
141
126
142
BasicSensitiveVariableAccess ( ) {
127
- nameIndicatesSensitiveData ( unprefixedVariableName ( name ) , classification )
143
+ unprefixedName = unprefixedVariableName ( name ) and
144
+ nameIndicatesSensitiveData ( unprefixedName )
128
145
}
129
146
130
- override SensitiveDataClassification getClassification ( ) { result = classification }
147
+ override SensitiveDataClassification getClassification ( ) {
148
+ nameIndicatesSensitiveData ( unprefixedName , result )
149
+ }
131
150
}
132
151
133
152
/** A method name that suggests it may be sensitive. */
@@ -143,11 +162,11 @@ abstract class SensitiveDataMethodName extends SensitiveMethodName {
143
162
144
163
/** A method name that might return sensitive credential data. */
145
164
class CredentialsMethodName extends SensitiveDataMethodName {
146
- SensitiveDataClassification classification ;
147
-
148
- CredentialsMethodName ( ) { nameIndicatesSensitiveData ( this , classification ) }
165
+ CredentialsMethodName ( ) { nameIndicatesSensitiveData ( this ) }
149
166
150
- override SensitiveDataClassification getClassification ( ) { result = classification }
167
+ override SensitiveDataClassification getClassification ( ) {
168
+ nameIndicatesSensitiveData ( this , result )
169
+ }
151
170
}
152
171
153
172
/**
0 commit comments