docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)

Comment/XML-doc changes only:
- add summaries to ~10k test methods, fixtures, fakes and helpers
  (+ <param> on theories, <returns> on async Task methods,
  <inheritdoc/> on interface implementations the checker can resolve)
- strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N,
  #NN, Component-0NN) from comments, keeping the explanatory text;
  reword false positives in comments only
- real docs on fakes implementing BCL/library interfaces
  (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime)
- reword the last 5 src/ false positives (CWE-1236, failures-1,
  year-0001, M365)

Only non-comment edits: four one-line nested classes split across lines
so members can carry docs. Build 0 errors / 0 warnings.
This commit is contained in:
Joseph Doherty
2026-10-07 15:05:49 -04:00
parent 0ffd4bdbea
commit 513fa1aa16
998 changed files with 17896 additions and 2395 deletions
@@ -5,13 +5,14 @@ using ZB.MOM.WW.ScadaBridge.SiteRuntime.Scripts;
namespace ZB.MOM.WW.ScadaBridge.SiteRuntime.Tests.Scripts;
/// <summary>
/// WP-6 (Phase 8): Script sandboxing verification.
/// Script sandboxing verification.
/// Adversarial tests that verify forbidden APIs are blocked at compilation time.
/// </summary>
public class SandboxTests
{
private readonly ScriptCompilationService _service;
/// <summary>Initializes the test class with a script compilation service.</summary>
public SandboxTests()
{
_service = new ScriptCompilationService(NullLogger<ScriptCompilationService>.Instance);
@@ -19,6 +20,7 @@ public class SandboxTests
// ── System.IO forbidden ──
/// <summary>Verifies that reading a file via System.IO is blocked at compilation.</summary>
[Fact]
public void Sandbox_FileRead_Blocked()
{
@@ -27,6 +29,7 @@ public class SandboxTests
Assert.Contains(result.Errors, e => e.Contains("System.IO"));
}
/// <summary>Verifies that writing a file via System.IO is blocked at compilation.</summary>
[Fact]
public void Sandbox_FileWrite_Blocked()
{
@@ -34,6 +37,7 @@ public class SandboxTests
Assert.False(result.IsSuccess);
}
/// <summary>Verifies that creating a directory via System.IO is blocked at compilation.</summary>
[Fact]
public void Sandbox_DirectoryCreate_Blocked()
{
@@ -41,6 +45,7 @@ public class SandboxTests
Assert.False(result.IsSuccess);
}
/// <summary>Verifies that using a FileStream is blocked at compilation.</summary>
[Fact]
public void Sandbox_FileStream_Blocked()
{
@@ -48,6 +53,7 @@ public class SandboxTests
Assert.False(result.IsSuccess);
}
/// <summary>Verifies that using a StreamReader is blocked at compilation.</summary>
[Fact]
public void Sandbox_StreamReader_Blocked()
{
@@ -57,6 +63,7 @@ public class SandboxTests
// ── Process forbidden ──
/// <summary>Verifies that starting a process is blocked at compilation.</summary>
[Fact]
public void Sandbox_ProcessStart_Blocked()
{
@@ -65,6 +72,7 @@ public class SandboxTests
Assert.Contains(result.Errors, e => e.Contains("Process"));
}
/// <summary>Verifies that using ProcessStartInfo is blocked at compilation.</summary>
[Fact]
public void Sandbox_ProcessStartInfo_Blocked()
{
@@ -78,6 +86,7 @@ public class SandboxTests
// ── Threading forbidden (except Tasks/CancellationToken) ──
/// <summary>Verifies that creating a thread is blocked at compilation.</summary>
[Fact]
public void Sandbox_ThreadCreate_Blocked()
{
@@ -86,6 +95,7 @@ public class SandboxTests
Assert.Contains(result.Errors, e => e.Contains("System.Threading"));
}
/// <summary>Verifies that using a Mutex is blocked at compilation.</summary>
[Fact]
public void Sandbox_Mutex_Blocked()
{
@@ -93,6 +103,7 @@ public class SandboxTests
Assert.False(result.IsSuccess);
}
/// <summary>Verifies that using a Semaphore is blocked at compilation.</summary>
[Fact]
public void Sandbox_Semaphore_Blocked()
{
@@ -100,6 +111,7 @@ public class SandboxTests
Assert.False(result.IsSuccess);
}
/// <summary>Verifies that Task.Delay is allowed.</summary>
[Fact]
public void Sandbox_TaskDelay_Allowed()
{
@@ -108,6 +120,7 @@ public class SandboxTests
Assert.Empty(violations);
}
/// <summary>Verifies that using a CancellationToken is allowed.</summary>
[Fact]
public void Sandbox_CancellationToken_Allowed()
{
@@ -116,6 +129,7 @@ public class SandboxTests
Assert.Empty(violations);
}
/// <summary>Verifies that using a CancellationTokenSource is allowed.</summary>
[Fact]
public void Sandbox_CancellationTokenSource_Allowed()
{
@@ -126,6 +140,7 @@ public class SandboxTests
// ── Reflection forbidden ──
/// <summary>Verifies that reflection via GetType is blocked at compilation.</summary>
[Fact]
public void Sandbox_GetType_Reflection_Blocked()
{
@@ -134,6 +149,7 @@ public class SandboxTests
Assert.False(result.IsSuccess);
}
/// <summary>Verifies that loading an assembly is blocked at compilation.</summary>
[Fact]
public void Sandbox_AssemblyLoad_Blocked()
{
@@ -142,6 +158,7 @@ public class SandboxTests
Assert.False(result.IsSuccess);
}
/// <summary>Verifies that creating an instance via Activator reflection is blocked at compilation.</summary>
[Fact]
public void Sandbox_ActivatorCreateInstance_ViaReflection_Blocked()
{
@@ -152,6 +169,7 @@ public class SandboxTests
// ── Raw network forbidden ──
/// <summary>Verifies that using a TcpClient is blocked at compilation.</summary>
[Fact]
public void Sandbox_TcpClient_Blocked()
{
@@ -160,6 +178,7 @@ public class SandboxTests
Assert.Contains(result.Errors, e => e.Contains("System.Net.Sockets"));
}
/// <summary>Verifies that using a UdpClient is blocked at compilation.</summary>
[Fact]
public void Sandbox_UdpClient_Blocked()
{
@@ -167,6 +186,7 @@ public class SandboxTests
Assert.False(result.IsSuccess);
}
/// <summary>Verifies that using an HttpClient is blocked at compilation.</summary>
[Fact]
public void Sandbox_HttpClient_Blocked()
{
@@ -175,6 +195,7 @@ public class SandboxTests
Assert.Contains(result.Errors, e => e.Contains("System.Net.Http"));
}
/// <summary>Verifies that using an HttpRequestMessage is blocked at compilation.</summary>
[Fact]
public void Sandbox_HttpRequestMessage_Blocked()
{
@@ -185,6 +206,7 @@ public class SandboxTests
// ── Allowed operations ──
/// <summary>Verifies that basic math operations are allowed.</summary>
[Fact]
public void Sandbox_BasicMath_Allowed()
{
@@ -192,6 +214,7 @@ public class SandboxTests
Assert.True(result.IsSuccess);
}
/// <summary>Verifies that LINQ operations are allowed.</summary>
[Fact]
public void Sandbox_LinqOperations_Allowed()
{
@@ -200,6 +223,7 @@ public class SandboxTests
Assert.True(result.IsSuccess);
}
/// <summary>Verifies that string operations are allowed.</summary>
[Fact]
public void Sandbox_StringOperations_Allowed()
{
@@ -208,6 +232,7 @@ public class SandboxTests
Assert.True(result.IsSuccess);
}
/// <summary>Verifies that DateTime operations are allowed.</summary>
[Fact]
public void Sandbox_DateTimeOperations_Allowed()
{
@@ -257,6 +282,8 @@ public class SandboxTests
CancellationToken = cts.Token
};
/// <summary>Verifies that an infinite loop is cancelled by the cancellation token.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Sandbox_InfiniteLoop_CancelledByToken()
{
@@ -284,6 +311,8 @@ public class SandboxTests
});
}
/// <summary>Verifies that a long-running script times out.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Sandbox_LongRunningScript_TimesOut()
{
@@ -314,6 +343,8 @@ public class SandboxTests
});
}
/// <summary>Verifies that a script that is never cancelled runs to completion.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task Sandbox_UncancelledScript_RunsToCompletion()
{
@@ -348,6 +379,7 @@ public class SandboxTests
// ── Combined adversarial attempts ──
/// <summary>Verifies that multiple violations in one script are all detected.</summary>
[Fact]
public void Sandbox_MultipleViolationsInOneScript_AllDetected()
{
@@ -363,6 +395,7 @@ public class SandboxTests
$"Expected at least 4 violations but got {violations.Count}: {string.Join("; ", violations)}");
}
/// <summary>Verifies that a forbidden using directive is still detected.</summary>
[Fact]
public void Sandbox_UsingDirective_StillDetected()
{