feat(scripts): read-only, allow-listed Files global for site scripts; Delmia test receiver parses recipe files
Script file access (design docs/plans/2026-09-28-script-file-access-design.md): Files.ReadTextAsync / ReadLinesAsync / ExistsAsync on site ScriptGlobals (+ Instance.Files), backed by the site-singleton ScriptFileReader. The one host-mediated exception to the System.IO ban - scripts still never name a System.IO type. OFF by default: ScadaBridge:SiteRuntime:ScriptFileAccess:AllowedRoots (empty = every call throws Disabled) + MaxFileBytes (1 MiB, validated 1..64 MiB, roots must be absolute). Guard: fully qualified, no device paths / ADS, canonical path strictly inside a root (directory-boundary match), no reparse point on the file or any directory below the root, size cap before and during the read. Errors are one Commons type, ScriptFileAccessException(+ScriptFileAccessFailure); Commons.Types.Scripts joins the default script imports on every surface so it binds by short name. Mirrored on ScriptCompileSurface (CompileFiles, parity-pinned) and the Test Run sandbox (binds, refuses Disabled). Inbound (central) scripts do not get it. Rig: docker/recipes (sample RecipeValueName,RecipeValue files incl. an invalid one) bind-mounted read-only at /app/recipes on both site-a nodes with AllowedRoots [/app/recipes]. The TestMesMachine SimDelmiaRecipe simulator now reads + parses the downloaded file, converts each value to its recipe tag's type and loads it all-or-nothing (14 new TestDelmiaReceiver attributes); verify-mes-test-machine.sh group A covers accept / re-download / invalid lines / NotFound / OutsideAllowedRoots, VERIFY_GROUPS selects groups (rig: AD).
This commit is contained in:
@@ -263,6 +263,7 @@ internal static class ScriptRunLauncher
|
||||
IAuditWriter? auditWriter = null;
|
||||
var siteId = string.Empty;
|
||||
string? sourceNode = null;
|
||||
IScriptFileReader? fileReader = null;
|
||||
// ISiteEventLogger is a singleton; resolve from the root provider so
|
||||
// it is available to the catch blocks regardless of scope state.
|
||||
var siteEventLogger = serviceProvider?.GetService<ISiteEventLogger>();
|
||||
@@ -346,6 +347,7 @@ internal static class ScriptRunLauncher
|
||||
operationTrackingStore = serviceScope.ServiceProvider.GetService<IOperationTrackingStore>();
|
||||
cachedForwarder = serviceScope.ServiceProvider.GetService<ICachedCallTelemetryForwarder>();
|
||||
sourceNode = serviceScope.ServiceProvider.GetService<INodeIdentityProvider>()?.NodeName;
|
||||
fileReader = serviceScope.ServiceProvider.GetService<IScriptFileReader>();
|
||||
}
|
||||
|
||||
context = new ScriptRuntimeContext(
|
||||
@@ -407,7 +409,9 @@ internal static class ScriptRunLauncher
|
||||
// effectiveOptions (the IOptionsMonitor snapshot taken at the top of this run),
|
||||
// so an operator's live edit applies from the NEXT run, like the event-policy
|
||||
// flags above.
|
||||
maxLogLinesPerRun: effectiveOptions.MaxLogLinesPerRun);
|
||||
maxLogLinesPerRun: effectiveOptions.MaxLogLinesPerRun,
|
||||
// Script file access (design 2026-09-28): the Files global's host reader.
|
||||
fileReader: fileReader);
|
||||
|
||||
var globals = new ScriptGlobals
|
||||
{
|
||||
@@ -737,7 +741,9 @@ internal static class ScriptRunLauncher
|
||||
// script's per-script execution-timeout token so a
|
||||
// Attributes.WaitAsync inside an on-trigger script is bounded
|
||||
// by the same script deadline.
|
||||
scriptTimeoutToken: cts.Token);
|
||||
scriptTimeoutToken: cts.Token,
|
||||
// Script file access (design 2026-09-28): the Files global's host reader.
|
||||
fileReader: services?.GetService<IScriptFileReader>());
|
||||
|
||||
var globals = new ScriptGlobals
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user