@@ -84,6 +84,13 @@ private predicate writesProperty(DataFlow::Node node, string name) {
84
84
node .( DataFlow:: CallNode ) .getArgument ( 0 ) .asExpr ( ) .getConstantValue ( ) .isStringlikeValue ( name )
85
85
}
86
86
87
+ /**
88
+ * Instance and class variable names are reported with their respective `@`
89
+ * and `@@` prefixes. This predicate strips these prefixes.
90
+ */
91
+ bindingset [ name]
92
+ private string unprefixedVariableName ( string name ) { result = name .regexpReplaceAll ( "^@*" , "" ) }
93
+
87
94
/** A write to a variable or property that might contain sensitive data. */
88
95
private class BasicSensitiveWrite extends SensitiveWrite {
89
96
SensitiveDataClassification classification ;
@@ -104,7 +111,7 @@ private class BasicSensitiveWrite extends SensitiveWrite {
104
111
*/
105
112
106
113
writesProperty ( this , name ) and
107
- nameIndicatesSensitiveData ( name , classification )
114
+ nameIndicatesSensitiveData ( unprefixedVariableName ( name ) , classification )
108
115
)
109
116
}
110
117
@@ -116,7 +123,9 @@ private class BasicSensitiveWrite extends SensitiveWrite {
116
123
private class BasicSensitiveVariableAccess extends SensitiveVariableAccess {
117
124
SensitiveDataClassification classification ;
118
125
119
- BasicSensitiveVariableAccess ( ) { nameIndicatesSensitiveData ( name , classification ) }
126
+ BasicSensitiveVariableAccess ( ) {
127
+ nameIndicatesSensitiveData ( unprefixedVariableName ( name ) , classification )
128
+ }
120
129
121
130
override SensitiveDataClassification getClassification ( ) { result = classification }
122
131
}
0 commit comments