Skip to content

Commit e6be666

Browse files
rolfbjarneCopilot
andauthored
[xcode27.0] [tests] Misc CodeQL fixes/ignores. (#26526)
Backport of #26506. --------- Co-authored-by: Rolf Bjarne Kvinge <rokvin@microsoft.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent d2751f6 commit e6be666

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

tests/linker/link sdk/CryptoTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void TLS1_ServerNameExtension ()
105105
sne_validation_callback++;
106106
return true;
107107
};
108-
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
108+
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; // CodeQL [SM02212] this test is testing Tls1, so this is expected.
109109
WebClient wc = new WebClient ();
110110
Assert.That (wc.DownloadString (NetworkResources.StatsUrl), Is.Not.Null);
111111
} catch (WebException we) {

tests/monotouch-test/System.Net.Http/HttpbinTestServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static string Start ()
6060
try {
6161
context.Response.StatusCode = 500;
6262
var body = Encoding.UTF8.GetBytes (ex.ToString ());
63-
context.Response.OutputStream.Write (body, 0, body.Length);
63+
context.Response.OutputStream.Write (body, 0, body.Length); // CodeQL [SM00430] This is a test server that only listens on localhost.
6464
} catch {
6565
// nothing we can do
6666
}

tests/xharness/Jenkins/TestServer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public Task RunAsync (Jenkins jenkins, HtmlReportWriter htmlReportWriter)
5050
var newPort = port != 0 ? port : r.Next (49152, 65535); // The suggested range for dynamic ports is 49152-65535 (IANA)
5151
server = new HttpListener ();
5252
server.Prefixes.Clear ();
53-
server.Prefixes.Add ("http://*:" + newPort + "/");
53+
server.Prefixes.Add ("http://localhost:" + newPort + "/");
5454
try {
5555
server.Start ();
5656
port = newPort;
@@ -339,9 +339,9 @@ IEnumerable<TestTask> find_tasks (StreamWriter writer, string ids)
339339
}
340340
}
341341
var path = serveFile;
342-
if (File.Exists (path)) {
342+
if (File.Exists (path)) { // CodeQL [SM00414] This is an http server only used during testing, and it also only listens on localhost
343343
var buffer = new byte [4096];
344-
using (var fs = new FileStream (path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
344+
using (var fs = new FileStream (path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { // CodeQL [SM00414] This is an http server only used during testing, and it also only listens on localhost
345345
int read;
346346
response.ContentLength64 = fs.Length;
347347
switch (Path.GetExtension (path).ToLowerInvariant ()) {
@@ -362,7 +362,7 @@ IEnumerable<TestTask> find_tasks (StreamWriter writer, string ids)
362362
break;
363363
}
364364
while ((read = fs.Read (buffer, 0, buffer.Length)) > 0)
365-
response.OutputStream.Write (buffer, 0, read);
365+
response.OutputStream.Write (buffer, 0, read); // CodeQL [SM00430] This is an http server only used during testing, and it also only listens on localhost
366366
}
367367
} else {
368368
Console.WriteLine ($"404: {localPath}");

0 commit comments

Comments
 (0)