test(grpc-data): A3a over-the-wire imported-condition events (exactly-once, identity, A3-SEC, child Read, N4, N7, resync, T2) + OwnsNamespace covers mapped/conditions

This commit is contained in:
Joseph Doherty
2026-11-24 16:35:01 -05:00
parent 8d6c94a3b3
commit de381157cf
3 changed files with 399 additions and 4 deletions
@@ -6051,7 +6051,10 @@ public sealed partial class OtOpcUaNodeManager : CustomNodeManager2, INodeManage
private bool OwnsNamespace(NodeId? nodeId) =>
nodeId is { } id
&& (id.NamespaceIndex == NamespaceIndexes[0] || id.NamespaceIndex == NamespaceIndexes[1] ||
id.NamespaceIndex == NamespaceIndexes[2] || id.NamespaceIndex == NamespaceIndexes[3]);
id.NamespaceIndex == NamespaceIndexes[2] || id.NamespaceIndex == NamespaceIndexes[3] ||
// A3: the imported-condition namespace is ours too — without it a condition's children keep their type ids and
// every Permits() would pass an imported id as "not ours to gate".
(NamespaceIndexes.Count > 4 && id.NamespaceIndex == NamespaceIndexes[4]));
/// <summary>Pulls the ACL identity off an SDK operation context.</summary>
/// <param name="context">The SDK context carrying the session identity.</param>
@@ -6556,13 +6559,13 @@ public sealed partial class OtOpcUaNodeManager : CustomNodeManager2, INodeManage
// Only creation is gated. Refusing an UNSUBSCRIBE would strand the item on a node the session can
// no longer reach — the client could never detach it, and the server would keep delivering.
// A3 (§5.4): an event item on a projected notifier (a folder wired for imported conditions) is admitted through the
// verified path — Browse on the folder at subscribe time, the mapping gate per event at delivery and again at
// publish — instead of the mapped blanket deny that still applies to data items.
// verified path — the mapping gate of some condition wired there at subscribe time, per event at delivery and again
// at publish — instead of the mapped blanket deny that still applies to data items.
var projectedNotifier = !unsubscribe && IsHandleInNamespace(sourceId) is { } candidate && IsProjectedEventNotifier(candidate.NodeId)
? candidate.NodeId : (NodeId?)null;
if (projectedNotifier is { } notifierId)
{
if (!Permits(IdentityOf(context), OpcUaOperation.Browse, notifierId)) return StatusCodes.BadUserAccessDenied;
if (!ImportedNotifierAdmits(IdentityOf(context), notifierId)) return StatusCodes.BadUserAccessDenied;
}
else if (SecurityFilteringActive && !unsubscribe
&& IsHandleInNamespace(sourceId) is { } source
@@ -510,6 +510,18 @@ public sealed partial class OtOpcUaNodeManager : IProjectedConditionSink
lock (Lock) return _importedConditions.WiredByFolder.ContainsKey(nodeId);
}
/// <summary>§5.4 admission of an event item on a projected notifier: the caller sees at least one condition wired there.</summary>
private bool ImportedNotifierAdmits(RoleCarryingUserIdentity? identity, NodeId notifierId)
{
List<ImportedCondition> wired;
lock (Lock)
{
if (!_importedConditions.WiredByFolder.TryGetValue(notifierId, out var ids)) return false;
wired = ids.Select(_importedConditions.Find).OfType<ImportedCondition>().ToList();
}
return wired.Any(c => ImportedVisibleTo(identity, c));
}
/// <summary>
/// The authorizer's pre-realm classifier (§5.2): null for any id outside the imported-condition namespace, otherwise
/// the imported verdict.