Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d427527

Browse files
committed
C#: Add SQLCommand examples.
1 parent 7fc95fb commit d427527

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
3+
namespace TestSqlite
4+
{
5+
6+
using System.Data.SQLite;
7+
using System.Web.UI.WebControls;
8+
9+
class SqlInjection
10+
{
11+
private string connectionString;
12+
public TextBox untrustedData;
13+
14+
public void InjectUntrustedData()
15+
{
16+
// BAD: untrusted data is not sanitized.
17+
SQLiteCommand cmd = new SQLiteCommand(untrustedData.Text);
18+
19+
// BAD: untrusted data is not sanitized.
20+
using (var connection = new SQLiteConnection(connectionString))
21+
{
22+
cmd = new SQLiteCommand(untrustedData.Text, connection);
23+
}
24+
25+
}
26+
}
27+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
semmle-extractor-options: /nostdlib /noconfig
22
semmle-extractor-options: --load-sources-from-project:../../../resources/stubs/Dapper/2.0.90/Dapper.csproj
33
semmle-extractor-options: --load-sources-from-project:../../../resources/stubs/System.Data.SqlClient/4.8.3/System.Data.SqlClient.csproj
4+
semmle-extractor-options: --load-sources-from-project:../../../resources/stubs/System.Data.SQLite/1.0.116/System.Data.SQLite.csproj
45
semmle-extractor-options: ${testdir}/../../../resources/stubs/EntityFramework.cs
56
semmle-extractor-options: ${testdir}/../../../resources/stubs/System.Windows.cs

0 commit comments

Comments
 (0)