Skip to content

Commit 1fb2099

Browse files
committed
C#: Add SQLiteDataAdapter examples.
1 parent ce9baaa commit 1fb2099

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

csharp/ql/test/query-tests/Security Features/CWE-089/SqlInjectionSqlite.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace TestSqlite
44
{
5-
5+
using System.Data;
66
using System.Data.SQLite;
77
using System.Web.UI.WebControls;
88

@@ -22,6 +22,21 @@ public void InjectUntrustedData()
2222
cmd = new SQLiteCommand(untrustedData.Text, connection);
2323
}
2424

25+
SQLiteDataAdapter adapter;
26+
DataSet result;
27+
28+
// BAD: untrusted data is not sanitized.
29+
using (var connection = new SQLiteConnection(connectionString))
30+
{
31+
adapter = new SQLiteDataAdapter(untrustedData.Text, connection);
32+
result = new DataSet();
33+
adapter.Fill(result);
34+
}
35+
36+
// BAD: untrusted data is not sanitized.
37+
adapter = new SQLiteDataAdapter(untrustedData.Text, connectionString);
38+
result = new DataSet();
39+
adapter.Fill(result);
2540
}
2641
}
2742
}

0 commit comments

Comments
 (0)