Skip to content

Commit c1f7422

Browse files
Fixing test cases
1 parent a179fa0 commit c1f7422

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

csharp/ql/test/query-tests/Security Features/CWE-327/InsecureSQLConnectionInitializer/InsecureSQLConnection.cs

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
namespace System.Data.SqlClient
2+
{
3+
public sealed class SqlConnectionStringBuilder
4+
{
5+
public bool Encrypt { get; set; }
6+
public SqlConnectionStringBuilder(string connectionString) { }
7+
}
8+
9+
}
10+
11+
namespace InsecureSQLConnection
12+
{
13+
public class Class1
14+
{
15+
void Test6()
16+
{
17+
string connectString = "Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd;Encrypt=false";
18+
var conn = new System.Data.SqlClient.SqlConnectionStringBuilder(connectString) { Encrypt = false }; // Bug - cs/insecure-sql-connection-initializer
19+
}
20+
21+
void Test72ndPhase(bool encrypt)
22+
{
23+
string connectString = "Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd;Encrypt=false";
24+
var conn = new System.Data.SqlClient.SqlConnectionStringBuilder(connectString) { Encrypt = encrypt }; // Bug - cs/insecure-sql-connection-initializer (sink)
25+
}
26+
27+
void Test7()
28+
{
29+
Test72ndPhase(false); // Bug - cs/insecure-sql-connection-initializer (source)
30+
}
31+
32+
void Test7FP()
33+
{
34+
Test72ndPhase(true); // Not a bug source
35+
}
36+
37+
void Test8FP()
38+
{
39+
string connectString = "Server=1.2.3.4;Database=Anything;UID=ab;Pwd=cd;Encrypt=false";
40+
var conn = new System.Data.SqlClient.SqlConnectionStringBuilder(connectString) { Encrypt = true };
41+
}
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
edges
2+
| InsecureSQLConnectionInitializer.cs:21:33:21:39 | encrypt : Boolean | InsecureSQLConnectionInitializer.cs:24:104:24:110 | access to parameter encrypt | provenance | |
3+
| InsecureSQLConnectionInitializer.cs:29:27:29:31 | false : Boolean | InsecureSQLConnectionInitializer.cs:21:33:21:39 | encrypt : Boolean | provenance | |
24
nodes
5+
| InsecureSQLConnectionInitializer.cs:18:104:18:108 | false | semmle.label | false |
6+
| InsecureSQLConnectionInitializer.cs:21:33:21:39 | encrypt : Boolean | semmle.label | encrypt : Boolean |
7+
| InsecureSQLConnectionInitializer.cs:24:104:24:110 | access to parameter encrypt | semmle.label | access to parameter encrypt |
8+
| InsecureSQLConnectionInitializer.cs:29:27:29:31 | false : Boolean | semmle.label | false : Boolean |
39
subpaths
410
#select
11+
| InsecureSQLConnectionInitializer.cs:18:104:18:108 | false | InsecureSQLConnectionInitializer.cs:18:104:18:108 | false | InsecureSQLConnectionInitializer.cs:18:104:18:108 | false | A value evaluating to $@ flows to $@ and sets the `encrypt` property. | InsecureSQLConnectionInitializer.cs:18:104:18:108 | false | `false` | InsecureSQLConnectionInitializer.cs:18:24:18:110 | object creation of type SqlConnectionStringBuilder | this SQL connection initializer |
12+
| InsecureSQLConnectionInitializer.cs:24:104:24:110 | access to parameter encrypt | InsecureSQLConnectionInitializer.cs:29:27:29:31 | false : Boolean | InsecureSQLConnectionInitializer.cs:24:104:24:110 | access to parameter encrypt | A value evaluating to $@ flows to $@ and sets the `encrypt` property. | InsecureSQLConnectionInitializer.cs:29:27:29:31 | false | `false` | InsecureSQLConnectionInitializer.cs:24:24:24:112 | object creation of type SqlConnectionStringBuilder | this SQL connection initializer |

0 commit comments

Comments
 (0)