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

199 lines
5.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
namespace ArchestrAServices.Common.Constants;
public static class DiscoveryScope
{
public const string AsbCoreServiceScope = "archestra://coreservices";
public const string AsbUserServiceScope = "archestra://asb/";
public const string ServiceNameScope = "instancename/";
public const string ServiceVersionScope = "serviceversion/";
public const string DataTypeScope = "datatype/";
public const string SolutionNameScope = "asbsolution/";
public const string NodeNameScope = "asbnode/";
public const string BindingScope = "servicebinding/";
public const string CustomSerializerScope = "binding/customserializer/version2";
public const string DomainScope = "domainname/";
public const string NamespaceScope = "namespace/";
public const string SourceIdScope = "sourceid/";
public const string AssociationTypeScope = "associationType/";
public const string HierarchyIdScope = "hierarchyId/";
public const string HierarchyNameScope = "hierarchy/";
public const string TlsScope = "tls/";
public const string BaseRevisionScope = "baserevision/";
public const string RevisionScope = "revision/";
public static bool IsTransportSecurityScope(Uri scope)
{
bool result = false;
if (scope != null)
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("archestra://asb/");
stringBuilder.Append("tls/");
string text = stringBuilder.ToString();
if (scope.ToString().ToUpperInvariant().StartsWith(text.ToUpperInvariant()))
{
result = true;
}
}
return result;
}
public static bool DoesScopeIndicateThatTlsIsEnabled(Uri scope)
{
bool result = false;
if (scope != null && IsTransportSecurityScope(scope))
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("archestra://asb/");
stringBuilder.Append("tls/");
string text = stringBuilder.ToString();
if (bool.TryParse(scope.ToString().ToUpperInvariant().Replace(text.ToUpperInvariant(), string.Empty), out var result2))
{
result = result2;
}
}
return result;
}
public static Uri GetSolutionScope(string solutionName)
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("archestra://asb/");
stringBuilder.Append("asbsolution/");
stringBuilder.Append(solutionName);
return new Uri(stringBuilder.ToString());
}
public static Uri GetSourceIdScope(ushort sourceId)
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.Append("archestra://asb/");
stringBuilder.Append("sourceid/");
stringBuilder.Append(sourceId.ToString(CultureInfo.InvariantCulture));
return new Uri(stringBuilder.ToString());
}
public static Uri[] GetStandardServiceScope(string instanceName, string nodeName, string solutionName, BindingType bindingType, IEnumerable<ushort> sourceIds, IEnumerable<string> associationTypes, IEnumerable<ushort> hierarchyIds, IEnumerable<string> hierarchyNames, IEnumerable<Uri> customScopes, bool tlsEnabled = false)
{
List<Uri> list = new List<Uri>();
StringBuilder stringBuilder = new StringBuilder();
if (!string.IsNullOrEmpty(solutionName))
{
list.Add(GetSolutionScope(solutionName));
}
Uri item;
if (bindingType != BindingType.Custom)
{
stringBuilder.Append("archestra://asb/");
stringBuilder.Append("servicebinding/");
stringBuilder.Append(bindingType.ToString());
item = new Uri(stringBuilder.ToString());
stringBuilder.Clear();
list.Add(item);
}
if (!string.IsNullOrEmpty(nodeName))
{
stringBuilder.Append("archestra://asb/");
stringBuilder.Append("asbnode/");
stringBuilder.Append(nodeName);
item = new Uri(stringBuilder.ToString());
stringBuilder.Clear();
list.Add(item);
}
if (!string.IsNullOrEmpty(instanceName))
{
stringBuilder.Append("archestra://asb/");
stringBuilder.Append("instancename/");
stringBuilder.Append(instanceName);
item = new Uri(stringBuilder.ToString());
stringBuilder.Clear();
list.Add(item);
}
if (sourceIds != null)
{
foreach (ushort sourceId in sourceIds)
{
stringBuilder.Append("archestra://asb/");
stringBuilder.Append("sourceid/");
stringBuilder.Append(sourceId.ToString(CultureInfo.InvariantCulture));
item = new Uri(stringBuilder.ToString());
stringBuilder.Clear();
list.Add(item);
}
}
if (associationTypes != null)
{
foreach (string associationType in associationTypes)
{
stringBuilder.Append("archestra://asb/");
stringBuilder.Append("associationType/");
stringBuilder.Append(associationType);
item = new Uri(stringBuilder.ToString());
stringBuilder.Clear();
list.Add(item);
}
}
if (hierarchyIds != null)
{
foreach (ushort hierarchyId in hierarchyIds)
{
stringBuilder.Append("archestra://asb/");
stringBuilder.Append("hierarchyId/");
stringBuilder.Append(hierarchyId.ToString(CultureInfo.InvariantCulture));
item = new Uri(stringBuilder.ToString());
stringBuilder.Clear();
list.Add(item);
}
}
if (hierarchyNames != null)
{
foreach (string hierarchyName in hierarchyNames)
{
stringBuilder.Append("archestra://asb/");
stringBuilder.Append("hierarchy/");
stringBuilder.Append(hierarchyName);
item = new Uri(stringBuilder.ToString());
stringBuilder.Clear();
list.Add(item);
}
}
stringBuilder.Clear();
stringBuilder.Append("archestra://asb/");
stringBuilder.Append("tls/");
stringBuilder.Append(tlsEnabled ? "true" : "false");
item = new Uri(stringBuilder.ToString());
stringBuilder.Clear();
list.Add(item);
if (customScopes != null)
{
foreach (Uri customScope in customScopes)
{
list.Add(customScope);
}
}
return list.ToArray();
}
}