Skip to content

eBPF-based security platform

tools/xtop: show who enrolled a node's key

John Fastabendb72a85762e5a
diff --git a/Documentation/operate/backend/xtop.rst b/Documentation/operate/backend/xtop.rst
index ee8c0e72..3f4f9923 100644
--- a/Documentation/operate/backend/xtop.rst
+++ b/Documentation/operate/backend/xtop.rst
@@ -116,7 +116,10 @@ The summary line gives the health of the nodes shown: the percent of
them ``healthy``, so 100% when every node is healthy and 0% when none
is. A stale node counts against it like an unhealthy one.
-Enter on a node shows its host name, key, labels with the name each was
+Enter on a node shows its host name, key, the builder that enrolled the
+key, when, and the endorsement key's name it gave, from
+``shirudo.enrollments`` (:doc:`enroll-put`), or ``by hand`` for a key
+enrolled without one, labels with the name each was
put under, ``ak_name``, ``node_id`` or ``config_root``, a line per
conflict with the values it overrode, what its record says it runs, and
the seven lines of its ``log``, a failed one in red; Esc returns. ``/``
diff --git a/tools/backend/test/xtop-nodes.expected b/tools/backend/test/xtop-nodes.expected
index 9b4f3500..423e8a11 100644
--- a/tools/backend/test/xtop-nodes.expected
+++ b/tools/backend/test/xtop-nodes.expected
@@ -1,8 +1,8 @@
-node_id ak_name host_name status trust failed_check generation last_seq head_seq loaded kernel_release version_id image_id image_version shields_applied shields_pending shields_idle exposed unknown labels label_sources label_conflicts log seen updated
-String String String String String UInt8 Nullable(UInt64) Nullable(UInt64) Nullable(UInt64) UInt64 LowCardinality(String) String Nullable(String) Nullable(String) UInt64 UInt64 UInt64 UInt64 UInt64 Map(String, String) Map(String, String) Array(Tuple(String, String, String, Array(Tuple(UInt8, String, String)))) Array(String) UInt8 UInt8
-node-a 000b23602ab98bfb edge-01 healthy untrusted 0 3 3 4 1 7.4.2 d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f fleet-os 2026.11.1 1 1 0 0 0 {'image':'base','role':'edge','site':'fra'} {'image':'config_root','role':'node_id','site':'node_id'} [('role','edge','node_id',[(2,'node_id','edge'),(1,'config_root','lab')])] ['1 signed: pass, untrusted, 0 rejected in the last hour','2 fresh: pass, last record N s ago','3 reported: pass, verdict ok, cond 0x1555, flags 0, tamper +0, build d6d918ad','4 chain: pass, root 15452248','5 head: behind, seq 3 of 4, generation 3','6 set: pass, 1 loaded','7 peers: pass, 2 in group'] 1 1
-node-b 000b9d72e08380a1 core-01 healthy untrusted 0 3 3 4 0 7.4.2 d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f fleet-os 2026.11.1 0 1 1 1 0 {'role':'core'} {'role':'ak_name'} [] ['1 signed: pass, untrusted, 0 rejected in the last hour','2 fresh: pass, last record N s ago','3 reported: pass, verdict ok, cond 0x1555, flags 0, tamper +0, build d6d918ad','4 chain: pass, root 00000000','5 head: behind, seq 3 of 4, generation 3','6 set: pass, 0 loaded','7 peers: pass, 2 in group'] 1 1
-node-c 000b0c lab-01 healthy untrusted 0 \N \N \N 0 7.5.1 d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f \N \N 0 0 0 0 1 {} {} [] ['1 signed: pass, untrusted, 0 rejected in the last hour','2 fresh: pass, last record N s ago','3 reported: pass, verdict ok, cond 0x1555, flags 0, tamper +0, build d6d918ad','4 chain: no tree','5 head: no tree','6 set: no tree','7 peers: no tree'] 1 1
-node-d 000b0d edge-02 unhealthy untrusted 3 3 3 4 1 7.4.2 d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f fleet-os 2026.11.1 1 1 0 0 0 {'image':'base','role':'edge','site':'ams'} {'image':'config_root','role':'node_id','site':'node_id'} [('role','edge','node_id',[(2,'node_id','edge'),(1,'config_root','lab')])] ['1 signed: pass, untrusted, 0 rejected in the last hour','2 fresh: pass, last record N s ago','3 reported: FAIL, verdict degraded, cond 0x1555, flags 0, tamper +0, build d6d918ad','4 chain: pass, root 15452248','5 head: behind, seq 3 of 4, generation 3','6 set: pass, 1 loaded','7 peers: pass, 2 in group'] 1 1
-node-e 000b0e core-02 stale untrusted 2 3 3 4 0 7.4.2 d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f fleet-os 2026.11.1 0 1 1 1 0 {} {} [] ['1 signed: pass, untrusted, 0 rejected in the last hour','2 fresh: FAIL, last record N s ago','3 reported: pass, verdict ok, cond 0x1555, flags 0, tamper +0, build d6d918ad','4 chain: pass, root 00000000','5 head: behind, seq 3 of 4, generation 3','6 set: pass, 0 loaded','7 peers: pass, 2 in group'] 1 1
+node_id ak_name host_name status trust failed_check generation last_seq head_seq loaded kernel_release version_id image_id image_version shields_applied shields_pending shields_idle exposed unknown labels label_sources label_conflicts enroll_ek_name enroll_source enrolled_ms log seen updated
+String String String String String UInt8 Nullable(UInt64) Nullable(UInt64) Nullable(UInt64) UInt64 LowCardinality(String) String Nullable(String) Nullable(String) UInt64 UInt64 UInt64 UInt64 UInt64 Map(String, String) Map(String, String) Array(Tuple(String, String, String, Array(Tuple(UInt8, String, String)))) String String Int64 Array(String) UInt8 UInt8
+node-a 000b23602ab98bfb edge-01 healthy untrusted 0 3 3 4 1 7.4.2 d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f fleet-os 2026.11.1 1 1 0 0 0 {'image':'base','role':'edge','site':'fra'} {'image':'config_root','role':'node_id','site':'node_id'} [('role','edge','node_id',[(2,'node_id','edge'),(1,'config_root','lab')])] 0 ['1 signed: pass, untrusted, 0 rejected in the last hour','2 fresh: pass, last record N s ago','3 reported: pass, verdict ok, cond 0x1555, flags 0, tamper +0, build d6d918ad','4 chain: pass, root 15452248','5 head: behind, seq 3 of 4, generation 3','6 set: pass, 1 loaded','7 peers: pass, 2 in group'] 1 1
+node-b 000b9d72e08380a1 core-01 healthy enrolled 0 3 3 4 0 7.4.2 d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f fleet-os 2026.11.1 0 1 1 1 0 {'role':'core'} {'role':'ak_name'} [] 000beeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee vm-host-1 1793527200000 ['1 signed: pass, enrolled, 0 rejected in the last hour','2 fresh: pass, last record N s ago','3 reported: pass, verdict ok, cond 0x1555, flags 0, tamper +0, build d6d918ad','4 chain: pass, root 00000000','5 head: behind, seq 3 of 4, generation 3','6 set: pass, 0 loaded','7 peers: pass, 2 in group'] 1 1
+node-c 000b0c lab-01 healthy untrusted 0 \N \N \N 0 7.5.1 d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f \N \N 0 0 0 0 1 {} {} [] 0 ['1 signed: pass, untrusted, 0 rejected in the last hour','2 fresh: pass, last record N s ago','3 reported: pass, verdict ok, cond 0x1555, flags 0, tamper +0, build d6d918ad','4 chain: no tree','5 head: no tree','6 set: no tree','7 peers: no tree'] 1 1
+node-d 000b0d edge-02 unhealthy untrusted 3 3 3 4 1 7.4.2 d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f fleet-os 2026.11.1 1 1 0 0 0 {'image':'base','role':'edge','site':'ams'} {'image':'config_root','role':'node_id','site':'node_id'} [('role','edge','node_id',[(2,'node_id','edge'),(1,'config_root','lab')])] 0 ['1 signed: pass, untrusted, 0 rejected in the last hour','2 fresh: pass, last record N s ago','3 reported: FAIL, verdict degraded, cond 0x1555, flags 0, tamper +0, build d6d918ad','4 chain: pass, root 15452248','5 head: behind, seq 3 of 4, generation 3','6 set: pass, 1 loaded','7 peers: pass, 2 in group'] 1 1
+node-e 000b0e core-02 stale untrusted 2 3 3 4 0 7.4.2 d6d918ad22ff597579e6678bef75adca84d30f9661e0b7bbdbf534eebc138c1f fleet-os 2026.11.1 0 1 1 1 0 {} {} [] 0 ['1 signed: pass, untrusted, 0 rejected in the last hour','2 fresh: FAIL, last record N s ago','3 reported: pass, verdict ok, cond 0x1555, flags 0, tamper +0, build d6d918ad','4 chain: pass, root 00000000','5 head: behind, seq 3 of 4, generation 3','6 set: pass, 0 loaded','7 peers: pass, 2 in group'] 1 1
nodes 5
diff --git a/tools/backend/test/xtop-nodes.setup.sql b/tools/backend/test/xtop-nodes.setup.sql
index 76fc3e31..3ac57bfa 100644
--- a/tools/backend/test/xtop-nodes.setup.sql
+++ b/tools/backend/test/xtop-nodes.setup.sql
@@ -87,6 +87,12 @@ SELECT record.1, argMinState(record.2, toDateTime64(0, 3))
FROM (SELECT arrayJoin([('000b23602ab98bfb', 'node-a'), ('000b9d72e08380a1', 'node-b'), ('000b0c', 'node-c'), ('000b0d', 'node-d'), ('000b0e', 'node-e')]) AS record)
GROUP BY record.1;
+-- node-b's key, enrolled from its builder's records.
+INSERT INTO shirudo.nodes (ak_name, trust) VALUES ('000b9d72e08380a1', 'enrolled');
+INSERT INTO shirudo.enrollments (ak_name, ek_name, node_id, source, put_at)
+VALUES ('000b9d72e08380a1', concat('000b', repeat('e', 64)), 'node-b', 'vm-host-1',
+ toDateTime64('2026-11-01 10:00:00', 3, 'UTC'));
+
SYSTEM REFRESH VIEW shirudo.node_ops_mv;
SYSTEM WAIT VIEW shirudo.node_ops_mv;
SYSTEM REFRESH VIEW shirudo.node_status_mv;
diff --git a/tools/xtop/sql/nodes.sql b/tools/xtop/sql/nodes.sql
index 153dc0fd..4522e078 100644
--- a/tools/xtop/sql/nodes.sql
+++ b/tools/xtop/sql/nodes.sql
@@ -4,8 +4,8 @@
-- One row per node for the nodes view of tools/xtop: the outcome of the
-- checks from node_status, what the newest record says it runs from
-- latest, the labels the operator gave it from node_labels with the keys
--- whose sets disagree from label_conflicts, and per node the counts of
--- node_vulns. Times are epoch milliseconds, so that no
+-- whose sets disagree from label_conflicts, the builder that enrolled
+-- its key from enrollments, and per node the counts of node_vulns. Times are epoch milliseconds, so that no
-- client reads them in the server's time zone.
WITH
@@ -52,10 +52,14 @@ SELECT
v.unknown AS unknown,
lb.labels AS labels,
lb.sources AS label_sources,
- lc.conflicts AS label_conflicts
+ lc.conflicts AS label_conflicts,
+ e.ek_name AS enroll_ek_name,
+ e.source AS enroll_source,
+ toUnixTimestamp64Milli(e.put_at) AS enrolled_ms
FROM shirudo.node_status AS s
LEFT JOIN shirudo.latest AS l ON l.ak_name = s.ak_name
LEFT JOIN vulns AS v ON v.ak_name = s.ak_name
LEFT JOIN shirudo.node_labels AS lb ON lb.ak_name = s.ak_name
LEFT JOIN conflicts AS lc ON lc.ak_name = s.ak_name
+LEFT JOIN (SELECT * FROM shirudo.enrollments FINAL) AS e ON e.ak_name = s.ak_name
ORDER BY node_id, ak_name
diff --git a/tools/xtop/src/components/NodeDetail.tsx b/tools/xtop/src/components/NodeDetail.tsx
index 938cd6af..f50e94f3 100644
--- a/tools/xtop/src/components/NodeDetail.tsx
+++ b/tools/xtop/src/components/NodeDetail.tsx
@@ -5,6 +5,7 @@
import type { ReactNode } from "react";
import { Box, Text, useInput } from "ink";
+import { ago } from "../lib/format.ts";
import { imageLabel, type FleetNode } from "../lib/fleet.ts";
import { STATUS_STYLE } from "./style.tsx";
@@ -61,6 +62,13 @@ export function NodeDetail({ node, height, active, onClose }: Props) {
</Text>
<Field name="host">{node.hostName}</Field>
<Field name="key">{node.akName}</Field>
+ <Field name="enrolled">
+ {node.enrollment
+ ? `by ${node.enrollment.source}, ${ago(node.enrollment.at)} ago, ek ${node.enrollment.ekName ?? "not given"}`
+ : node.trust === "enrolled"
+ ? "by hand, no builder's record"
+ : "no"}
+ </Field>
<Field name="labels">
{Object.keys(node.labels).length === 0 && "none put"}
{Object.keys(node.labels)
diff --git a/tools/xtop/src/lib/backend.ts b/tools/xtop/src/lib/backend.ts
index 43ea5445..8497a106 100644
--- a/tools/xtop/src/lib/backend.ts
+++ b/tools/xtop/src/lib/backend.ts
@@ -71,6 +71,10 @@ export type NodeRow = {
label_sources: Record<string, string>;
/** (key, value, by, [(rank, by, value)]) */
label_conflicts: [string, string, string, [number, string, string][]][];
+ enroll_ek_name: string;
+ enroll_source: string;
+ /** 0 for a key with no row in shirudo.enrollments. */
+ enrolled_ms: number;
};
const labelSource = (by: string) => oneOf<LabelSource>(LABEL_SOURCES, by, "label source");
@@ -114,6 +118,9 @@ export function toFleetNode(r: NodeRow): FleetNode {
Object.entries(r.label_sources).map(([key, by]) => [key, labelSource(by)]),
),
labelConflicts: r.label_conflicts.map(toLabelConflict),
+ enrollment: r.enrolled_ms
+ ? { ekName: r.enroll_ek_name || null, source: r.enroll_source, at: new Date(r.enrolled_ms) }
+ : null,
};
}
diff --git a/tools/xtop/src/lib/fleet.ts b/tools/xtop/src/lib/fleet.ts
index 84ecc159..75aef033 100644
--- a/tools/xtop/src/lib/fleet.ts
+++ b/tools/xtop/src/lib/fleet.ts
@@ -19,6 +19,14 @@ export type LabelConflict = {
given: { by: LabelSource; value: string }[];
};
+/** The builder's record of the node's key, from jobs/enroll-put. */
+export type Enrollment = {
+ /** The endorsement key's name the builder saw, null when it gave none. */
+ ekName: string | null;
+ source: string;
+ at: Date;
+};
+
export const STATUS_RANK: Record<NodeStatus, number> = { unhealthy: 0, stale: 1, healthy: 2 };
export const STATUSES = ["unhealthy", "stale", "healthy"] as const;
export const TRUSTS = ["untrusted", "enrolled"] as const;
@@ -63,6 +71,8 @@ export type FleetNode = {
/** Per key, the name its value was put under. */
labelSources: Record<string, LabelSource>;
labelConflicts: LabelConflict[];
+ /** null for a key no builder enrolled, enrolled by hand or untrusted. */
+ enrollment: Enrollment | null;
};
export type FleetReport = {
diff --git a/tools/xtop/test/fleet.test.ts b/tools/xtop/test/fleet.test.ts
index d4733d24..619846da 100644
--- a/tools/xtop/test/fleet.test.ts
+++ b/tools/xtop/test/fleet.test.ts
@@ -48,6 +48,9 @@ function row(over: Partial<NodeRow>): NodeRow {
labels: { role: "edge", site: "fra" },
label_sources: { role: "node_id", site: "node_id" },
label_conflicts: [],
+ enroll_ek_name: "",
+ enroll_source: "",
+ enrolled_ms: 0,
...over,
};
}
@@ -155,6 +158,16 @@ describe("toFleetNode", () => {
]);
});
+ test("keeps the builder's record of an enrolled key", () => {
+ const ek = `000b${"e".repeat(64)}`;
+ const n = toFleetNode(
+ row({ trust: "enrolled", enroll_ek_name: ek, enroll_source: "vm-host-1", enrolled_ms: 1_793_527_200_000 }),
+ );
+ expect(n.enrollment).toEqual({ ekName: ek, source: "vm-host-1", at: new Date(1_793_527_200_000) });
+ expect(toFleetNode(row({ enroll_source: "vm-host-1", enrolled_ms: 1 })).enrollment?.ekName).toBeNull();
+ expect(toFleetNode(ROWS[0]!).enrollment).toBeNull();
+ });
+
test("refuses a status the view does not know", () => {
expect(() => toFleetNode(row({ status: "degraded" }))).toThrow(/unknown status/);
expect(() => toFleetNode(row({ trust: "maybe" }))).toThrow(/unknown trust/);