@@ -6,6 +6,48 @@ import go
6
6
7
7
/** Provides classes for working with SQL-related APIs. */
8
8
module SQL {
9
+ private class FunctionModels extends TaintTracking:: FunctionModel {
10
+ FunctionInput inp ;
11
+ FunctionOutput outp ;
12
+
13
+ FunctionModels ( ) {
14
+ // signature: func Named(name string, value interface{}) NamedArg
15
+ hasQualifiedName ( "database/sql" , "Named" ) and
16
+ ( inp .isParameter ( _) and outp .isResult ( ) )
17
+ }
18
+
19
+ override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
20
+ input = inp and output = outp
21
+ }
22
+ }
23
+
24
+ private class MethodModels extends TaintTracking:: FunctionModel , Method {
25
+ FunctionInput inp ;
26
+ FunctionOutput outp ;
27
+
28
+ MethodModels ( ) {
29
+ // signature: func (*NullString).Scan(value interface{}) error
30
+ this .hasQualifiedName ( "database/sql" , "NullString" , "Scan" ) and
31
+ ( inp .isParameter ( 0 ) and outp .isReceiver ( ) )
32
+ or
33
+ // signature: func (*Row).Scan(dest ...interface{}) error
34
+ this .hasQualifiedName ( "database/sql" , "Row" , "Scan" ) and
35
+ ( inp .isReceiver ( ) and outp .isParameter ( _) )
36
+ or
37
+ // signature: func (*Rows).Scan(dest ...interface{}) error
38
+ this .hasQualifiedName ( "database/sql" , "Rows" , "Scan" ) and
39
+ ( inp .isReceiver ( ) and outp .isParameter ( _) )
40
+ or
41
+ // signature: func (Scanner).Scan(src interface{}) error
42
+ this .implements ( "database/sql" , "Scanner" , "Scan" ) and
43
+ ( inp .isParameter ( 0 ) and outp .isReceiver ( ) )
44
+ }
45
+
46
+ override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
47
+ input = inp and output = outp
48
+ }
49
+ }
50
+
9
51
/**
10
52
* A data-flow node whose string value is interpreted as (part of) a SQL query.
11
53
*
0 commit comments