@celilo/cli 2.2.1 → 3.0.0
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.
- package/CELILO_CORE_MODULES.md +2 -1
- package/CELILO_SUBSYSTEMS.md +1 -1
- package/README.md +1 -1
- package/drizzle/0032_module_jail_policies.sql +28 -0
- package/drizzle/0033_build_bus_hook_runs.sql +37 -0
- package/drizzle/meta/_journal.json +15 -1
- package/package.json +3 -3
- package/src/__integration__/container-services-cli.integration.test.ts +1 -1
- package/src/api/serve.ts +13 -1
- package/src/api/sessions.test.ts +3 -3
- package/src/api-clients/proxmox.ts +10 -7
- package/src/cli/backup-rename.test.ts +3 -3
- package/src/cli/cli.test.ts +1 -1
- package/src/cli/commands/events.test.ts +2 -2
- package/src/cli/commands/firewall-interface-list.test.ts +2 -2
- package/src/cli/commands/machine-list.test.ts +57 -0
- package/src/cli/commands/machine-list.ts +35 -4
- package/src/cli/commands/module-health.test.ts +35 -0
- package/src/cli/commands/module-health.ts +12 -3
- package/src/cli/commands/module-import-registry.test.ts +1 -1
- package/src/cli/commands/module-jail.test.ts +242 -0
- package/src/cli/commands/module-jail.ts +227 -0
- package/src/cli/commands/module-list-jail.test.ts +136 -0
- package/src/cli/commands/module-list.ts +30 -3
- package/src/cli/commands/module-publish.test.ts +28 -6
- package/src/cli/commands/module-publish.ts +14 -12
- package/src/cli/commands/module-update.test.ts +22 -7
- package/src/cli/commands/module-update.ts +73 -18
- package/src/cli/commands/module-upgrade-gate.test.ts +154 -0
- package/src/cli/commands/module-upgrade.test.ts +115 -1
- package/src/cli/commands/module-upgrade.ts +66 -4
- package/src/cli/commands/module-verify.test.ts +1 -1
- package/src/cli/commands/publish/execute.ts +4 -1
- package/src/cli/commands/publish/helpers.ts +4 -3
- package/src/cli/commands/publish/index.ts +23 -1
- package/src/cli/commands/publish/module-registry.test.ts +24 -1
- package/src/cli/commands/publish/module-registry.ts +23 -4
- package/src/cli/commands/publish/plan.test.ts +64 -0
- package/src/cli/commands/publish/plan.ts +52 -19
- package/src/cli/commands/publish/types.ts +20 -0
- package/src/cli/commands/registry-owner.test.ts +1 -1
- package/src/cli/commands/registry-token.test.ts +1 -1
- package/src/cli/commands/subscribers-install-daemon.test.ts +44 -0
- package/src/cli/commands/subscribers-install-daemon.ts +107 -0
- package/src/cli/commands/subscribers-serve.test.ts +22 -0
- package/src/cli/commands/subscribers-serve.ts +22 -4
- package/src/cli/commands/system-audit.ts +34 -11
- package/src/cli/commands/system-doctor-remediation-gate.test.ts +295 -0
- package/src/cli/commands/system-doctor.test.ts +76 -10
- package/src/cli/commands/system-doctor.ts +34 -3
- package/src/cli/commands/system-init-deprecation.test.ts +1 -1
- package/src/cli/commands/system-update.ts +16 -6
- package/src/cli/completion.ts +18 -3
- package/src/cli/flag-surface-gate.test.ts +279 -0
- package/src/cli/fuel-gauge.ts +12 -4
- package/src/cli/index.ts +80 -2
- package/src/cli/json-output.test.ts +81 -0
- package/src/cli/parser.test.ts +37 -1
- package/src/cli/restore-command.test.ts +3 -3
- package/src/cli/restore-migration-failure.test.ts +2 -2
- package/src/cli/tui/audit-state.ts +2 -0
- package/src/cli/types.ts +9 -0
- package/src/config/paths.test.ts +19 -19
- package/src/db/client.test.ts +46 -1
- package/src/db/client.ts +26 -0
- package/src/db/schema.ts +63 -0
- package/src/hooks/broker.test.ts +9 -3
- package/src/hooks/capability-loader-firewall.test.ts +9 -1
- package/src/hooks/capability-loader.ts +8 -0
- package/src/hooks/executor.test.ts +91 -14
- package/src/hooks/executor.ts +31 -1
- package/src/hooks/hook-jail-toolchain-reach.test.ts +8 -3
- package/src/hooks/hook-jail-unreachability.test.ts +27 -20
- package/src/hooks/hook-trespass.test.ts +22 -6
- package/src/hooks/jail.test.ts +105 -17
- package/src/hooks/jail.ts +47 -10
- package/src/hooks/run-named-hook.ts +19 -16
- package/src/hooks/test-fixtures/artifact-writing-hook.ts +0 -1
- package/src/hooks/test-fixtures/capability-calling-hook.ts +20 -13
- package/src/hooks/test-fixtures/jail-probe-hook.ts +9 -1
- package/src/hooks/test-fixtures/jail-toolchain-hook.ts +7 -2
- package/src/hooks/test-fixtures/runaway-hook.ts +0 -1
- package/src/hooks/test-fixtures/sigterm-ignoring-hook.ts +0 -1
- package/src/hooks/test-fixtures/silent-hook.ts +0 -1
- package/src/hooks/test-fixtures/store-writing-hook.ts +20 -11
- package/src/hooks/test-fixtures/success-hook.ts +4 -4
- package/src/manifest/contracts/v1.ts +32 -14
- package/src/manifest/json-schema-roundtrip.test.ts +1 -1
- package/src/manifest/schema.ts +66 -16
- package/src/manifest/validate.test.ts +47 -0
- package/src/policy/capability-shape-baseline.ts +63 -21
- package/src/policy/capability-shape-drift.test.ts +53 -1
- package/src/policy/capability-shape.test.ts +105 -0
- package/src/policy/capability-shape.ts +283 -2
- package/src/policy/module-script-scan.ts +52 -68
- package/src/policy/no-hand-built-ssh.test.ts +5 -1
- package/src/policy/no-swallowed-refusal.test.ts +14 -14
- package/src/registry/client.test.ts +67 -2
- package/src/registry/client.ts +7 -7
- package/src/secrets/storage.test.ts +70 -4
- package/src/secrets/storage.ts +71 -1
- package/src/services/alerting/keys.test.ts +4 -0
- package/src/services/alerting/keys.ts +12 -2
- package/src/services/audit/health.test.ts +155 -2
- package/src/services/audit/health.ts +76 -2
- package/src/services/audit/index.test.ts +23 -1
- package/src/services/audit/index.ts +8 -2
- package/src/services/audit/interface-classification.test.ts +16 -5
- package/src/services/audit/interface-classification.ts +25 -2
- package/src/services/audit/jail-exemptions.test.ts +42 -0
- package/src/services/audit/jail-exemptions.ts +44 -0
- package/src/services/audit/module-integrity.test.ts +23 -1
- package/src/services/audit/module-integrity.ts +7 -2
- package/src/services/audit/module-versions.ts +5 -1
- package/src/services/audit/public-dns.test.ts +20 -0
- package/src/services/audit/public-dns.ts +7 -2
- package/src/services/audit/recurrence-gate.test.ts +225 -0
- package/src/services/audit/trusted-sources.test.ts +17 -0
- package/src/services/audit/trusted-sources.ts +21 -0
- package/src/services/audit/types.ts +2 -1
- package/src/services/backup-create.ts +9 -0
- package/src/services/backup-envelope-roundtrip.test.ts +1 -1
- package/src/services/backup-in-flight-refusal.test.ts +1 -1
- package/src/services/build-bus/hook-dispatch-executor.test.ts +269 -0
- package/src/services/build-bus/hook-dispatch-mgmt.test.ts +105 -105
- package/src/services/build-bus/hook-dispatch-path.test.ts +95 -0
- package/src/services/build-bus/hook-dispatch.test.ts +86 -116
- package/src/services/build-bus/hook-dispatch.ts +99 -121
- package/src/services/build-bus/hook-dispatcher.ts +143 -17
- package/src/services/build-bus/receiver-daemon.test.ts +189 -0
- package/src/services/build-bus/receiver-daemon.ts +355 -0
- package/src/services/build-bus/self-update.ts +156 -0
- package/src/services/bus-ensure-flow.test.ts +1 -1
- package/src/services/bus-interview-park.test.ts +2 -2
- package/src/services/bus-interview.test.ts +2 -2
- package/src/services/bus-secret-flow.test.ts +1 -1
- package/src/services/capability-compat.test.ts +90 -0
- package/src/services/capability-compat.ts +128 -0
- package/src/services/celilo-events.test.ts +1 -1
- package/src/services/celilo-mgmt-hooks.test.ts +23 -5
- package/src/services/container-service.test.ts +1 -1
- package/src/services/cross-module-read.test.ts +2 -2
- package/src/services/deploy-preflight.ts +7 -0
- package/src/services/deploy-terraform.ts +38 -1
- package/src/services/deployed-systems.ts +1 -1
- package/src/services/events-daemon.test.ts +57 -0
- package/src/services/events-daemon.ts +76 -0
- package/src/services/firewall-reach.ts +21 -8
- package/src/services/fleet-checks.test.ts +159 -4
- package/src/services/fleet-checks.ts +206 -3
- package/src/services/health-runner.test.ts +87 -2
- package/src/services/health-runner.ts +83 -16
- package/src/services/infrastructure-selector.test.ts +1 -1
- package/src/services/jail-exemptions.test.ts +125 -0
- package/src/services/jail-exemptions.ts +81 -0
- package/src/services/machine-pool.test.ts +1 -1
- package/src/services/module-deploy-prune.test.ts +89 -0
- package/src/services/module-deploy.ts +84 -129
- package/src/services/module-subscriptions.test.ts +2 -2
- package/src/services/module-types-drift.test.ts +1 -1
- package/src/services/module-validator/capability-versions.test.ts +13 -2
- package/src/services/network-discovery.test.ts +64 -1
- package/src/services/network-discovery.ts +30 -5
- package/src/services/responder-probe.test.ts +1 -1
- package/src/services/restore-from-file.test.ts +4 -4
- package/src/services/restore-preflight.test.ts +1 -1
- package/src/services/ssh-key-manager.test.ts +2 -2
- package/src/services/system-state-stage.test.ts +2 -2
- package/src/services/terraform-safety.test.ts +83 -0
- package/src/services/terraform-safety.ts +53 -0
- package/src/services/update/orchestrator.test.ts +3 -1
- package/src/test-utils/bus-responder.ts +1 -1
- package/tsconfig.json +2 -13
|
@@ -178,3 +178,56 @@ function formatUnsafeOperationError(action: TerraformAction): string {
|
|
|
178
178
|
|
|
179
179
|
return lines.join('\n');
|
|
180
180
|
}
|
|
181
|
+
|
|
182
|
+
/** What the deploy should do with the plan computed AFTER an auto-import. */
|
|
183
|
+
export type ImportRetryVerdict =
|
|
184
|
+
| { action: 'done' }
|
|
185
|
+
| { action: 'apply' }
|
|
186
|
+
| { action: 'refuse'; error: string };
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Decide whether the apply retried after an auto-import may proceed.
|
|
190
|
+
*
|
|
191
|
+
* An import REPLACES the plan that `deployTerraform` validated before its first
|
|
192
|
+
* apply. That plan described a create; the plan computed after the import can
|
|
193
|
+
* describe a REPLACE, because `ostemplate` and `rootfs[0].storage` do not
|
|
194
|
+
* round-trip through an import and each forces one. Nothing re-validated it, so
|
|
195
|
+
* the retry applied a destroy that `validateTerraformPlanSafety` exists to
|
|
196
|
+
* forbid — and a redeploy destroyed signal's LXC on a converged fleet
|
|
197
|
+
* (celilo#1374). The gate was present; the import walked around it.
|
|
198
|
+
*
|
|
199
|
+
* Pure (Rule 10) so the refusal is testable without terraform: the caller does
|
|
200
|
+
* the I/O and hands the exit code and output here.
|
|
201
|
+
*/
|
|
202
|
+
export function planAfterImportVerdict(exitCode: number, planOutput: string): ImportRetryVerdict {
|
|
203
|
+
// 0 = no changes. The import alone reconciled state with reality, which is
|
|
204
|
+
// the outcome we want: adopt the resource and apply nothing.
|
|
205
|
+
if (exitCode === 0) {
|
|
206
|
+
return { action: 'done' };
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// 2 = changes pending. Anything else is an error, and an unreadable plan is
|
|
210
|
+
// never a licence to apply (D7: no measurement is not "no drift").
|
|
211
|
+
if (exitCode !== 2) {
|
|
212
|
+
return {
|
|
213
|
+
action: 'refuse',
|
|
214
|
+
error: `Refusing to apply after import: terraform plan failed (exit ${exitCode}).\n${planOutput.slice(0, 500)}`,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const safety = validateTerraformPlanSafety(planOutput);
|
|
219
|
+
if (!safety.safe) {
|
|
220
|
+
return {
|
|
221
|
+
action: 'refuse',
|
|
222
|
+
error: [
|
|
223
|
+
'Refusing to apply the plan computed after importing an existing resource.',
|
|
224
|
+
'The import adopted infrastructure that already exists, and applying this',
|
|
225
|
+
'plan would destroy it rather than adopt it.',
|
|
226
|
+
'',
|
|
227
|
+
safety.error ?? 'unsafe plan',
|
|
228
|
+
].join('\n'),
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return { action: 'apply' };
|
|
233
|
+
}
|
|
@@ -78,6 +78,7 @@ const cleanAudit: AuditDeps = {
|
|
|
78
78
|
moduleConfigs: { modules: [] },
|
|
79
79
|
moduleIntegrity: { results: [] },
|
|
80
80
|
detectWithoutConverge: { modules: [] },
|
|
81
|
+
jailExemptions: { exemptions: [] },
|
|
81
82
|
health: { results: [] },
|
|
82
83
|
backups: { modules: [] },
|
|
83
84
|
abandonedOperations: { records: [] },
|
|
@@ -87,8 +88,9 @@ const cleanAudit: AuditDeps = {
|
|
|
87
88
|
secretsDecryptable: { results: [] },
|
|
88
89
|
servicesReachable: { results: [] },
|
|
89
90
|
machinesReachable: { results: [] },
|
|
91
|
+
diskSpace: { results: [] },
|
|
90
92
|
transportReads: { statuses: [], now: new Date(), staleAfterMs: 30 * 60_000 },
|
|
91
|
-
trustedSources: { firewalls: [] },
|
|
93
|
+
trustedSources: { firewalls: [], unreachableFirewalls: [] },
|
|
92
94
|
publicDns: { records: [], probe: unusedPublicDnsProbe },
|
|
93
95
|
};
|
|
94
96
|
|
|
@@ -130,7 +130,7 @@ export function startBusResponderFixture(opts: BusResponderFixtureOptions): BusR
|
|
|
130
130
|
close: () => {
|
|
131
131
|
handle.close();
|
|
132
132
|
db.$client.close();
|
|
133
|
-
if (prevDataDir === undefined) process.env.CELILO_DATA_DIR
|
|
133
|
+
if (prevDataDir === undefined) delete process.env.CELILO_DATA_DIR;
|
|
134
134
|
else process.env.CELILO_DATA_DIR = prevDataDir;
|
|
135
135
|
// Reset to the scratch path, never restore the previous value: it may
|
|
136
136
|
// be another suite's temp database, or unset — which sends the next
|
package/tsconfig.json
CHANGED
|
@@ -1,21 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
2
3
|
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"module": "ESNext",
|
|
5
4
|
"lib": ["ESNext"],
|
|
6
|
-
"moduleResolution": "bundler",
|
|
7
5
|
"jsx": "react-jsx",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"isolatedModules": true,
|
|
14
|
-
"types": ["bun-types"],
|
|
15
6
|
"paths": {
|
|
16
7
|
"@/*": ["./src/*"]
|
|
17
8
|
}
|
|
18
|
-
}
|
|
19
|
-
"include": ["src/**/*", "test-integration/**/*"],
|
|
20
|
-
"exclude": ["node_modules"]
|
|
9
|
+
}
|
|
21
10
|
}
|