13
13
14
14
import cpp
15
15
import semmle.code.cpp.security.SensitiveExprs
16
- import semmle.code.cpp.security.TaintTracking
17
- import TaintedWithPath
18
-
19
- class UserInputIsSensitiveExpr extends SecurityOptions {
20
- override predicate isUserInput ( Expr expr , string cause ) {
21
- expr instanceof SensitiveExpr and cause = "sensitive information"
22
- }
23
- }
16
+ import semmle.code.cpp.dataflow.TaintTracking
17
+ import DataFlow:: PathGraph
24
18
25
19
class SqliteFunctionCall extends FunctionCall {
26
20
SqliteFunctionCall ( ) { this .getTarget ( ) .getName ( ) .matches ( "sqlite%" ) }
@@ -34,25 +28,30 @@ predicate sqlite_encryption_used() {
34
28
any ( FunctionCall fc ) .getTarget ( ) .getName ( ) .matches ( "sqlite%\\_key\\_%" )
35
29
}
36
30
37
- class Configuration extends TaintTrackingConfiguration {
38
- override predicate isSource ( Expr source ) {
39
- super .isSource ( source ) and source instanceof SensitiveExpr
31
+ /**
32
+ * Taint flow from a sensitive expression to a `SqliteFunctionCall` sink.
33
+ */
34
+ class FromSensitiveConfiguration extends TaintTracking:: Configuration {
35
+ FromSensitiveConfiguration ( ) { this = "FromSensitiveConfiguration" }
36
+
37
+ override predicate isSource ( DataFlow:: Node source ) { source .asExpr ( ) instanceof SensitiveExpr }
38
+
39
+ override predicate isSink ( DataFlow:: Node sink ) {
40
+ any ( SqliteFunctionCall c ) .getASource ( ) = sink .asExpr ( ) and
41
+ not sqlite_encryption_used ( )
40
42
}
41
43
42
- override predicate isSink ( Element taintedArg ) {
43
- exists ( SqliteFunctionCall sqliteCall |
44
- taintedArg = sqliteCall .getASource ( ) and
45
- not sqlite_encryption_used ( )
46
- )
44
+ override predicate isSanitizer ( DataFlow:: Node node ) {
45
+ node .asExpr ( ) .getUnspecifiedType ( ) instanceof IntegralType
47
46
}
48
47
}
49
48
50
49
from
51
- SensitiveExpr taintSource , Expr taintedArg , SqliteFunctionCall sqliteCall , PathNode sourceNode ,
52
- PathNode sinkNode
50
+ FromSensitiveConfiguration config , SensitiveExpr sensitive , DataFlow :: PathNode source ,
51
+ DataFlow :: PathNode sink , SqliteFunctionCall sqliteCall
53
52
where
54
- taintedWithPath ( taintSource , taintedArg , sourceNode , sinkNode ) and
55
- taintedArg = sqliteCall . getASource ( )
56
- select sqliteCall , sourceNode , sinkNode ,
57
- "This SQLite call may store $@ in a non-encrypted SQLite database" , taintSource ,
58
- "sensitive information"
53
+ config . hasFlowPath ( source , sink ) and
54
+ source . getNode ( ) . asExpr ( ) = sensitive and
55
+ sqliteCall . getASource ( ) = sink . getNode ( ) . asExpr ( )
56
+ select sqliteCall , source , sink , "This SQLite call may store $@ in a non-encrypted SQLite database" ,
57
+ sensitive , "sensitive information"
0 commit comments