@@ -13,10 +13,11 @@ private import codeql.ruby.AST
1313private import codeql.ruby.DataFlow
1414import codeql.ruby.security.internal.SensitiveDataHeuristics
1515private import HeuristicNames
16+ private import codeql.ruby.CFG
1617
1718/** An expression that might contain sensitive data. */
1819cached
19- abstract class SensitiveExpr extends Expr {
20+ abstract class SensitiveNode extends DataFlow :: Node {
2021 /** Gets a human-readable description of this expression for use in alert messages. */
2122 cached
2223 abstract string describe ( ) ;
@@ -27,32 +28,36 @@ abstract class SensitiveExpr extends Expr {
2728}
2829
2930/** A method call that might produce sensitive data. */
30- class SensitiveCall extends SensitiveExpr , MethodCall {
31+ class SensitiveCall extends SensitiveNode instanceof DataFlow :: CallNode {
3132 SensitiveDataClassification classification ;
3233
3334 SensitiveCall ( ) {
3435 classification = this .getMethodName ( ) .( SensitiveDataMethodName ) .getClassification ( )
3536 or
3637 // This is particularly to pick up methods with an argument like "password", which
3738 // may indicate a lookup.
38- exists ( string s | this . getAnArgument ( ) .getConstantValue ( ) .isStringlikeValue ( s ) |
39+ exists ( string s | super . getArgument ( _ ) . asExpr ( ) .getConstantValue ( ) .isStringlikeValue ( s ) |
3940 nameIndicatesSensitiveData ( s , classification )
4041 )
4142 }
4243
43- override string describe ( ) { result = "a call to " + this .getMethodName ( ) }
44+ override string describe ( ) { result = "a call to " + super .getMethodName ( ) }
4445
4546 override SensitiveDataClassification getClassification ( ) { result = classification }
4647}
4748
4849/** An access to a variable or hash value that might contain sensitive data. */
49- abstract class SensitiveVariableAccess extends SensitiveExpr {
50+ abstract class SensitiveVariableAccess extends SensitiveNode {
5051 string name ;
5152
5253 SensitiveVariableAccess ( ) {
53- this .( VariableAccess ) .getVariable ( ) .hasName ( name )
54+ this .asExpr ( ) . ( CfgNodes :: ExprNodes :: VariableAccessCfgNode ) . getExpr ( ) .getVariable ( ) .hasName ( name )
5455 or
55- this .( ElementReference ) .getAnArgument ( ) .getConstantValue ( ) .isStringlikeValue ( name )
56+ this .asExpr ( )
57+ .( CfgNodes:: ExprNodes:: ElementReferenceCfgNode )
58+ .getAnArgument ( )
59+ .getConstantValue ( )
60+ .isStringlikeValue ( name )
5661 }
5762
5863 override string describe ( ) { result = "an access to " + name }
0 commit comments