Skip to content

Commit c7cac96

Browse files
committed
Convert to inline expectations test
1 parent 3d9e8a2 commit c7cac96

3 files changed

Lines changed: 27 additions & 26 deletions

File tree

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
#select
2+
| Test.cs:14:13:14:57 | (...) => ... | Test.cs:14:13:14:57 | (...) => ... | Test.cs:14:13:14:57 | (...) => ... | This TLS certificate validation $@, which trusts any certificate. | Test.cs:14:13:14:57 | (...) => ... | uses a callback |
3+
| Test.cs:22:13:25:13 | (...) => ... | Test.cs:22:13:25:13 | (...) => ... | Test.cs:22:13:25:13 | (...) => ... | This TLS certificate validation $@, which trusts any certificate. | Test.cs:22:13:25:13 | (...) => ... | uses a callback |
4+
| Test.cs:33:13:33:74 | access to property DangerousAcceptAnyServerCertificateValidator | Test.cs:33:13:33:74 | access to property DangerousAcceptAnyServerCertificateValidator | Test.cs:33:13:33:74 | access to property DangerousAcceptAnyServerCertificateValidator | This TLS certificate validation $@, which trusts any certificate. | Test.cs:33:13:33:74 | access to property DangerousAcceptAnyServerCertificateValidator | uses a callback |
5+
| Test.cs:40:13:40:56 | (...) => ... | Test.cs:40:13:40:56 | (...) => ... | Test.cs:40:13:40:56 | (...) => ... | This TLS certificate validation $@, which trusts any certificate. | Test.cs:40:13:40:56 | (...) => ... | uses a callback |
6+
| Test.cs:47:13:47:61 | (...) => ... | Test.cs:47:13:47:61 | (...) => ... | Test.cs:47:13:47:61 | (...) => ... | This TLS certificate validation $@, which trusts any certificate. | Test.cs:47:13:47:61 | (...) => ... | uses a callback |
7+
| Test.cs:49:68:49:87 | (...) => ... | Test.cs:49:68:49:87 | (...) => ... | Test.cs:49:68:49:87 | (...) => ... | This TLS certificate validation $@, which trusts any certificate. | Test.cs:49:68:49:87 | (...) => ... | uses a callback |
8+
| Test.cs:51:68:51:92 | delegate(...) { ... } | Test.cs:51:68:51:92 | delegate(...) { ... } | Test.cs:51:68:51:92 | delegate(...) { ... } | This TLS certificate validation $@, which trusts any certificate. | Test.cs:51:68:51:92 | delegate(...) { ... } | uses a callback |
9+
| Test.cs:69:67:69:75 | delegate creation of type RemoteCertificateValidationCallback | Test.cs:69:67:69:75 | delegate creation of type RemoteCertificateValidationCallback | Test.cs:69:67:69:75 | delegate creation of type RemoteCertificateValidationCallback | This TLS certificate validation $@, which trusts any certificate. | Test.cs:69:67:69:75 | delegate creation of type RemoteCertificateValidationCallback | uses a callback |
10+
| Test.cs:76:13:76:76 | delegate creation of type RemoteCertificateValidationCallback | Test.cs:76:13:76:76 | delegate creation of type RemoteCertificateValidationCallback | Test.cs:76:13:76:76 | delegate creation of type RemoteCertificateValidationCallback | This TLS certificate validation $@, which trusts any certificate. | Test.cs:76:13:76:76 | delegate creation of type RemoteCertificateValidationCallback | uses a callback |
11+
| Test.cs:83:13:83:56 | (...) => ... | Test.cs:83:13:83:56 | (...) => ... | Test.cs:83:13:83:56 | (...) => ... | This TLS certificate validation $@, which trusts any certificate. | Test.cs:83:13:83:56 | (...) => ... | uses a callback |
12+
| Test.cs:89:13:89:56 | (...) => ... | Test.cs:89:13:89:56 | (...) => ... | Test.cs:89:13:89:56 | (...) => ... | This TLS certificate validation $@, which trusts any certificate. | Test.cs:89:13:89:56 | (...) => ... | uses a callback |
13+
| Test.cs:91:48:91:55 | access to local variable callback | Test.cs:89:13:89:56 | (...) => ... : (...) => ... | Test.cs:91:48:91:55 | access to local variable callback | This TLS certificate validation $@, which trusts any certificate. | Test.cs:89:13:89:56 | (...) => ... | uses a callback |
114
edges
215
| Test.cs:88:45:88:52 | access to local variable callback : (...) => ... | Test.cs:91:48:91:55 | access to local variable callback | provenance | |
316
| Test.cs:89:13:89:56 | (...) => ... : (...) => ... | Test.cs:88:45:88:52 | access to local variable callback : (...) => ... | provenance | |
@@ -17,16 +30,3 @@ nodes
1730
| Test.cs:89:13:89:56 | (...) => ... : (...) => ... | semmle.label | (...) => ... : (...) => ... |
1831
| Test.cs:91:48:91:55 | access to local variable callback | semmle.label | access to local variable callback |
1932
subpaths
20-
#select
21-
| Test.cs:14:13:14:57 | (...) => ... | Test.cs:14:13:14:57 | (...) => ... | Test.cs:14:13:14:57 | (...) => ... | This TLS certificate validation $@, which trusts any certificate. | Test.cs:14:13:14:57 | (...) => ... | uses a callback |
22-
| Test.cs:22:13:25:13 | (...) => ... | Test.cs:22:13:25:13 | (...) => ... | Test.cs:22:13:25:13 | (...) => ... | This TLS certificate validation $@, which trusts any certificate. | Test.cs:22:13:25:13 | (...) => ... | uses a callback |
23-
| Test.cs:33:13:33:74 | access to property DangerousAcceptAnyServerCertificateValidator | Test.cs:33:13:33:74 | access to property DangerousAcceptAnyServerCertificateValidator | Test.cs:33:13:33:74 | access to property DangerousAcceptAnyServerCertificateValidator | This TLS certificate validation $@, which trusts any certificate. | Test.cs:33:13:33:74 | access to property DangerousAcceptAnyServerCertificateValidator | uses a callback |
24-
| Test.cs:40:13:40:56 | (...) => ... | Test.cs:40:13:40:56 | (...) => ... | Test.cs:40:13:40:56 | (...) => ... | This TLS certificate validation $@, which trusts any certificate. | Test.cs:40:13:40:56 | (...) => ... | uses a callback |
25-
| Test.cs:47:13:47:61 | (...) => ... | Test.cs:47:13:47:61 | (...) => ... | Test.cs:47:13:47:61 | (...) => ... | This TLS certificate validation $@, which trusts any certificate. | Test.cs:47:13:47:61 | (...) => ... | uses a callback |
26-
| Test.cs:49:68:49:87 | (...) => ... | Test.cs:49:68:49:87 | (...) => ... | Test.cs:49:68:49:87 | (...) => ... | This TLS certificate validation $@, which trusts any certificate. | Test.cs:49:68:49:87 | (...) => ... | uses a callback |
27-
| Test.cs:51:68:51:92 | delegate(...) { ... } | Test.cs:51:68:51:92 | delegate(...) { ... } | Test.cs:51:68:51:92 | delegate(...) { ... } | This TLS certificate validation $@, which trusts any certificate. | Test.cs:51:68:51:92 | delegate(...) { ... } | uses a callback |
28-
| Test.cs:69:67:69:75 | delegate creation of type RemoteCertificateValidationCallback | Test.cs:69:67:69:75 | delegate creation of type RemoteCertificateValidationCallback | Test.cs:69:67:69:75 | delegate creation of type RemoteCertificateValidationCallback | This TLS certificate validation $@, which trusts any certificate. | Test.cs:69:67:69:75 | delegate creation of type RemoteCertificateValidationCallback | uses a callback |
29-
| Test.cs:76:13:76:76 | delegate creation of type RemoteCertificateValidationCallback | Test.cs:76:13:76:76 | delegate creation of type RemoteCertificateValidationCallback | Test.cs:76:13:76:76 | delegate creation of type RemoteCertificateValidationCallback | This TLS certificate validation $@, which trusts any certificate. | Test.cs:76:13:76:76 | delegate creation of type RemoteCertificateValidationCallback | uses a callback |
30-
| Test.cs:83:13:83:56 | (...) => ... | Test.cs:83:13:83:56 | (...) => ... | Test.cs:83:13:83:56 | (...) => ... | This TLS certificate validation $@, which trusts any certificate. | Test.cs:83:13:83:56 | (...) => ... | uses a callback |
31-
| Test.cs:89:13:89:56 | (...) => ... | Test.cs:89:13:89:56 | (...) => ... | Test.cs:89:13:89:56 | (...) => ... | This TLS certificate validation $@, which trusts any certificate. | Test.cs:89:13:89:56 | (...) => ... | uses a callback |
32-
| Test.cs:91:48:91:55 | access to local variable callback | Test.cs:89:13:89:56 | (...) => ... : (...) => ... | Test.cs:91:48:91:55 | access to local variable callback | This TLS certificate validation $@, which trusts any certificate. | Test.cs:89:13:89:56 | (...) => ... | uses a callback |
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Security Features/CWE-295/AcceptAnyCertificate.ql
1+
query: Security Features/CWE-295/AcceptAnyCertificate.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql

