mirror of
https://github.com/github/codeql.git
synced 2025-12-21 19:26:31 +01:00
Fixing Test cases
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
using System;
|
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
|
|
||||||
namespace InsecureSQLConnection
|
namespace InsecureSQLConnection
|
||||||
@@ -35,13 +34,13 @@ namespace InsecureSQLConnection
|
|||||||
public void StringInInitializer()
|
public void StringInInitializer()
|
||||||
{
|
{
|
||||||
string connectString = "Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd;Encrypt=false";
|
string connectString = "Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd;Encrypt=false";
|
||||||
SqlConnectionStringBuilder conBuilder = new SqlConnectionStringBuilder(connectString) { Encrypt = true}; // False Positive
|
SqlConnectionStringBuilder conBuilder = new SqlConnectionStringBuilder(connectString) { Encrypt = true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void TriggerThis()
|
public void TriggerThis()
|
||||||
{
|
{
|
||||||
// BAD, Encrypt not specified (version dependent)
|
// BAD, Encrypt not specified
|
||||||
SqlConnection conn = new SqlConnection("Server=myServerName\\myInstanceName;Database=myDataBase;User Id=myUsername;");
|
SqlConnection conn = new SqlConnection("Server=myServerName\\myInstanceName;Database=myDataBase;User Id=myUsername;");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +48,7 @@ namespace InsecureSQLConnection
|
|||||||
{
|
{
|
||||||
string connectString =
|
string connectString =
|
||||||
"Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd";
|
"Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd";
|
||||||
// BAD, Encrypt not specified (version dependent)
|
// BAD, Encrypt not specified
|
||||||
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectString);
|
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectString);
|
||||||
var conn = new SqlConnection(builder.ConnectionString);
|
var conn = new SqlConnection(builder.ConnectionString);
|
||||||
}
|
}
|
||||||
@@ -62,20 +61,5 @@ namespace InsecureSQLConnection
|
|||||||
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectString);
|
SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(connectString);
|
||||||
var conn = new SqlConnection(builder.ConnectionString);
|
var conn = new SqlConnection(builder.ConnectionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Test6()
|
|
||||||
{
|
|
||||||
var conn = new SqlConnectionStringBuilder(SetToTrueConnStr) { Encrypt = false }; // Bug - cs/insecure-sql-connection-initializer
|
|
||||||
}
|
|
||||||
|
|
||||||
void Test72ndPhase(bool encrypt)
|
|
||||||
{
|
|
||||||
var conn = new SqlConnectionStringBuilder(SetToTrueConnStr) { Encrypt = encrypt }; // Bug - cs/insecure-sql-connection-initializer (sink)
|
|
||||||
}
|
|
||||||
|
|
||||||
void Test7()
|
|
||||||
{
|
|
||||||
Test72ndPhase(false); // Bug - cs/insecure-sql-connection-initializer (source)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
edges
|
||||||
|
nodes
|
||||||
|
subpaths
|
||||||
|
#select
|
||||||
Reference in New Issue
Block a user