@@ -13,9 +13,25 @@ import javascript
1313import semmle.javascript.security.internal.SensitiveDataHeuristics
1414private import HeuristicNames
1515
16+ /**
17+ * DEPRECATED: Use `SensitiveNode` instead.
18+ * An expression that might contain sensitive data.
19+ */
20+ deprecated class SensitiveExpr extends Expr {
21+ SensitiveNode node ;
22+
23+ SensitiveExpr ( ) { node .asExpr ( ) = this }
24+
25+ /** Gets a human-readable description of this expression for use in alert messages. */
26+ deprecated string describe ( ) { result = node .describe ( ) }
27+
28+ /** Gets a classification of the kind of sensitive data this expression might contain. */
29+ deprecated SensitiveDataClassification getClassification ( ) { result = node .getClassification ( ) }
30+ }
31+
1632/** An expression that might contain sensitive data. */
1733cached
18- abstract class SensitiveExpr extends Expr {
34+ abstract class SensitiveNode extends DataFlow :: Node {
1935 /** Gets a human-readable description of this expression for use in alert messages. */
2036 cached
2137 abstract string describe ( ) ;
@@ -26,33 +42,33 @@ abstract class SensitiveExpr extends Expr {
2642}
2743
2844/** A function call that might produce sensitive data. */
29- class SensitiveCall extends SensitiveExpr , InvokeExpr {
45+ class SensitiveCall extends SensitiveNode instanceof DataFlow :: InvokeNode {
3046 SensitiveDataClassification classification ;
3147
3248 SensitiveCall ( ) {
33- classification = this .getCalleeName ( ) .( SensitiveDataFunctionName ) .getClassification ( )
49+ classification = super .getCalleeName ( ) .( SensitiveDataFunctionName ) .getClassification ( )
3450 or
3551 // This is particularly to pick up methods with an argument like "password", which
3652 // may indicate a lookup.
37- exists ( string s | this .getAnArgument ( ) .mayHaveStringValue ( s ) |
53+ exists ( string s | super .getAnArgument ( ) .mayHaveStringValue ( s ) |
3854 nameIndicatesSensitiveData ( s , classification )
3955 )
4056 }
4157
42- override string describe ( ) { result = "a call to " + this .getCalleeName ( ) }
58+ override string describe ( ) { result = "a call to " + super .getCalleeName ( ) }
4359
4460 override SensitiveDataClassification getClassification ( ) { result = classification }
4561}
4662
4763/** An access to a variable or property that might contain sensitive data. */
48- abstract class SensitiveVariableAccess extends SensitiveExpr {
64+ abstract class SensitiveVariableAccess extends SensitiveNode {
4965 string name ;
5066
5167 SensitiveVariableAccess ( ) {
52- this .( VarAccess ) .getName ( ) = name
68+ this .asExpr ( ) . ( VarAccess ) .getName ( ) = name
5369 or
5470 exists ( DataFlow:: PropRead pr |
55- this = pr . asExpr ( ) and
71+ this = pr and
5672 pr .getPropertyName ( ) = name
5773 )
5874 }
@@ -173,10 +189,8 @@ class ProtectCall extends DataFlow::CallNode {
173189}
174190
175191/** An expression that might contain a clear-text password. */
176- class CleartextPasswordExpr extends SensitiveExpr {
177- CleartextPasswordExpr ( ) {
178- this .( SensitiveExpr ) .getClassification ( ) = SensitiveDataClassification:: password ( )
179- }
192+ class CleartextPasswordExpr extends SensitiveNode {
193+ CleartextPasswordExpr ( ) { this .getClassification ( ) = SensitiveDataClassification:: password ( ) }
180194
181195 override string describe ( ) { none ( ) }
182196
0 commit comments