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:
@@ -1,16 +1,16 @@
|
||||
namespace ZB.MOM.WW.ScadaBridge.InboundAPI.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// InboundAPI-005 / InboundAPI-015: tests for the script-trust-model checker.
|
||||
/// Tests for the script-trust-model checker.
|
||||
///
|
||||
/// Since M3.4 <see cref="ForbiddenApiChecker"/> delegates to the shared
|
||||
/// The <see cref="ForbiddenApiChecker"/> delegates to the shared
|
||||
/// <c>ScriptTrustValidator</c> in <c>ZB.MOM.WW.ScadaBridge.ScriptAnalysis</c>.
|
||||
/// The unified policy differs from the old local deny-list in one notable way:
|
||||
/// <c>System.Diagnostics</c> is loosened to <c>System.Diagnostics.Process</c>
|
||||
/// only — <c>Stopwatch</c>, <c>Debug</c>, and other non-Process Diagnostics
|
||||
/// types are now ALLOWED.
|
||||
///
|
||||
/// InboundAPI-015 hardening (reflection-gateway / dynamic / Activator) is
|
||||
/// Hardening (reflection-gateway / dynamic / Activator) is
|
||||
/// preserved unchanged via the shared validator.
|
||||
///
|
||||
/// Violation message wording is intentionally not asserted — callers should
|
||||
@@ -23,6 +23,8 @@ public class ForbiddenApiCheckerTests
|
||||
|
||||
// --- Baseline: legitimate scripts must still pass ---
|
||||
|
||||
/// <summary>Verifies that a legitimate script is not rejected.</summary>
|
||||
/// <param name="script">The permitted script source.</param>
|
||||
[Theory]
|
||||
[InlineData("return 1 + 1;")]
|
||||
[InlineData("var list = new List<int> { 1, 2, 3 }; return list.Sum();")]
|
||||
@@ -36,9 +38,10 @@ public class ForbiddenApiCheckerTests
|
||||
}
|
||||
|
||||
// --- System.Diagnostics loosening: Process is still forbidden; non-Process types
|
||||
// (Stopwatch, Debug) are now ALLOWED by the unified policy (M3.4). The old
|
||||
// (Stopwatch, Debug) are now ALLOWED by the unified policy. The old
|
||||
// InboundAPI checker blocked the entire System.Diagnostics namespace. ---
|
||||
|
||||
/// <summary>Verifies that System.Diagnostics.Process is still forbidden.</summary>
|
||||
[Fact]
|
||||
public void Diagnostics_Process_StillForbidden()
|
||||
{
|
||||
@@ -46,6 +49,7 @@ public class ForbiddenApiCheckerTests
|
||||
Assert.True(IsRejected("System.Diagnostics.Process.Start(\"/bin/sh\"); return null;"));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Stopwatch from System.Diagnostics is now allowed.</summary>
|
||||
[Fact]
|
||||
public void Diagnostics_Stopwatch_NowAllowed()
|
||||
{
|
||||
@@ -55,6 +59,7 @@ public class ForbiddenApiCheckerTests
|
||||
Assert.False(IsRejected("var sw = new System.Diagnostics.Stopwatch(); sw.Start(); return null;"));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Debug from System.Diagnostics is now allowed.</summary>
|
||||
[Fact]
|
||||
public void Diagnostics_Debug_NowAllowed()
|
||||
{
|
||||
@@ -64,6 +69,8 @@ public class ForbiddenApiCheckerTests
|
||||
|
||||
// --- Baseline: forbidden namespaces (textual) must still be rejected ---
|
||||
|
||||
/// <summary>Verifies that a script using a forbidden namespace is rejected.</summary>
|
||||
/// <param name="script">The script source that uses a forbidden namespace.</param>
|
||||
[Theory]
|
||||
[InlineData("System.IO.File.Delete(\"/tmp/x\"); return null;")]
|
||||
[InlineData("using System.Reflection; return null;")]
|
||||
@@ -73,8 +80,9 @@ public class ForbiddenApiCheckerTests
|
||||
Assert.True(IsRejected(script), script);
|
||||
}
|
||||
|
||||
// --- InboundAPI-015: reflection reachable without a forbidden namespace token ---
|
||||
// --- Reflection reachable without a forbidden namespace token ---
|
||||
|
||||
/// <summary>Verifies that reflection through assembly property access is rejected.</summary>
|
||||
[Fact]
|
||||
public void Reflection_AssemblyPropertyAccess_Rejected()
|
||||
{
|
||||
@@ -82,6 +90,7 @@ public class ForbiddenApiCheckerTests
|
||||
Assert.True(IsRejected("var a = typeof(string).Assembly; return null;"));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that reflection through Assembly.GetType is rejected.</summary>
|
||||
[Fact]
|
||||
public void Reflection_AssemblyGetType_Rejected()
|
||||
{
|
||||
@@ -90,6 +99,7 @@ public class ForbiddenApiCheckerTests
|
||||
"var t = typeof(string).Assembly.GetType(\"System.IO.File\"); return null;"));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that reflection through Object.GetType is rejected.</summary>
|
||||
[Fact]
|
||||
public void Reflection_ObjectGetType_Rejected()
|
||||
{
|
||||
@@ -97,12 +107,14 @@ public class ForbiddenApiCheckerTests
|
||||
Assert.True(IsRejected("var t = \"\".GetType(); return null;"));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the static Type.GetType reflection entry point is rejected.</summary>
|
||||
[Fact]
|
||||
public void Reflection_TypeGetTypeStatic_Rejected()
|
||||
{
|
||||
Assert.True(IsRejected("var t = Type.GetType(\"System.IO.File\"); return null;"));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Activator.CreateInstance is rejected.</summary>
|
||||
[Fact]
|
||||
public void Reflection_ActivatorCreateInstance_Rejected()
|
||||
{
|
||||
@@ -110,6 +122,7 @@ public class ForbiddenApiCheckerTests
|
||||
"var o = Activator.CreateInstance(Type.GetType(\"System.IO.File\")); return null;"));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that Type.InvokeMember is rejected.</summary>
|
||||
[Fact]
|
||||
public void Reflection_InvokeMember_Rejected()
|
||||
{
|
||||
@@ -117,6 +130,7 @@ public class ForbiddenApiCheckerTests
|
||||
"typeof(object).InvokeMember(\"x\", default, null, null, null); return null;"));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that GetMethod followed by Invoke is rejected.</summary>
|
||||
[Fact]
|
||||
public void Reflection_GetMethodInvoke_Rejected()
|
||||
{
|
||||
@@ -124,12 +138,14 @@ public class ForbiddenApiCheckerTests
|
||||
"var m = typeof(object).GetMethod(\"ToString\"); return null;"));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that GetTypeInfo is rejected.</summary>
|
||||
[Fact]
|
||||
public void Reflection_GetTypeInfo_Rejected()
|
||||
{
|
||||
Assert.True(IsRejected("var ti = \"\".GetType().GetTypeInfo(); return null;"));
|
||||
}
|
||||
|
||||
/// <summary>Verifies that the dynamic keyword is rejected.</summary>
|
||||
[Fact]
|
||||
public void DynamicKeyword_Rejected()
|
||||
{
|
||||
@@ -139,6 +155,8 @@ public class ForbiddenApiCheckerTests
|
||||
|
||||
// --- FindViolations returns a non-null, non-throwing result for edge inputs ---
|
||||
|
||||
/// <summary>Verifies that an empty, whitespace or null script yields an empty violation list.</summary>
|
||||
/// <param name="script">The empty, whitespace or null script source.</param>
|
||||
[Theory]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
|
||||
Reference in New Issue
Block a user