csharp/ql/test/query-tests/Security Features/CWE-295/AcceptAnyCertificate/Test.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public void HttpClientHandlerBad()
1111
var handler = new HttpClientHandler();
1212
// BAD: always trusts any certificate.
1313
handler.ServerCertificateCustomValidationCallback =
14-
(request, certificate, chain, errors) => true;
14+
(request, certificate, chain, errors) => true; // $ Alert
1515
}
1616

1717
public void HttpClientHandlerBlockBodyBad()
@@ -22,33 +22,33 @@ public void HttpClientHandlerBlockBodyBad()
2222
(request, certificate, chain, errors) =>
2323
{
2424
return true;
25-
};
25+
}; // $ Alert
2626
}
2727

2828
public void HttpClientHandlerDangerousBad()
2929
{
3030
var handler = new HttpClientHandler();
3131
// BAD: built-in callback that accepts any certificate.
3232
handler.ServerCertificateCustomValidationCallback =
33-
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
33+
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator; // $ Alert
3434
}
3535

3636
public void ServicePointManagerBad()
3737
{
3838
// BAD: always trusts any certificate.
3939
ServicePointManager.ServerCertificateValidationCallback =
40-
(sender, certificate, chain, errors) => true;
40+
(sender, certificate, chain, errors) => true; // $ Alert
4141
}
4242

