[GalaxyRepository] Scoped browse hides the ancestors of an allowed subtree #42
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
From the scadaproj#15 shared-library review (
code-reviews/GalaxyRepository/findings.md, GalaxyRepository-002), verified at91fb2b4. Update the finding's Resolution row when fixed.ZB.MOM.WW.GalaxyRepository/src/ZB.MOM.WW.GalaxyRepository/GalaxyBrowseProjector.cs:134(alsoZB.MOM.WW.GalaxyRepository/src/ZB.MOM.WW.GalaxyRepository/GalaxyHierarchyProjector.cs:233)Description
GetFilteredChildrenrunsMatchesBrowseSubtrees(view, globs)first andcontinues when a directchild fails it. It never checks whether that child has a descendant that is inside the allowed
subtree.
Right below, the request-filter branch does surface ancestors of matching descendants, with
HasMatchingDescendantand the comment "a matching descendant should still surface its ancestor".The scope branch has no equivalent.
So with a scope glob like
Plant/LineA/*, neitherPlantnorPlant/LineAmatches. Both arefiltered out of their parent's child list.
DiscoverHierarchylikewise omits thePlant/LineAareaobject itself.
Failure scenario
An mxaccessgw API key is scoped to
BrowseSubtrees: ["Plant/LineA/*"]. A lazy-browse client startsat the root with
BrowseChildren{}and expands nodes, as the OtOpcUa / ScadaBridge browse dialogsdo. Scratch-test result over
Plant → LineA → Pump01,Plant → LineB → Pump02:BrowseChildren:TotalChildCount = 0.DiscoverHierarchy: onlyPump01(noLineAarea).BrowseChildren{ParentContainedPath="Plant/LineA"}: 1 child.The scoped user sees an empty Galaxy unless they already know and type the exact parent path.
Admins can work around it by also listing the ancestor paths as globs (
Plant,Plant/LineA), butthat is undocumented. It also exposes those ancestor objects with their attributes, which is wider
than the intended scope.
Recommendation
In
GetFilteredChildren, when a child fails the scope check, test whether it is an ancestor of anallowed path. Either use
HasMatchingDescendantwith the scope applied, or do a cheap prefix test ofthe child's
ContainedPath + "/"against each glob's literal prefix. If it is an ancestor, includeit as a navigation-only node (
has_children=true) with its attributes stripped.Document the semantics on
IGalaxyBrowseScopeProvider. Add a test that browses from the root undera deep scope glob.
Resolution
Unresolved.
Fixed on main
4140509(GalaxyRepository-002 → Resolved): ancestors of an allowed object appear as navigation-only nodes (attributes stripped, has-children set); only the path to the allowed object is listed, so siblings stay hidden; ancestors appear only when an allowed descendant also passes the request's filters. Consumer behaviour change (mxaccessgw, HistorianGateway): a scoped DiscoverHierarchy now also returns those ancestors, counted by new NavigationAncestorCount; WatchDeployEvents subtracts it so its counts still cover allowed objects only. Rules documented on IGalaxyBrowseScopeProvider. Ships in GalaxyRepository 0.2.1 (unpublished). Evidence: Overview 195/195, Theme 65/65, GalaxyRepository 74/74; each regression test failed before its fix; code-reviews --check consistent.