diff options
Diffstat (limited to 'src/Agent.Windows')
| -rw-r--r-- | src/Agent.Windows/Diagnostics/WindowsPlatformCheck.cs | 10 | ||||
| -rw-r--r-- | src/Agent.Windows/Security/AppContainerProfile.cs | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/Agent.Windows/Diagnostics/WindowsPlatformCheck.cs b/src/Agent.Windows/Diagnostics/WindowsPlatformCheck.cs index 89a2106..32086d3 100644 --- a/src/Agent.Windows/Diagnostics/WindowsPlatformCheck.cs +++ b/src/Agent.Windows/Diagnostics/WindowsPlatformCheck.cs @@ -36,9 +36,9 @@ public static class WindowsPlatformCheck bfe = true; if (helper) { - string current = Assembly.GetEntryAssembly()?.GetName().Version?.ToString(3) ?? ""; + Version? current = Assembly.GetEntryAssembly()?.GetName().Version; string candidate = FileVersionInfo.GetVersionInfo(helperPath).FileVersion ?? ""; - version = candidate.StartsWith(current, StringComparison.Ordinal); + version = current is not null && HasSameReleaseIdentity(current, candidate); } return new(platform, profile, bfe, helper, version, null, null); } @@ -47,6 +47,12 @@ public static class WindowsPlatformCheck { return new(platform, profile, bfe, helper, version, ex.HResult, ex.Message); } } + internal static bool HasSameReleaseIdentity(Version current, string candidate) + { + if (!Version.TryParse(candidate, out Version? parsed)) return false; + return current.Major == parsed.Major && current.Minor == parsed.Minor && current.Build == parsed.Build; + } + private static FwpmEngineClose0SafeHandle OpenBfeReadOnly() { uint result = PInvoke.FwpmEngineOpen0(10, null, null, out FwpmEngineClose0SafeHandle engine); diff --git a/src/Agent.Windows/Security/AppContainerProfile.cs b/src/Agent.Windows/Security/AppContainerProfile.cs index 97258ec..83b1675 100644 --- a/src/Agent.Windows/Security/AppContainerProfile.cs +++ b/src/Agent.Windows/Security/AppContainerProfile.cs @@ -14,7 +14,7 @@ public sealed partial class AppContainerProfile public static AppContainerProfile EnsureFixed() { - int result = Native.CreateAppContainerProfile(FixedName, "Agent Sandbox MCP v1", "Fixed sandbox profile for Agent Sandbox MCP", 0, 0, out nint sidPointer); + int result = Native.CreateAppContainerProfile(FixedName, "WinAgent Sandbox MCP", "Fixed sandbox profile for WinAgent Sandbox MCP", 0, 0, out nint sidPointer); if (result == AlreadyExists) result = Native.DeriveAppContainerSidFromAppContainerName(FixedName, out sidPointer); if (result < 0) Marshal.ThrowExceptionForHR(result); try |
