Files
mxaccess/analysis/decompiled/aaServicesCommonDataContracts/ArchestrAServices.Proxy/ASBSolutionManager.cs
T
Joseph Doherty fe2a6db786
rust / build / test / clippy / fmt (push) Has been cancelled
Initial project state: .NET reference, design, Rust port (M0+M1), evidence
Layout:
- src/                    .NET 10 x64 reference: MxNativeCodec, MxNativeClient,
                          MxAsbClient, probes, tests, harnesses. Executable spec.
- design/                 Architectural plan for the Rust port (M0–M6), error
                          model, protocol invariants, risks (R1–R16), adversarial
                          review log (review.md).
- rust/                   Rust workspace. M0 skeleton + M1 codec parity.
                          mxaccess-codec: 215 unit tests + 2 cross-implementation
                          parity tests (byte-identical against .NET reference).
                          Other crates are M0 stubs awaiting M2+.
- captures/               Frida + netsh + pcap evidence per CLAUDE.md
                          ("captures are evidence, not throwaway logs").
- analysis/               Decompiled C# (frida/proxy/decompiled-*),
                          Ghidra exports for native DLLs (`exports/` only —
                          working state at `projects/` and AVEVA's input
                          binaries at `input/` are gitignored).
- docs/                   Reverse-engineering reference docs.
- tools/                  Setup-LiveProbeEnv.ps1 (Infisical credential fetcher),
                          Compute-Crc.ps1 (.NET parity helper).
- .github/workflows/      Rust CI: fmt + build + test + clippy on Windows.
- LICENSE                 MIT (Joseph Doherty, 2026).

Verified:
- cargo test --workspace → 217 passed (215 unit + 2 .NET parity), 0 failed
- cargo clippy --workspace -- -D warnings → clean
- cargo fmt --all -- --check → clean
- cargo publish --dry-run -p mxaccess-codec → packages cleanly

Excluded from history (see .gitignore):
- **/bin, **/obj, **/target — build artifacts
- analysis/ghidra/projects/ — Ghidra working state (regenerable)
- analysis/ghidra/input/ — AVEVA proprietary DLLs (vendor IP)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-05 06:21:00 -04:00

104 lines
4.1 KiB
C#

#define TRACE
using System;
using System.Diagnostics;
using System.ServiceModel.Discovery;
using ArchestrAServices.Common;
using ArchestrAServices.Contract;
namespace ArchestrAServices.Proxy;
public class ASBSolutionManager
{
public static string ASBSolutionScope = "archestra://asb/" + ("archestra://asb/".EndsWith("/") ? string.Empty : "/") + "asbsolution/";
public static string CoreServiceSolutionScope = "archestra://coreservices" + ("archestra://coreservices".EndsWith("/") ? string.Empty : "/") + "asbsolution/";
public string GetASBSolutionPassphrase(EndpointDiscoveryMetadata DiscoveryMetadata, out string errorMessage)
{
string aSBSolutionName = GetASBSolutionName(DiscoveryMetadata, out errorMessage);
if (string.IsNullOrEmpty(aSBSolutionName))
{
errorMessage = RegistryHandler.GetSolutionPassphrase(aSBSolutionName, out var passphrase);
return passphrase;
}
return GetASBSolutionPassphrase(aSBSolutionName, out errorMessage);
}
public string GetASBSolutionName(EndpointDiscoveryMetadata DiscoveryMetadata, out string errorMessage)
{
errorMessage = string.Empty;
string text = ASBSolutionScope.ToLower();
string text2 = CoreServiceSolutionScope.ToLower();
foreach (Uri scope in DiscoveryMetadata.Scopes)
{
string text3 = string.Empty;
string text4 = scope.AbsoluteUri.ToString().ToLower();
if (text4.StartsWith(text))
{
text3 = scope.AbsoluteUri.ToString().Substring(text.Length);
}
if (text4.StartsWith(text2))
{
text3 = scope.AbsoluteUri.ToString().Substring(text2.Length);
}
if (!string.IsNullOrEmpty(text3))
{
if (text3.StartsWith("/"))
{
text3 = text3.Substring(1);
}
if (text3.EndsWith("/"))
{
text3 = text3.Substring(0, text3.Length - 1);
}
return text3;
}
}
errorMessage = "GetASBSolutionName unable to find solution name in scopes provided in DiscoveryMetadata";
return string.Empty;
}
public string GetASBSolutionPassphrase(string SolutionName, out string errorMessage)
{
errorMessage = string.Empty;
errorMessage = RegistryHandler.GetSolutionPassphrase(SolutionName, out var passphrase);
if (string.IsNullOrEmpty(errorMessage))
{
return passphrase;
}
using (ManageASBSecurityProxy manageASBSecurityProxy = new ManageASBSecurityProxy(string.Empty))
{
if (!manageASBSecurityProxy.Connect(string.Empty, out errorMessage))
{
errorMessage = "GetASBSolutionPassphrase(" + SolutionName + ") failed to connect to default SR node on ASB endpoint: " + errorMessage;
SvcTrace.DiagException.TraceEvent(TraceEventType.Warning, 0, $"GetASBSolutionPassphrase: failed to connect to default SR node on ASB endpoint: {errorMessage}");
}
if (string.IsNullOrEmpty(errorMessage))
{
SystemAuthenticationASBConfiguration ConfigurationData = default(SystemAuthenticationASBConfiguration);
string XMLExtraInfo = string.Empty;
ArchestrAResult serviceBusPlatformConfiguration = manageASBSecurityProxy.GetServiceBusPlatformConfiguration(out ConfigurationData, out XMLExtraInfo, default(Guid), string.IsNullOrEmpty(SolutionName) ? "Register/" : SolutionName);
if (serviceBusPlatformConfiguration.Status == 0)
{
errorMessage = ASBSolutionUtilities.WriteSecurityInformationInRegistry(ConfigurationData, XMLExtraInfo);
}
else
{
errorMessage = "Failed to get SecurityConfiguration from SystemAuthentication service with Status = " + serviceBusPlatformConfiguration.Status;
SvcTrace.DiagException.TraceEvent(TraceEventType.Warning, 0, $"GetASBSolutionPassphrase: Failed to get SecurityConfiguration from SystemAuthentication service with Status: {serviceBusPlatformConfiguration.Status.ToString()}");
}
}
else
{
SvcTrace.DiagException.TraceEvent(TraceEventType.Warning, 0, $"GetASBSolutionPassphrase: cannot continue: {errorMessage}");
}
errorMessage = RegistryHandler.GetSolutionPassphrase(SolutionName, out passphrase);
if (!string.IsNullOrEmpty(errorMessage))
{
SvcTrace.DiagException.TraceEvent(TraceEventType.Warning, 0, $"GetASBSolutionPassphrase: After retrieving solution {SolutionName}, cannot find passphrase: {errorMessage}'");
}
}
return passphrase;
}
}