eBPF-based security platform
tools/xtop: clip a detail pane taller than the view
John Fastabend6cb66278c4b5
diff --git a/tools/xtop/src/components/FindingDetail.tsx b/tools/xtop/src/components/FindingDetail.tsxindex 1bc52727..2567f577 100644--- a/tools/xtop/src/components/FindingDetail.tsx+++ b/tools/xtop/src/components/FindingDetail.tsx@@ -61,45 +61,48 @@ export function FindingDetail({ finding: f, height, active, onClose }: Props) {const shown = f.nodes.slice(0, room);return (<Box flexDirection="column" height={height} overflow="hidden">- <Text>- <Text bold>{f.vulnId}</Text> <SeverityText severity={f.severity} />- <Text color={style.color}> {style.label}</Text>- </Text>- <Field name="package">- {f.source === "kernel" ? "the kernel" : f.package} {f.installed.join(", ")}- {f.fixed ? `, fixed in ${f.fixed}` : ", no fixed version yet"}- </Field>- <Field name="source">{f.source === "kernel" ? "kernel_vulns, by kernel release" : "the image's SBOM, by its scan"}</Field>- <Field name="shield">{f.upatchId || "no upatch is linked to the advisory"}</Field>- <Field name="nodes">- {f.affected} of {f.total} affected · <Text color="green">{f.shielded} shielded</Text> · {f.pending} coming ·{" "}- {f.idle} not taking it · {f.withdrawn} withdrawn · {f.unshielded} without one- </Field>- {f.stale && <Text color="red">an image's newest scan is older than sbom_stale_seconds</Text>}- <Box marginTop={1} flexDirection="column">- <Text dimColor>- {"NODE".padEnd(14)}- {"EXPOSURE".padEnd(22)}- {"IMAGE".padEnd(22)}- {"INSTALLED".padEnd(12)}- {"BINDING".padEnd(14)}STATUS+ {/* Lines keep their height and the pane clips them, rather than squeeze them onto each other. */}+ <Box flexDirection="column" flexShrink={0}>+ <Text>+ <Text bold>{f.vulnId}</Text> <SeverityText severity={f.severity} />+ <Text color={style.color}> {style.label}</Text></Text>- {shown.map((n) => {- const e = EXPOSURE_TEXT[n.exposure];- return (- <Text key={n.akName} wrap="truncate-end">- <Text bold>{n.name.padEnd(14)}</Text>- <Text color={e.color}>{e.text.padEnd(22)}</Text>- <Text color="cyan">{`${n.imageId} ${n.imageVersion}`.trim().padEnd(22)}</Text>- {n.installed.padEnd(12)}- <Text dimColor>{n.binding.padEnd(14)}</Text>- {n.status}- </Text>- );- })}- {f.nodes.length > shown.length && <Text dimColor>and {f.nodes.length - shown.length} more</Text>}+ <Field name="package">+ {f.source === "kernel" ? "the kernel" : f.package} {f.installed.join(", ")}+ {f.fixed ? `, fixed in ${f.fixed}` : ", no fixed version yet"}+ </Field>+ <Field name="source">{f.source === "kernel" ? "kernel_vulns, by kernel release" : "the image's SBOM, by its scan"}</Field>+ <Field name="shield">{f.upatchId || "no upatch is linked to the advisory"}</Field>+ <Field name="nodes">+ {f.affected} of {f.total} affected · <Text color="green">{f.shielded} shielded</Text> · {f.pending} coming ·{" "}+ {f.idle} not taking it · {f.withdrawn} withdrawn · {f.unshielded} without one+ </Field>+ {f.stale && <Text color="red">an image's newest scan is older than sbom_stale_seconds</Text>}+ <Box marginTop={1} flexDirection="column">+ <Text dimColor>+ {"NODE".padEnd(14)}+ {"EXPOSURE".padEnd(22)}+ {"IMAGE".padEnd(22)}+ {"INSTALLED".padEnd(12)}+ {"BINDING".padEnd(14)}STATUS+ </Text>+ {shown.map((n) => {+ const e = EXPOSURE_TEXT[n.exposure];+ return (+ <Text key={n.akName} wrap="truncate-end">+ <Text bold>{n.name.padEnd(14)}</Text>+ <Text color={e.color}>{e.text.padEnd(22)}</Text>+ <Text color="cyan">{`${n.imageId} ${n.imageVersion}`.trim().padEnd(22)}</Text>+ {n.installed.padEnd(12)}+ <Text dimColor>{n.binding.padEnd(14)}</Text>+ {n.status}+ </Text>+ );+ })}+ {f.nodes.length > shown.length && <Text dimColor>and {f.nodes.length - shown.length} more</Text>}+ </Box>+ <Text dimColor>esc back</Text></Box>- <Text dimColor>esc back</Text></Box>);}diff --git a/tools/xtop/src/components/NodeDetail.tsx b/tools/xtop/src/components/NodeDetail.tsxindex ac5dd4a9..1dd60b7d 100644--- a/tools/xtop/src/components/NodeDetail.tsx+++ b/tools/xtop/src/components/NodeDetail.tsx@@ -49,35 +49,38 @@ export function NodeDetail({ node, height, active, onClose }: Props) {const t = node.tree;return (<Box flexDirection="column" height={height} overflow="hidden">- <Text>- <Text bold>{node.name}</Text>- <Text color={style.color}>- {" "}- {style.icon} {node.status}- </Text>- <Text color={node.trust === "enrolled" ? "green" : "yellow"}> · {node.trust}</Text>- </Text>- <Field name="host">{node.hostName}</Field>- <Field name="key">{node.akName}</Field>- <Field name="image">{imageLabel(node.imageId, node.imageVersion)}</Field>- <Field name="kernel">{node.kernel}</Field>- <Field name="build">{node.version}</Field>- <Field name="tree">- {t.lastSeq === null- ? "follows no tree"- : `seq ${t.lastSeq} of ${t.headSeq ?? "?"}, generation ${t.generation ?? "?"}, ${node.loaded} loaded`}- </Field>- <Field name="seen">{node.lastSeen.toLocaleString()}</Field>- <Box marginTop={1} flexDirection="column">- <Text dimColor>checks</Text>- {node.log.map((line, i) => (- <Text key={i} color={checkColor(line)} wrap="truncate-end">- {line}+ {/* Lines keep their height and the pane clips them, rather than squeeze them onto each other. */}+ <Box flexDirection="column" flexShrink={0}>+ <Text>+ <Text bold>{node.name}</Text>+ <Text color={style.color}>+ {" "}+ {style.icon} {node.status}</Text>- ))}- </Box>- <Box marginTop={1}>- <Text dimColor>esc back</Text>+ <Text color={node.trust === "enrolled" ? "green" : "yellow"}> · {node.trust}</Text>+ </Text>+ <Field name="host">{node.hostName}</Field>+ <Field name="key">{node.akName}</Field>+ <Field name="image">{imageLabel(node.imageId, node.imageVersion)}</Field>+ <Field name="kernel">{node.kernel}</Field>+ <Field name="build">{node.version}</Field>+ <Field name="tree">+ {t.lastSeq === null+ ? "follows no tree"+ : `seq ${t.lastSeq} of ${t.headSeq ?? "?"}, generation ${t.generation ?? "?"}, ${node.loaded} loaded`}+ </Field>+ <Field name="seen">{node.lastSeen.toLocaleString()}</Field>+ <Box marginTop={1} flexDirection="column">+ <Text dimColor>checks</Text>+ {node.log.map((line, i) => (+ <Text key={i} color={checkColor(line)} wrap="truncate-end">+ {line}+ </Text>+ ))}+ </Box>+ <Box marginTop={1}>+ <Text dimColor>esc back</Text>+ </Box></Box></Box>);diff --git a/tools/xtop/src/components/ShieldDetail.tsx b/tools/xtop/src/components/ShieldDetail.tsxindex 1911072c..93dacf54 100644--- a/tools/xtop/src/components/ShieldDetail.tsx+++ b/tools/xtop/src/components/ShieldDetail.tsx@@ -46,47 +46,50 @@ export function ShieldDetail({ shield: s, height, active, onClose }: Props) {const r = s.rollout;return (<Box flexDirection="column" height={height} overflow="hidden">- <Text>- <Text bold>{s.id}</Text>- <Text color={SHIELD_STATUS_COLOR[s.status]}> {s.status}</Text>- <Text dimColor> · tree {s.treeId}</Text>- </Text>- <Field name="newest op">- {s.op} at #{s.seq}- {s.ops > 1 ? `, ${s.ops} operations in all` : ""}- {s.op === "delete" && s.addSeq ? `, last added at #${s.addSeq}` : ""}- </Field>- <Field name="published">{s.publishedAt ? s.publishedAt.toLocaleString() : "—"}</Field>- <Field name="repository">{s.repository}</Field>- <Field name="manifest">{s.manifestDigest}</Field>- <Field name="selector">{s.selector}</Field>- <Field name="rollout">- <Text color="green">{r.applied} applied</Text>- {" · "}- <Text color={r.pending ? "yellow" : undefined}>{r.pending} not reached</Text>- {" · "}- {r.notSelected} left out by the selector- {" · "}- <Text color={r.noTarget ? "red" : undefined}>{r.noTarget} module not loaded</Text>- <Text dimColor> · of {r.nodes} nodes following the tree</Text>- </Field>- <Field name="images">{s.images.length ? s.images.join(", ") : "—"}</Field>- <Box marginTop={1} flexDirection="column">- <Text dimColor>fixes{s.op === "delete" && s.addSeq ? ` (the add at #${s.addSeq})` : ""}</Text>- {s.advisories.length === 0 && <Text dimColor>no advisory linked</Text>}- {s.advisories.map((a) => (- <Text key={a.id} wrap="truncate-end">- <Text bold>{a.id}</Text> <SeverityText severity={a.severity} />{" "}- <Text color={a.source === "kernel" ? "magenta" : "cyan"}>{a.source === "kernel" ? "kernel" : a.package || "?"}</Text>- <Text dimColor> · </Text>- <Text color="green">{a.shielded} shielded</Text>- <Text dimColor> · </Text>- <Text color={a.exposed ? "yellow" : undefined}>{a.exposed} not shielded</Text>- </Text>- ))}- </Box>- <Box marginTop={1}>- <Text dimColor>esc back</Text>+ {/* Lines keep their height and the pane clips them, rather than squeeze them onto each other. */}+ <Box flexDirection="column" flexShrink={0}>+ <Text>+ <Text bold>{s.id}</Text>+ <Text color={SHIELD_STATUS_COLOR[s.status]}> {s.status}</Text>+ <Text dimColor> · tree {s.treeId}</Text>+ </Text>+ <Field name="newest op">+ {s.op} at #{s.seq}+ {s.ops > 1 ? `, ${s.ops} operations in all` : ""}+ {s.op === "delete" && s.addSeq ? `, last added at #${s.addSeq}` : ""}+ </Field>+ <Field name="published">{s.publishedAt ? s.publishedAt.toLocaleString() : "—"}</Field>+ <Field name="repository">{s.repository}</Field>+ <Field name="manifest">{s.manifestDigest}</Field>+ <Field name="selector">{s.selector}</Field>+ <Field name="rollout">+ <Text color="green">{r.applied} applied</Text>+ {" · "}+ <Text color={r.pending ? "yellow" : undefined}>{r.pending} not reached</Text>+ {" · "}+ {r.notSelected} left out by the selector+ {" · "}+ <Text color={r.noTarget ? "red" : undefined}>{r.noTarget} module not loaded</Text>+ <Text dimColor> · of {r.nodes} nodes following the tree</Text>+ </Field>+ <Field name="images">{s.images.length ? s.images.join(", ") : "—"}</Field>+ <Box marginTop={1} flexDirection="column">+ <Text dimColor>fixes{s.op === "delete" && s.addSeq ? ` (the add at #${s.addSeq})` : ""}</Text>+ {s.advisories.length === 0 && <Text dimColor>no advisory linked</Text>}+ {s.advisories.map((a) => (+ <Text key={a.id} wrap="truncate-end">+ <Text bold>{a.id}</Text> <SeverityText severity={a.severity} />{" "}+ <Text color={a.source === "kernel" ? "magenta" : "cyan"}>{a.source === "kernel" ? "kernel" : a.package || "?"}</Text>+ <Text dimColor> · </Text>+ <Text color="green">{a.shielded} shielded</Text>+ <Text dimColor> · </Text>+ <Text color={a.exposed ? "yellow" : undefined}>{a.exposed} not shielded</Text>+ </Text>+ ))}+ </Box>+ <Box marginTop={1}>+ <Text dimColor>esc back</Text>+ </Box></Box></Box>);