@vigilbase/cli
Version:
Vigilbase CLI — security scanners, agent tools, and Vigilbase One from the terminal.
119 lines (118 loc) • 5.49 kB
TypeScript
import { type Styles, type Symbols } from './tui.js';
export type CheckupCounts = {
total: number | null;
passed: number | null;
warnings: number | null;
failed: number | null;
skipped: number | null;
};
/** One check ID's failing or warning instances, across the account and its zones. */
export type CheckupFinding = {
name: string;
/** The server's label (`critical`, `high`, …), as sent. */
severity: string | null;
/** `failed` (fail or error) or `warning`; null for a legacy report's issue, which has no status. */
status: 'failed' | 'warning' | null;
/** Distinct zones with this finding. */
zones: number;
/** An account-level check. */
account: boolean;
/** The first line of the server's recommendation. */
recommendation: string | null;
};
export type CheckupZoneRow = {
name: string;
plan: string | null;
status: string | null;
grade: string | null;
score: number | null;
passed: number | null;
warnings: number | null;
failed: number | null;
/** A legacy report's issue count (it has no pass/warning/fail summary). */
issues: number | null;
};
export type CheckupReportView = {
accountName: string | null;
zoneCount: number | null;
scannedZones: number | null;
grade: string | null;
score: number | null;
summary: CheckupCounts | null;
zones: CheckupZoneRow[];
/** Ordered: failed before warnings, then by the server's severity, then the widest. */
findings: CheckupFinding[];
/** Premium checks the locked projection holds back. */
lockedPremiumCount: number;
/** The results page, only when it is an https://vigilbase.com URL. */
shareableUrl: string | null;
scannedAt: string | null;
};
/**
* The view of a checkup result (`CheckupResult`, its locked projection, or a
* legacy One report), or null when `value` is not an object. Malformed parts
* are left out rather than failing the whole view.
*/
export declare function readCheckupReport(value: unknown): CheckupReportView | null;
/** How the lines are drawn: styles (identity without colour), symbols (ASCII on legacy consoles) and the width to fit, if any. */
export type ReportPalette = {
style: Styles;
symbols: Symbols;
/** Colours on: the bar shows warnings and failed checks in their colours. */
color: boolean;
/** Terminal columns; null for plain output (pipes, files), which is never cut. */
columns: number | null;
};
export declare function joinParts(palette: ReportPalette, parts: readonly string[]): string;
/** `account-wide`, `on 2 domains`, or '' (a legacy issue without a zone list). */
export declare function findingScope(finding: CheckupFinding): string;
/** A grade in the colour of its band, bold: A green, B and C yellow, D and F red (the server's letter, coloured). */
export declare function styleGrade(style: Styles, grade: string): string;
/**
* Cells per segment for a stacked bar: proportional, summing to `width`, and
* at least one cell for every non-zero count while the width allows.
*/
export declare function segmentWidths(values: readonly number[], width: number): number[];
/**
* `██████░░`: passed, then warnings and failed (yellow and red with colour),
* then checks with any other status. Without colour, everything but passed is
* the empty cell, so the bar still reads as the share that passed.
*/
export declare function checksBar(palette: ReportPalette, summary: CheckupCounts, width: number): string | null;
/**
* Finding lines, aligned: `✗ critical Account MFA Enforcement account-wide`.
* `indent` prefixes every line; with `recommendations`, the first line of the
* recommendation follows each finding, dim, under its name.
*/
export declare function findingLines(palette: ReportPalette, findings: readonly CheckupFinding[], options: {
indent: string;
recommendations?: boolean;
}): string[];
/** `+87 more checks in the full report` */
export declare function lockedTeaser(palette: ReportPalette, locked: number): string | null;
/** Findings shown at the end of a local checkup. */
export declare const LOCAL_FINDINGS_SHOWN: 5;
/**
* The result card of the terminal UI, under `└ ✓ Done. …`: the free checks as
* a bar, the top findings (failed, then warnings; names and zone counts, never
* zone names) and how many premium checks the full report adds. Lines are
* indented to the end of the timeline and fit the width.
*/
export declare function localResultCard(palette: ReportPalette, view: CheckupReportView): string[];
/**
* The same, as plain lines appended after the plain result lines:
* `Top findings:`, one indented line each, then the premium teaser. Empty when
* there is nothing to add.
*/
export declare function localResultPlainLines(view: CheckupReportView, palette: ReportPalette): string[];
/** Priorities shown by `cf checkup result` and `cf checkup`. */
export declare const PRIORITIES_SHOWN: 8;
/** Domain rows shown before `… N more domains`. */
export declare const ZONES_SHOWN: 15;
/**
* The body of `cf checkup result` and `cf checkup` in text mode, after their
* `checkup` and `grade` lines: the account, the counts (a bar on a terminal),
* the domains, the top priorities with the first line of each recommendation,
* the premium teaser of a locked result and the full report link.
*/
export declare function checkupReportLines(palette: ReportPalette, view: CheckupReportView): string[];