Files
mxaccess/analysis/decompiled/aaServicesCommon/ArchestrAServices.Common/ConfigurationRepository.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

132 lines
5.1 KiB
C#

#define TRACE
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Xml.Linq;
namespace ArchestrAServices.Common;
public class ConfigurationRepository
{
private readonly Dictionary<string, string> configurationRepositoryInternal = new Dictionary<string, string>();
public ConfigurationRepository()
{
configurationRepositoryInternal = new Dictionary<string, string>();
Initialize();
}
public static string ExtractValueFromKey(XElement configuration, string key, string defaultValue)
{
string text = LookupKeyInElement(configuration, "ServiceParameters", key);
if (string.IsNullOrEmpty(text))
{
text = LookupKeyInElement(configuration, "CustomData", key);
}
if (string.IsNullOrEmpty(text))
{
SvcTrace.DiagDiagnostics.TraceEvent(TraceEventType.Information, 2, $"ExtractValueFromKey cannot find key '{key}', using default '{defaultValue}'");
text = defaultValue;
}
return text;
}
public void InsertExtractedParameter(XElement configuration, string Name, string DefaultValue = null)
{
if (string.IsNullOrEmpty(DefaultValue))
{
DefaultValue = GetParameter(Name);
}
string value = ExtractValueFromKey(configuration, Name, DefaultValue);
configurationRepositoryInternal[Name] = value;
}
public void InsertParameter(string Name, string Value)
{
configurationRepositoryInternal[Name] = Value;
}
public string GetParameter(string Name)
{
string result = string.Empty;
if (configurationRepositoryInternal.ContainsKey(Name))
{
result = configurationRepositoryInternal[Name];
}
return result;
}
public string GetParameter(string Name, string DefaultValue)
{
string text = GetParameter(Name);
if (string.IsNullOrEmpty(text))
{
text = DefaultValue;
}
return text;
}
private static string LookupKeyInElement(XElement configuration, string OuterElement, string key)
{
string empty = string.Empty;
try
{
string text = (from ServiceParameters in configuration.Element(OuterElement).Elements("Parameter")
where key == ServiceParameters.Attribute("name").Value
select ServiceParameters.Attribute("value").Value).First();
if (text != null && text.Length > 0)
{
SvcTrace.DiagDiagnostics.TraceEvent(TraceEventType.Information, 3, $"ExtractValueFromKey extracting value '{text}' from key '{key}'");
empty = text;
}
else
{
empty = string.Empty;
}
}
catch (Exception ex)
{
empty = string.Empty;
SvcTrace.DiagException.TraceEvent(TraceEventType.Error, 0, $"Exception raised : {ex.Message}");
}
return empty;
}
private void Initialize()
{
InsertParameter("netTcpBinding.Security.Mode", "None");
InsertParameter("netTcpBinding.TransferMode", "Buffered");
InsertParameter("netTcpBinding.MaxReceivedMessageSize", int.MaxValue.ToString());
InsertParameter("netTcpBinding.MaxBufferSize", int.MaxValue.ToString());
InsertParameter("netTcpBinding.MaxBufferPoolSize", long.MaxValue.ToString());
InsertParameter("netTcpBinding.ReaderQuotas.MaxArrayLength", int.MaxValue.ToString());
InsertParameter("netTcpBinding.ReaderQuotas.MaxBytesPerRead", int.MaxValue.ToString());
InsertParameter("netTcpBinding.ReaderQuotas.MaxDepth", int.MaxValue.ToString());
InsertParameter("netTcpBinding.ReaderQuotas.MaxNameTableCharCount", int.MaxValue.ToString());
InsertParameter("netTcpBinding.ReaderQuotas.MaxStringContentLength", int.MaxValue.ToString());
InsertParameter("netTcpBinding.OpenTimeout", new TimeSpan(0, 1, 0).ToString());
InsertParameter("netTcpBinding.ReceiveTimeout", new TimeSpan(0, 1, 0).ToString());
InsertParameter("netTcpBinding.SendTimeout", new TimeSpan(0, 1, 0).ToString());
InsertParameter("netTcpBinding.CloseTimeout", new TimeSpan(0, 1, 0).ToString());
InsertParameter("netTcpBinding.ReliableSession.InactivityTimeout", new TimeSpan(0, 1, 0).ToString());
InsertParameter("HttpBinding.Security.Mode", "None");
InsertParameter("HttpBinding.AllowCookies", "false");
InsertParameter("HttpBinding.BypassProxyOnLocal", "true");
InsertParameter("HttpBinding.HostNameComparisonMode", "StrongWildcard");
InsertParameter("HttpBinding.MessageEncoding", "Text");
InsertParameter("HttpBinding.MaxReceivedMessageSize", int.MaxValue.ToString());
InsertParameter("HttpBinding.MaxBufferPoolSize", long.MaxValue.ToString());
InsertParameter("HttpBinding.ReaderQuotas.MaxArrayLength", int.MaxValue.ToString());
InsertParameter("HttpBinding.ReaderQuotas.MaxBytesPerRead", int.MaxValue.ToString());
InsertParameter("HttpBinding.ReaderQuotas.MaxDepth", int.MaxValue.ToString());
InsertParameter("HttpBinding.ReaderQuotas.MaxNameTableCharCount", int.MaxValue.ToString());
InsertParameter("HttpBinding.ReaderQuotas.MaxStringContentLength", int.MaxValue.ToString());
InsertParameter("HttpBinding.OpenTimeout", new TimeSpan(0, 1, 0).ToString());
InsertParameter("HttpBinding.ReceiveTimeout", new TimeSpan(0, 1, 0).ToString());
InsertParameter("HttpBinding.SendTimeout", new TimeSpan(0, 1, 0).ToString());
InsertParameter("HttpBinding.CloseTimeout", new TimeSpan(0, 1, 0).ToString());
InsertParameter("HttpBinding.ReliableSession.InactivityTimeout", new TimeSpan(0, 1, 0).ToString());
}
}