@@ -13,10 +13,11 @@ private import codeql.ruby.AST
13
13
private import codeql.ruby.DataFlow
14
14
import codeql.ruby.security.internal.SensitiveDataHeuristics
15
15
private import HeuristicNames
16
+ private import codeql.ruby.CFG
16
17
17
18
/** An expression that might contain sensitive data. */
18
19
cached
19
- abstract class SensitiveExpr extends Expr {
20
+ abstract class SensitiveNode extends DataFlow :: Node {
20
21
/** Gets a human-readable description of this expression for use in alert messages. */
21
22
cached
22
23
abstract string describe ( ) ;
@@ -27,32 +28,36 @@ abstract class SensitiveExpr extends Expr {
27
28
}
28
29
29
30
/** A method call that might produce sensitive data. */
30
- class SensitiveCall extends SensitiveExpr , MethodCall {
31
+ class SensitiveCall extends SensitiveNode instanceof DataFlow :: CallNode {
31
32
SensitiveDataClassification classification ;
32
33
33
34
SensitiveCall ( ) {
34
35
classification = this .getMethodName ( ) .( SensitiveDataMethodName ) .getClassification ( )
35
36
or
36
37
// This is particularly to pick up methods with an argument like "password", which
37
38
// may indicate a lookup.
38
- exists ( string s | this . getAnArgument ( ) .getConstantValue ( ) .isStringlikeValue ( s ) |
39
+ exists ( string s | super . getArgument ( _ ) . asExpr ( ) .getConstantValue ( ) .isStringlikeValue ( s ) |
39
40
nameIndicatesSensitiveData ( s , classification )
40
41
)
41
42
}
42
43
43
- override string describe ( ) { result = "a call to " + this .getMethodName ( ) }
44
+ override string describe ( ) { result = "a call to " + super .getMethodName ( ) }
44
45
45
46
override SensitiveDataClassification getClassification ( ) { result = classification }
46
47
}
47
48
48
49
/** 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 {
50
51
string name ;
51
52
52
53
SensitiveVariableAccess ( ) {
53
- this .( VariableAccess ) .getVariable ( ) .hasName ( name )
54
+ this .asExpr ( ) . ( CfgNodes :: ExprNodes :: VariableAccessCfgNode ) . getExpr ( ) .getVariable ( ) .hasName ( name )
54
55
or
55
- this .( ElementReference ) .getAnArgument ( ) .getConstantValue ( ) .isStringlikeValue ( name )
56
+ this .asExpr ( )
57
+ .( CfgNodes:: ExprNodes:: ElementReferenceCfgNode )
58
+ .getAnArgument ( )
59
+ .getConstantValue ( )
60
+ .isStringlikeValue ( name )
56
61
}
57
62
58
63
override string describe ( ) { result = "an access to " + name }
0 commit comments