This commit is contained in:
2022-02-02 19:20:57 +01:00
parent 3b3670af19
commit 527ba10c1a
4 changed files with 65 additions and 8 deletions

View File

@@ -32,13 +32,14 @@ namespace Webtester.Pages
Console.WriteLine("Testing for injections:");
getDone = true;
}
TestInjection(test);
}
private void TestInjection(string text)
{
var result = SqlHelper.ExecuteQuery(
new Microsoft.Data.SqlClient.SqlConnection(@"Server=localhost;Database=NorthWind;User Id=sa;Password=jeroen;TrustServerCertificate=Yes;"),
var connectionString = @"Server=localhost;Database=NorthWind;User Id=sa;Password=jeroen;TrustServerCertificate=Yes;";
var result = SqlHelper.ExecuteQuery(connectionString,
$"SELECT * FROM Customers WHERE Country = @0", true, text);
if (!result.HasResult)
@@ -76,8 +77,8 @@ namespace Webtester.Pages
private static async void TestsqlServer()
{
var customerId = "AROUT";
var result = SqlHelper.ExecuteQuery(
new Microsoft.Data.SqlClient.SqlConnection(@"Server=localhost;Database=NorthWind;User Id=sa;Password=jeroen;TrustServerCertificate=Yes;"),
var connectionString = @"Server=localhost;Database=NorthWind;User Id=sa;Password=jeroen;TrustServerCertificate=Yes;";
var result = SqlHelper.ExecuteQuery(connectionString,
$"SELECT * FROM Customers WHERE CustomerID = @0 AND Country = @1"
, true, customerId, "UK");