Skip to content

Commit 276deee

Browse files
author
Denis Levin
committed
Added comments to the test file. Fixed a typo.
1 parent 2a46a26 commit 276deee

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
| Test.cs:19:13:19:17 | access to local variable store | Certificate added to the root certificate store. Do not add certificates to root certificate store. |
2-
| Test.cs:28:13:28:17 | access to local variable store | Certificate added to the root certificate store. Do not add certificates to root certificate store. |
3-
| Test.cs:69:13:69:17 | access to local variable store | Certificate added to the root certificate store. Do not add certificates to root certificate store. |
1+
| Test.cs:20:13:20:17 | access to local variable store | Certificate added to the root certificate store. Do not add certificates to root certificate store. |
2+
| Test.cs:30:13:30:17 | access to local variable store | Certificate added to the root certificate store. Do not add certificates to root certificate store. |
3+
| Test.cs:75:13:75:17 | access to local variable store | Certificate added to the root certificate store. Do not add certificates to root certificate store. |

csharp/ql/test/query-tests/Security Features/CWE-327/DontInstallRootCert/Test.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,22 @@ namespace RootCert
1111
{
1212
public class Class1
1313
{
14-
public void InstallRoorCert()
14+
public void InstallRootCert()
1515
{
1616
string file = "mytest.pfx"; // Contains name of certificate file
1717
X509Store store = new X509Store(StoreName.Root);
1818
store.Open(OpenFlags.ReadWrite);
19+
// BAD: adding a certificate to the Root store
1920
store.Add(new X509Certificate2(X509Certificate2.CreateFromCertFile(file)));
2021
store.Close();
2122
}
2223

23-
public void InstallRoorCert2()
24+
public void InstallRootCert2()
2425
{
2526
string file = "mytest.pfx"; // Contains name of certificate file
2627
X509Store store = new X509Store(StoreName.Root, StoreLocation.CurrentUser);
2728
store.Open(OpenFlags.ReadWrite);
29+
// BAD: adding a certificate to the Root store
2830
store.Add(new X509Certificate2(X509Certificate2.CreateFromCertFile(file)));
2931
store.Close();
3032
}
@@ -34,6 +36,7 @@ public void InstallUserCert()
3436
string file = "mytest.pfx"; // Contains name of certificate file
3537
X509Store store = new X509Store(StoreName.My);
3638
store.Open(OpenFlags.ReadWrite);
39+
// GOOD: adding a certificate to My store
3740
store.Add(new X509Certificate2(X509Certificate2.CreateFromCertFile(file)));
3841
store.Close();
3942
}
@@ -43,6 +46,7 @@ public void RemoveUserCert()
4346
string file = "mytest.pfx"; // Contains name of certificate file
4447
X509Store store = new X509Store(StoreName.My);
4548
store.Open(OpenFlags.ReadWrite);
49+
// GOOD: removing a certificate from My store
4650
store.Remove(new X509Certificate2(X509Certificate2.CreateFromCertFile(file)));
4751
store.Close();
4852
}
@@ -52,11 +56,12 @@ public void RemoveRootCert()
5256
string file = "mytest.pfx"; // Contains name of certificate file
5357
X509Store store = new X509Store(StoreName.Root);
5458
store.Open(OpenFlags.ReadWrite);
59+
// GOOD: removing a certificate from Root store
5560
store.Remove(new X509Certificate2(X509Certificate2.CreateFromCertFile(file)));
5661
store.Close();
5762
}
5863

59-
public void InstallRoorCertRange()
64+
public void InstallRootCertRange()
6065
{
6166
string file1 = "mytest1.pfx"; // Contains name of certificate file
6267
string file2 = "mytest2.pfx"; // Contains name of certificate file
@@ -66,6 +71,7 @@ public void InstallRoorCertRange()
6671
};
6772
X509Store store = new X509Store(StoreName.Root, StoreLocation.CurrentUser);
6873
store.Open(OpenFlags.ReadWrite);
74+
// BAD: adding multiple certificates to the Root store
6975
store.AddRange(new X509Certificate2Collection(certCollection));
7076
store.Close();
7177
}

0 commit comments

Comments
 (0)