feat(acl): Introduction of reachability map - #604
Draft
bufferpurge wants to merge 2 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relates to #603.
A read-only visual view of what the ACL policy actually permits: a map of machines with a line per permitted flow. A map is created consisting of nodes and lines are drawn between them in a "constellation" where lines or nodes can be filtered accordingly.
New —
app/utils/acl/(~930 lines, no server or React imports, so it runs in a loader or the browser)parse.ts/hujson.ts— HuJSON → typed policyresolve.ts— alias expansion:tag:,group:(recursive, cycle-guarded),autogroup:member/tagged/internet/self, hosts, IPv4 CIDRsevaluate.ts—evaluatePolicy(policy, nodes)→ nodes, edges, per-edge rules, warningslocate.ts— source offsets, for the jump-to-rule linksNew —
map.client.tsxChanged (4 files)
acl-loader.ts— fetches machines for the map, gated onread_machines, in a try/catch so a failure degrades the map rather than the editoroverview.tsx— the new tab; tabs become URL-controlled so jump-to-rule is a real history entry; Save/Discard hidden on the map tab onlycm.client.tsx— optional highlight prop so the editor can reveal a rule (selection and scroll only, never a document change)package.json— adds@xyflow/reactNotes
useSearchParams(GET). Nothing here can reach the ACL write path.Testing — 44 new unit tests (261 total, all passing).
pnpm typecheck,lintandbuildclean.What the map does
acls[]rule against the live machine list — tags, groups (recursive),autogroup:member/tagged/internet/self, host aliases, IPv4 CIDRs — into a graph of permitted flows. Internet and off-mesh subnets appear as pseudo-nodes, subnets carrying the routers that serve them.I have tested this against my own headscale instance - which means that more testing would be highly appreciated/required with other constellations of ACLs. I'm not sure if the "Preview rules" placeholder was supposed to be something like this. here are some screenshots:
Main overview:

Pressing one machine shows the relationship it has to other machines, visually represented by both direction and color according to legend:

Multiple machines can be pressed (filtered) to see whether they have any active ACL rules to each other:

Inbound filter used when pressing one machine to see which machines can reach it:

Machine inspect mode - for a more focused view on one machine:

Checking outbound flows in the inspect mode:

Multiple nodes selected/added to filter with the "Hide machines outside of the filter" toggle active:

When the magnifying glass on a rule on the right-hand side is clicked, it directs to the related rule in the ACL editor:

Representation of the filter dropdown menu:
