11
11
*/
12
12
13
13
import csharp
14
- import DataFlow :: PathGraph
14
+ import InsecureSqlConnection :: PathGraph
15
15
16
16
/**
17
17
* A data flow configuration for tracking strings passed to `SqlConnection[StringBuilder]` instances.
18
18
*/
19
- class TaintTrackingConfiguration extends DataFlow:: Configuration {
20
- TaintTrackingConfiguration ( ) { this = "TaintTrackingConfiguration" }
21
-
22
- override predicate isSource ( DataFlow:: Node source ) {
19
+ module InsecureSqlConnectionConfig implements DataFlow:: ConfigSig {
20
+ predicate isSource ( DataFlow:: Node source ) {
23
21
exists ( string s | s = source .asExpr ( ) .( StringLiteral ) .getValue ( ) .toLowerCase ( ) |
24
22
s .matches ( "%encrypt=false%" )
25
23
or
26
24
not s .matches ( "%encrypt=%" )
27
25
)
28
26
}
29
27
30
- override predicate isSink ( DataFlow:: Node sink ) {
28
+ predicate isSink ( DataFlow:: Node sink ) {
31
29
exists ( ObjectCreation oc |
32
30
oc .getRuntimeArgument ( 0 ) = sink .asExpr ( ) and
33
31
(
@@ -39,8 +37,13 @@ class TaintTrackingConfiguration extends DataFlow::Configuration {
39
37
}
40
38
}
41
39
42
- from TaintTrackingConfiguration c , DataFlow:: PathNode source , DataFlow:: PathNode sink
43
- where c .hasFlowPath ( source , sink )
40
+ /**
41
+ * A data flow configuration for tracking strings passed to `SqlConnection[StringBuilder]` instances.
42
+ */
43
+ module InsecureSqlConnection = DataFlow:: Global< InsecureSqlConnectionConfig > ;
44
+
45
+ from InsecureSqlConnection:: PathNode source , InsecureSqlConnection:: PathNode sink
46
+ where InsecureSqlConnection:: flowPath ( source , sink )
44
47
select sink .getNode ( ) , source , sink ,
45
48
"$@ flows to this SQL connection and does not specify `Encrypt=True`." , source .getNode ( ) ,
46
49
"Connection string"
0 commit comments