4343
public void ServicePointManagerCompoundBad()
4444
{
4545
// BAD: always trusts any certificate (compound assignment).
4646
ServicePointManager.ServerCertificateValidationCallback +=
47-
(sender, cert, chain, errors) => { return true; };
47+
(sender, cert, chain, errors) => { return true; }; // $ Alert
4848
// BAD
49-
ServicePointManager.ServerCertificateValidationCallback += (a, b, c, d) => true;
49+
ServicePointManager.ServerCertificateValidationCallback += (a, b, c, d) => true; // $ Alert
5050
// BAD: parameterless anonymous method.
51-
ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };
51+
ServicePointManager.ServerCertificateValidationCallback += delegate { return true; }; // $ Alert
5252
}
5353

5454
private static bool AcceptAll(object sender, X509Certificate certificate, X509Chain chain,
@@ -66,29 +66,29 @@ public bool AcceptAllNonStatic(object sender, X509Certificate certificate, X509C
6666
public void MethodGroupBad()
6767
{
6868
// BAD: the referenced static method always returns true.
69-
ServicePointManager.ServerCertificateValidationCallback = AcceptAll;
69+
ServicePointManager.ServerCertificateValidationCallback = AcceptAll; // $ Alert
7070
}
7171

7272
public void MethodGroupNonStaticBad()
7373
{
7474
// BAD: the referenced instance method always returns true.
7575
ServicePointManager.ServerCertificateValidationCallback =
76-
new RemoteCertificateValidationCallback(this.AcceptAllNonStatic);
76+
new RemoteCertificateValidationCallback(this.AcceptAllNonStatic); // $ Alert
7777
}
7878

7979
public void SslStreamBad(Stream stream)
8080
{
8181
// BAD: the validation callback always returns true.
8282
var ssl = new SslStream(stream, false,
83-
(sender, certificate, chain, errors) => true);
83+
(sender, certificate, chain, errors) => true); // $ Alert
8484
}
8585

8686
public void IndirectBad(Stream stream)
8787
{
8888
RemoteCertificateValidationCallback callback =
89-
(sender, certificate, chain, errors) => true;
89+
(sender, certificate, chain, errors) => true; // $ Source Alert
9090
// BAD: the callback flowing here always returns true.
91-
var ssl = new SslStream(stream, false, callback);
91+
var ssl = new SslStream(stream, false, callback); // $ Alert
9292
}
9393

9494
public void HttpClientHandlerGood()

0 commit comments

Comments
 (0)