From d70f780e603ab0b38c61b93d0bd1fcd18d4a9b6c Mon Sep 17 00:00:00 2001 From: Daniel Wallace Date: Sat, 7 Nov 2026 15:31:21 -0800 Subject: [PATCH] RynthDreamWeave: Task 6 re-review, close the source-scan gaps - Calls: one CallPattern for the lock and Draw allow-lists, which also reads "?." member chains and a type-argument list before "(", so Reply?.Fail( and Notify( count as non-launcher calls. - Monitor is banned in WebButtons.cs and DreamWeaveWebTools.cs; the host takes the launcher's lock in exactly 9 places, and each lock body is pinned exactly (no host property read under it either). - ServerChatText: everything before its first lock is pinned exactly (declarations only), so no gate, return or throw can come before the launcher reads the line. - WebLauncher.cs holds no Action, Func or delegate; any scanned file with a raw string literal fails, since the scan does not model them. - Usage: "Market, Suit Builder or Ability Planner". The shared two lines are unchanged. Co-Authored-By: Claude Opus 5.5 --- .../DreamWeave/DreamWeaveWeb.cs | 5 +- .../DreamWeaveWebTests.cs | 54 ++++++++++++++++--- .../ServerPackCommandsTests.cs | 2 +- 3 files changed, 51 insertions(+), 10 deletions(-) diff --git a/Plugins/RynthCore.Plugin.RynthDreamWeave/DreamWeave/DreamWeaveWeb.cs b/Plugins/RynthCore.Plugin.RynthDreamWeave/DreamWeave/DreamWeaveWeb.cs index 0436ea3..199bb1f 100644 --- a/Plugins/RynthCore.Plugin.RynthDreamWeave/DreamWeave/DreamWeaveWeb.cs +++ b/Plugins/RynthCore.Plugin.RynthDreamWeave/DreamWeave/DreamWeaveWeb.cs @@ -38,8 +38,9 @@ internal static class DreamWeaveWeb var ids = new string[Destinations.Length]; var labels = new string[Destinations.Length]; for (int i = 0; i < Destinations.Length; i++) { ids[i] = Destinations[i].Id; labels[i] = Destinations[i].Label; } - return "/rserver " + string.Join(" | ", ids) + " - open the website's " + string.Join(", ", labels) - + ", logged in as this account."; + string choices = labels.Length < 2 ? string.Join("", labels) + : string.Join(", ", labels, 0, labels.Length - 1) + " or " + labels[labels.Length - 1]; + return "/rserver " + string.Join(" | ", ids) + " - open the website's " + choices + ", logged in as this account."; } /// The sign-in URL for a destination. The caller has already checked the code with LaunchWire. diff --git a/Tools/RynthServerPack.Tests/DreamWeaveWebTests.cs b/Tools/RynthServerPack.Tests/DreamWeaveWebTests.cs index 1caeac3..5f09271 100644 --- a/Tools/RynthServerPack.Tests/DreamWeaveWebTests.cs +++ b/Tools/RynthServerPack.Tests/DreamWeaveWebTests.cs @@ -176,15 +176,22 @@ internal static class DreamWeaveWebTests return found; } + /// + /// A call: an identifier or a member chain (".", "?."), an optional type-argument list, then "(". + /// Group 1 is the chain; the type arguments are left out of it ("Notify(" is "Notify"). + /// + private static readonly System.Text.RegularExpressions.Regex CallPattern = new( + @"(?();{}]*>)?\s*\("); + /// /// Every call in that is not a member call on - /// ("_web.Begin(" is allowed; "Send(", "Helper(", "if (", "x._web.Begin(" are not). + /// ("_web.Begin(" is allowed; "Send(", "Helper(", "if (", "x._web.Begin(", "a?.Invoke(", "Notify(" are not). /// internal static List CallsNotOn(string body, string receiver) { var bad = new List(); var allowed = new System.Text.RegularExpressions.Regex("^" + System.Text.RegularExpressions.Regex.Escape(receiver) + @"\.[A-Za-z_][A-Za-z0-9_]*$"); - foreach (System.Text.RegularExpressions.Match m in System.Text.RegularExpressions.Regex.Matches(body, @"(?(); - foreach (System.Text.RegularExpressions.Match m in System.Text.RegularExpressions.Regex.Matches(drawBody, @"(? hostLocks = Locks(host); - Check.True(hostLocks.Count >= 5, "the host takes the launcher's lock (" + hostLocks.Count + " places)"); + Check.Eq(hostLocks.Count, 9, "the host takes the launcher's lock in exactly 9 places"); foreach (var (target, body) in hostLocks) { Check.Eq(target, "_web.Gate", "every lock in the host is lock (_web.Gate)"); Check.Eq(string.Join(" ", CallsNotOn(body, "_web")), "", "only _web members under lock (_web.Gate): " + Collapse(body)); } + // Each lock body, exactly: launcher calls and reads, nothing else (no host property read either). + string[] lockBodies = + { + "{begun=_web.Begin(d,Environment.TickCount64);status=_web.Status;}", // StartLaunch + "_web.Cancel(notSent);", // StartLaunch, send failed + "{kind=_web.OnChatLine(text,chatType,Environment.TickCount64,outd,outlaunchCode,out_);status=_web.Status;generation=_web.Generation;}", // ServerChatText + "_web.SetResult(generation,text);", // SetWebResult + "{timedOut=_web.TakeTimedOut(Environment.TickCount64);status=_web.Status;}", // ServerTick + "status=_web.Status;", // ServerInfoLines + "_web.Reset();", // ServerLoginComplete + "_web.Reset();", // ServerLogout + "_web.Reset();", // ServerShutdown + }; + Check.Eq(string.Join("\n", hostLocks.Select(l => Collapse(l.Body))), string.Join("\n", lockBodies), "the host's lock bodies, exactly"); Check.False(host.Contains("DateTime", StringComparison.Ordinal) || host.Contains("Stopwatch", StringComparison.Ordinal), "nowMs comes from Environment.TickCount64 only"); Check.True(host.Contains("Environment.TickCount64", StringComparison.Ordinal), "the host uses Environment.TickCount64"); @@ -319,8 +354,11 @@ internal static class DreamWeaveWebTests string chat = chatHook.Count == 1 ? chatHook[0] : ""; int onChat = chat.IndexOf("OnChatLine(", StringComparison.Ordinal); Check.True(onChat > 0, "ServerChatText calls OnChatLine"); - Check.False(onChat > 0 && System.Text.RegularExpressions.Regex.IsMatch(chat.Substring(0, onChat), @"(?", + "{LaunchLinekind=LaunchLine.NotOurs;try{WebDestination?d;stringlaunchCode;stringstatus;longgeneration;", + "ServerChatText: nothing but declarations before the launcher reads the line (a code must be eaten whatever the world is now)"); // Stale eats the line and does nothing else. int stale = host.IndexOf("case LaunchLine.Stale:", StringComparison.Ordinal); @@ -387,6 +425,8 @@ internal static class DreamWeaveWebTests Check.Eq(locks[1].Target, "other", "another target is reported as it is"); Check.Eq(string.Join(" ", CallsNotOn(locks[2].Body, "_web")), "if( b(", "keywords and helpers are not launcher calls"); Check.Eq(string.Join(" ", CallsNotOn("x._web.Begin(); _web.Begin(); _web.Gate.Foo();", "_web")), "x._web.Begin( _web.Gate.Foo(", "only a direct _web member call is allowed"); + Check.Eq(string.Join(" ", CallsNotOn("a?.Invoke(x); Notify(y); _web.Begin();", "_web")), "a?.Invoke( Notify(", "null-conditional and generic calls are calls"); + Check.Eq(string.Join(" ", CallsNotOn("_web?.Begin(); _web.Begin();", "_web")), "_web?.Begin(", "_web?. is not the allowed form; a generic _web member call is"); } private const string Code = "AbCdEfGhIjKlMnOpQrStUvWxYz0123456789-_AbCde"; // 43 chars diff --git a/Tools/RynthServerPack.Tests/ServerPackCommandsTests.cs b/Tools/RynthServerPack.Tests/ServerPackCommandsTests.cs index 25b7eaa..b088ea4 100644 --- a/Tools/RynthServerPack.Tests/ServerPackCommandsTests.cs +++ b/Tools/RynthServerPack.Tests/ServerPackCommandsTests.cs @@ -74,7 +74,7 @@ internal static class ServerPackCommandsTests // DreamWeave's verbs follow the shared two. string[] dw = ServerPackCommands.Usage("DreamWeave", new List { RynthCore.Plugin.RynthDreamWeave.DreamWeaveWeb.UsageLine() }); Check.Eq(dw.Length, 3, "DreamWeave: three usage lines"); - Check.Eq(dw[2], "/rserver market | suit | abilities - open the website's Market, Suit Builder, Ability Planner, logged in as this account.", "DreamWeave's own line"); + Check.Eq(dw[2], "/rserver market | suit | abilities - open the website's Market, Suit Builder or Ability Planner, logged in as this account.", "DreamWeave's own line"); Check.True(dw[0] == ServerPackCommands.Usage("DreamWeave")[0] && dw[1] == ServerPackCommands.Usage("DreamWeave")[1], "the shared two come first, unchanged"); }