Skip to content

Commit 8825428

Browse files
committed
C#: Exclude Microsoft.Data.SqlClient.SqlCommand from the best effort SqlSink creation.
1 parent 23ee048 commit 8825428

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

csharp/ql/lib/semmle/code/csharp/frameworks/Sql.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class IDbCommandConstructionSqlExpr extends SqlExpr, ObjectCreation {
3535
ic.getParameter(0).getType() instanceof StringType and
3636
not exists(Type t | t = ic.getDeclaringType() |
3737
// Known sealed classes:
38+
t.hasFullyQualifiedName("Microsoft.Data.SqlClient", "SqlCommand") or
3839
t.hasFullyQualifiedName("System.Data.SqlClient", "SqlCommand") or
3940
t.hasFullyQualifiedName("System.Data.Odbc", "OdbcCommand") or
4041
t.hasFullyQualifiedName("System.Data.OleDb", "OleDbCommand") or
Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,11 @@
11
#select
2-
| SqlInjection.cs:26:42:26:52 | access to local variable queryString | SqlInjection.cs:25:21:25:29 | access to property Text : String | SqlInjection.cs:26:42:26:52 | access to local variable queryString | This query depends on $@. | SqlInjection.cs:25:21:25:29 | access to property Text : String | this TextBox text |
3-
| SqlInjection.cs:35:42:35:52 | access to local variable queryString | SqlInjection.cs:34:21:34:38 | call to method ReadLine : String | SqlInjection.cs:35:42:35:52 | access to local variable queryString | This query depends on $@. | SqlInjection.cs:34:21:34:38 | call to method ReadLine : String | this read from stdin |
42
edges
5-
| SqlInjection.cs:24:21:24:31 | access to local variable queryString : String | SqlInjection.cs:26:42:26:52 | access to local variable queryString | provenance | |
6-
| SqlInjection.cs:25:21:25:29 | access to property Text : String | SqlInjection.cs:24:21:24:31 | access to local variable queryString : String | provenance | |
7-
| SqlInjection.cs:33:21:33:31 | access to local variable queryString : String | SqlInjection.cs:35:42:35:52 | access to local variable queryString | provenance | |
8-
| SqlInjection.cs:34:21:34:38 | call to method ReadLine : String | SqlInjection.cs:33:21:33:31 | access to local variable queryString : String | provenance | Src:MaD:1 |
9-
models
10-
| 1 | Source: System; Console; false; ReadLine; ; ; ReturnValue; stdin; manual |
113
nodes
12-
| SqlInjection.cs:24:21:24:31 | access to local variable queryString : String | semmle.label | access to local variable queryString : String |
13-
| SqlInjection.cs:25:21:25:29 | access to property Text : String | semmle.label | access to property Text : String |
14-
| SqlInjection.cs:26:42:26:52 | access to local variable queryString | semmle.label | access to local variable queryString |
15-
| SqlInjection.cs:33:21:33:31 | access to local variable queryString : String | semmle.label | access to local variable queryString : String |
16-
| SqlInjection.cs:34:21:34:38 | call to method ReadLine : String | semmle.label | call to method ReadLine : String |
17-
| SqlInjection.cs:35:42:35:52 | access to local variable queryString | semmle.label | access to local variable queryString |
184
subpaths
195
testFailures
6+
| SqlInjection.cs:25:53:25:81 | // ... | Missing result: Source[cs/sql-injection] |
7+
| SqlInjection.cs:26:56:26:83 | // ... | Missing result: Alert[cs/sql-injection] |
208
| SqlInjection.cs:27:56:27:83 | // ... | Missing result: Alert[cs/sql-injection] |
9+
| SqlInjection.cs:34:62:34:90 | // ... | Missing result: Source[cs/sql-injection] |
10+
| SqlInjection.cs:35:56:35:83 | // ... | Missing result: Alert[cs/sql-injection] |
2111
| SqlInjection.cs:36:56:36:83 | // ... | Missing result: Alert[cs/sql-injection] |

0 commit comments

Comments
 (0)