Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 3fd6f9c

Browse files
committed
Extend QueryString::Range with database/sql/driver interfaces' methods
1 parent 24e8a18 commit 3fd6f9c

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

ql/src/semmle/go/frameworks/SQL.qll

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ module SQL {
111111
exists(Method meth, string base, string m, int n |
112112
(
113113
meth.hasQualifiedName("database/sql", "DB", m) or
114-
meth.hasQualifiedName("database/sql", "Tx", m)
114+
meth.hasQualifiedName("database/sql", "Tx", m) or
115+
meth.hasQualifiedName("database/sql", "Conn", m)
115116
) and
116117
this = meth.getACall().getArgument(n)
117118
|
@@ -125,6 +126,29 @@ module SQL {
125126
}
126127
}
127128

129+
/** A query string used in an API function of the standard `database/sql/driver` package. */
130+
private class DriverQueryString extends Range {
131+
DriverQueryString() {
132+
exists(Method meth, int n |
133+
(
134+
meth.hasQualifiedName("database/sql/driver", "Execer", "Exec") and n = 0
135+
or
136+
meth.hasQualifiedName("database/sql/driver", "ExecerContext", "ExecContext") and n = 1
137+
or
138+
meth.hasQualifiedName("database/sql/driver", "Conn", "Prepare") and n = 0
139+
or
140+
meth.hasQualifiedName("database/sql/driver", "ConnPrepareContext", "PrepareContext") and
141+
n = 1
142+
or
143+
meth.hasQualifiedName("database/sql/driver", "Queryer", "Query") and n = 0
144+
or
145+
meth.hasQualifiedName("database/sql/driver", "QueryerContext", "QueryContext") and n = 1
146+
) and
147+
this = meth.getACall().getArgument(n)
148+
)
149+
}
150+
}
151+
128152
/**
129153
* An argument to an API of the squirrel library that is directly interpreted as SQL without
130154
* taking syntactic structure into account.

0 commit comments

Comments
 (0)