fix(core): resolve Medium code-review finding (Core-003)
Add FolderSegment member to NodeAclScopeKind; update WalkSystemPlatform to report NodeAclScopeKind.FolderSegment (not Equipment) for each visited Galaxy folder level, so MatchedGrant.Scope in AuthorizationDecision.Provenance correctly distinguishes Galaxy folder grants from UNS Equipment grants in the audit trail and Admin UI diagnostics. Three regression tests added to PermissionTrieTests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,5 +8,11 @@ public enum NodeAclScopeKind
|
||||
UnsArea,
|
||||
UnsLine,
|
||||
Equipment,
|
||||
/// <summary>
|
||||
/// A Galaxy (SystemPlatform-kind) folder segment anchored below a namespace.
|
||||
/// Distinguishes folder grants from UNS <see cref="Equipment"/> grants in the
|
||||
/// <c>AuthorizationDecision.Provenance</c> audit trail and Admin UI diagnostics.
|
||||
/// </summary>
|
||||
FolderSegment,
|
||||
Tag,
|
||||
}
|
||||
|
||||
@@ -79,16 +79,15 @@ public sealed class PermissionTrie
|
||||
|
||||
private static void WalkSystemPlatform(PermissionTrieNode ns, NodeScope scope, HashSet<string> groups, List<MatchedGrant> matches)
|
||||
{
|
||||
// FolderSegments are nested under the namespace; each is its own trie level. Reuse the
|
||||
// UnsArea scope kind for the flags — NodeAcl rows for Galaxy tags carry ScopeKind.Tag
|
||||
// for leaf grants and ScopeKind.Namespace for folder-root grants; deeper folder grants
|
||||
// are modeled as Equipment-level rows today since NodeAclScopeKind doesn't enumerate
|
||||
// a dedicated FolderSegment kind. Future-proof TODO tracked in Stream B follow-up.
|
||||
// FolderSegments are nested under the namespace; each is its own trie level. Use the
|
||||
// dedicated FolderSegment scope kind so Galaxy folder grants report their true scope in
|
||||
// AuthorizationDecision.Provenance — distinguishing them from UNS Equipment grants in
|
||||
// the audit trail and Admin UI "Probe this permission" diagnostic.
|
||||
var current = ns;
|
||||
foreach (var segment in scope.FolderSegments)
|
||||
{
|
||||
if (!current.Children.TryGetValue(segment, out var child)) return;
|
||||
CollectAtLevel(child, NodeAclScopeKind.Equipment, groups, matches);
|
||||
CollectAtLevel(child, NodeAclScopeKind.FolderSegment, groups, matches);
|
||||
current = child;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user