@ejouan/lxray 0.0.0-stage → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,178 @@
1
+ // Types for @ejouan/lxray (LXRAY 1.2.0 report format).
2
+
3
+ export type ReportFormat = 'json' | 'html' | 'md' | 'txt';
4
+ export type Profile = 'quick' | 'standard' | 'full';
5
+ export type Severity = 'critical' | 'warning' | 'info' | 'ok';
6
+
7
+ export type PluginId =
8
+ | '00-system' | '05-raw' | '10-cpu-memory' | '20-storage' | '30-network' | '40-kernel' | '50-services'
9
+ | '60-packages' | '70-security' | '80-logs' | '85-databases' | '90-containers' | '95-appstack';
10
+ export type PluginAlias =
11
+ | 'system' | 'raw' | 'cpu_memory' | 'storage' | 'network' | 'kernel' | 'services' | 'packages'
12
+ | 'security' | 'logs' | 'databases' | 'containers' | 'applications'
13
+ | 'cpu' | 'memory' | 'storage_raid' | 'disks' | 'raid' | 'firewall' | 'appstack' | 'apps';
14
+ export type PluginName = PluginId | PluginAlias;
15
+
16
+ export interface Finding {
17
+ id: string;
18
+ title: string;
19
+ severity: Severity;
20
+ category: string;
21
+ detail: string;
22
+ evidence?: string;
23
+ fix?: string;
24
+ impact?: string;
25
+ [key: string]: unknown;
26
+ }
27
+
28
+ /** Parsed lxray-report.json */
29
+ export interface LxrayReport {
30
+ tool: string;
31
+ version: string;
32
+ generated: string;
33
+ host: { hostname?: string; fqdn?: string; ip?: string; os_id?: string; os_name?: string; kernel?: string; arch?: string; virt?: string; cpus?: number; mem_kb?: number; [k: string]: unknown };
34
+ manifest: Record<string, unknown>;
35
+ facts: { score?: number; grade?: string; verdict?: string; [k: string]: unknown };
36
+ findings: Finding[];
37
+ }
38
+
39
+ export interface Summary {
40
+ hostname: string | null;
41
+ os: string | null;
42
+ kernel: string | null;
43
+ lxrayVersion: string | null;
44
+ generated: string | null;
45
+ score: number | null;
46
+ grade: string | null;
47
+ verdict: string | null;
48
+ counts: Record<Severity, number>;
49
+ issues: Array<Pick<Finding, 'id' | 'severity' | 'category' | 'title' | 'detail' | 'fix' | 'impact'>>;
50
+ }
51
+
52
+ export interface AuditResult {
53
+ summary: Summary;
54
+ report: LxrayReport;
55
+ html?: string;
56
+ markdown?: string;
57
+ text?: string;
58
+ durationMs?: number;
59
+ privileged?: boolean;
60
+ /** collection was partial (not root, or a plugin failed): the report lists what was not evaluated */
61
+ partial?: boolean;
62
+ isRoot?: boolean;
63
+ warnings?: string[];
64
+ binary?: string;
65
+ outdir?: string;
66
+ snapshotDir?: string | null;
67
+ archivePath?: string | null;
68
+ reportDir?: string;
69
+ ageMinutes?: number;
70
+ }
71
+
72
+ export interface AuditOptions {
73
+ formats?: ReportFormat[] | string;
74
+ /** @deprecated use formats */
75
+ format?: ReportFormat;
76
+ profile?: Profile;
77
+ only?: PluginName[];
78
+ exclude?: PluginName[];
79
+ /** per-command timeout of the collector, seconds */
80
+ timeout?: number;
81
+ redactIps?: boolean;
82
+ noRedact?: boolean;
83
+ archive?: boolean;
84
+ keepArtifacts?: boolean;
85
+ outdir?: string;
86
+ privileged?: boolean;
87
+ wrapperPath?: string;
88
+ autoInstall?: boolean;
89
+ installOptions?: InstallOptions;
90
+ binaryPath?: string;
91
+ /** overall limit, milliseconds */
92
+ processTimeout?: number;
93
+ extraArgs?: string[];
94
+ /** receives LXRAY's progress lines while it runs (disables --quiet) */
95
+ onLog?: (line: string, stream: 'stdout' | 'stderr') => void;
96
+ }
97
+
98
+ export interface Environment {
99
+ platform: string;
100
+ supported: boolean;
101
+ installed: boolean;
102
+ binaryPath: string | null;
103
+ lxrayVersion: string | null;
104
+ pythonAvailable: boolean;
105
+ pythonVersion: string | null;
106
+ isRoot: boolean;
107
+ rootWrapperInstalled: boolean;
108
+ spoolReadable: boolean;
109
+ plugins: ReadonlyArray<{ id: PluginId; alias: string; title: string }>;
110
+ note: string;
111
+ }
112
+
113
+ export interface InstallOptions { installDir?: string; version?: string; verifyGpg?: boolean; expectedFingerprint?: string }
114
+
115
+ export interface RemoteTarget {
116
+ host: string;
117
+ user?: string;
118
+ port?: number;
119
+ identityFile?: string;
120
+ sshOptions?: string[];
121
+ acceptNewHostKeys?: boolean;
122
+ local?: boolean;
123
+ options?: AuditOptions & RemoteOptions;
124
+ }
125
+ export interface RemoteOptions {
126
+ lxrayPath?: string;
127
+ sshPath?: string;
128
+ /** run (default) | privileged (root wrapper via sudo) | latest (newest hourly root report) */
129
+ mode?: 'run' | 'privileged' | 'latest' | 'root';
130
+ spoolDir?: string;
131
+ }
132
+ export interface CheckRules { minScore?: number; warnScore?: number; maxCritical?: number; maxWarning?: number; ignore?: string[]; partialIsWarning?: boolean }
133
+ export interface CheckResult { status: 'ok' | 'warning' | 'critical'; exitCode: 0 | 1 | 2; message: string; reasons: string[]; score: number | null }
134
+ export interface Comparison { scoreBefore: number | null; scoreAfter: number | null; scoreDelta: number | null; newIssues: Finding[]; resolved: Finding[]; worse: Array<Finding & { previousSeverity: Severity }>; better: Array<Finding & { previousSeverity: Severity }>; persisting: Finding[] }
135
+ export interface DepsResult { platform: Record<string, string>; tools: Array<{ group: string; probe: string; ok: boolean; unlocks: string }>; missingPackages: string[]; installCommand: string | null }
136
+ export interface FleetEntry { host: string; ok: boolean; result?: AuditResult & { host: string }; error?: string; code?: string | null }
137
+
138
+ export function audit(options?: AuditOptions): Promise<AuditResult>;
139
+ export const run: typeof audit;
140
+ export function readLatest(options?: { spoolDir?: string; formats?: ReportFormat[] | string; maxAgeMinutes?: number }): Promise<AuditResult>;
141
+ export function requestRootAudit(options?: { profile?: Profile; formats?: ReportFormat[] | string; requestDir?: string; spoolDir?: string; waitMs?: number; pollMs?: number }): Promise<AuditResult>;
142
+ export function collect(options?: AuditOptions & { noTar?: boolean }): Promise<{ outdir: string; snapshotDir: string | null; archivePath: string | null; partial: boolean }>;
143
+ export function analyze(target: string, options?: { formats?: ReportFormat[] | string; outdir?: string; keepArtifacts?: boolean; binaryPath?: string; processTimeout?: number }): Promise<AuditResult>;
144
+ export function plugins(options?: { binaryPath?: string }): Promise<Array<{ id: string; alias: string | null; description: string }>>;
145
+ export function version(options?: { binaryPath?: string }): Promise<string>;
146
+ export function deps(options?: { install?: boolean; binaryPath?: string; processTimeout?: number; onLog?: AuditOptions['onLog'] }): Promise<DepsResult>;
147
+ export function evaluate(input: AuditResult | LxrayReport | Summary, rules?: CheckRules): CheckResult;
148
+ export function compare(previous: AuditResult | LxrayReport, current: AuditResult | LxrayReport): Comparison;
149
+ export function toPrometheus(input: AuditResult | LxrayReport | FleetEntry | Array<AuditResult | FleetEntry>, options?: { prefix?: string; labels?: Record<string, string> }): string;
150
+ export function saveReports(result: AuditResult, dir: string, options?: { prefix?: string }): Promise<string[]>;
151
+ export function remoteCollect(target: RemoteTarget, options?: AuditOptions & RemoteOptions & { saveTo?: string }): Promise<{ host: string; archive: Buffer; archiveName: string; savedTo?: string; partial: boolean }>;
152
+ export function checkEnvironment(options?: { binaryPath?: string; wrapperPath?: string; spoolDir?: string }): Promise<Environment>;
153
+ export function summarize(report: LxrayReport): Summary;
154
+ export function resolvePlugins(names?: PluginName[] | string): PluginId[];
155
+ export function install(options?: InstallOptions): Promise<{ binaryPath: string; version: string; installDir: string; gpgVerified: boolean }>;
156
+ export function remoteAudit(target: RemoteTarget, options?: AuditOptions & RemoteOptions): Promise<AuditResult & { host: string; mode: string; archive?: Buffer; archiveName?: string }>;
157
+ export function auditFleet(targets: RemoteTarget[], options?: AuditOptions & RemoteOptions & { concurrency?: number; onResult?: (entry: FleetEntry, index: number) => void }): Promise<FleetEntry[]>;
158
+ export function createAuditHandler(options: {
159
+ authorize: (req: any) => boolean | Promise<boolean>;
160
+ source?: 'audit' | 'privileged' | 'latest';
161
+ defaultFormat?: ReportFormat | 'summary' | 'metrics' | 'check';
162
+ checkRules?: CheckRules;
163
+ checkHttpStatus?: boolean;
164
+ allowArchive?: boolean;
165
+ rateLimitWindowMs?: number;
166
+ rateLimitMax?: number;
167
+ trustProxy?: boolean;
168
+ keyGenerator?: (req: any) => string;
169
+ auditOptions?: AuditOptions;
170
+ }): (req: any, res: any, next?: (err?: unknown) => void) => Promise<void>;
171
+
172
+ export const PLUGINS: ReadonlyArray<{ id: PluginId; alias: string; title: string }>;
173
+ export const PROFILES: ReadonlyArray<Profile>;
174
+ export const FORMATS: ReadonlyArray<ReportFormat>;
175
+ export const REPORT_FILES: Readonly<Record<ReportFormat, string>>;
176
+ export const DEFAULT_WRAPPER: string;
177
+ export const DEFAULT_SPOOL: string;
178
+ export const DEFAULT_REQUESTS: string;