feat(ql3): add direct Vault KV worker secret custody

This commit is contained in:
whyour
2026-08-25 00:16:59 +08:00
parent a64d08bda1
commit 686873f8ec
25 changed files with 2830 additions and 37 deletions
+1 -1
View File
@@ -919,7 +919,7 @@ test('CLI rejects symlinks, open arguments, output aliasing and policy ambiguity
test('source-surface audit freezes every reviewed cluster and worker authority', () => {
assert.deepEqual(auditDeploymentImageSurfaces(root), {
schemaVersion: 1,
deploymentYamlFiles: 224,
deploymentYamlFiles: 227,
imageOccurrences: {
control: 2,
'control-ai': 1,
+2 -2
View File
@@ -385,10 +385,10 @@ test('current QL3 workspace has exactly eighteen reviewed package boundaries', (
rootSourceFileRoles: clusterControl.rootSourceFileRoles,
},
{
sourceFiles: 65,
sourceFiles: 66,
rootSourceFiles: 2,
rootSourceLines: 195,
nestedSourceFiles: 63,
nestedSourceFiles: 64,
rootSourceFileRoles: {
'aiCli.ts': 'binary_entry',
'cli.ts': 'binary_entry',
@@ -0,0 +1,47 @@
'use strict';
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const { test } = require('node:test');
const {
auditVaultKvWorkerSecretDeployment,
} = require('../../scripts/ql3-vault-kv-worker-secret-deployment-audit.cjs');
const ROOT = path.resolve(__dirname, '../..');
test('accepts the exact direct Vault KV deployment overlay', () => {
assert.deepEqual(auditVaultKvWorkerSecretDeployment({ root: ROOT }), {
schemaVersion: 1,
provider: 'vault-kv-v2',
mountedValueProjection: false,
findings: [],
compatible: true,
});
});
test('rejects a restored mounted-value projection or broad token TTL', () => {
const readFile = (file, encoding) => {
const source = fs.readFileSync(file, encoding);
if (!file.endsWith('deployment-patch.yaml')) return source;
return source
.replace(
"QL3_WORKER_SECRET_VAULT_MAX_TOKEN_TTL_SECONDS\n value: '900'",
"QL3_WORKER_SECRET_VAULT_MAX_TOKEN_TTL_SECONDS\n value: '3600'",
)
.replace(
'- name: worker-secret-values\n $patch: delete',
'- name: worker-secret-values\n mountPath: /run/values',
);
};
const result = auditVaultKvWorkerSecretDeployment({ root: ROOT, readFile });
assert.equal(result.compatible, false);
assert.deepEqual(
result.findings.map(({ code }) => code),
[
'QL3_VAULT_KV_WORKER_SECRET_ENVIRONMENT_INVALID',
'QL3_VAULT_KV_WORKER_SECRET_PROJECTION_INVALID',
],
);
});
@@ -0,0 +1,88 @@
'use strict';
const assert = require('node:assert/strict');
const { test } = require('node:test');
const {
FIXTURE,
IMAGE,
REQUIRED_GATES,
validateVaultKvWorkerSecretLiveReport,
} = require('../../scripts/ql3-vault-kv-worker-secret-live-audit.cjs');
function fixture() {
return {
schemaVersion: 1,
fixture: FIXTURE,
platform: {
architecture: 'arm64',
vaultImage: IMAGE,
vaultImageId: `sha256:${'a'.repeat(64)}`,
vaultVersion: '1.20.2',
transport: 'TLSv1.3 with an explicit private CA',
storage: 'persistent file barrier fixture',
},
custody: {
provider: 'vault-kv-v2',
kvVersion: 2,
policyCount: 1,
maximumTokenTtlSeconds: 900,
tokenLeaseSeconds: 600,
secretCount: 2,
environmentBundleCount: 1,
observedVersions: [1, 2],
containerReplacements: 1,
},
gates: Object.fromEntries(REQUIRED_GATES.map((gate) => [gate, true])),
limitations: [
'single-host file storage is not Vault integrated-storage HA or an HSM seal quorum',
'the short-lived private CA and service tokens are fixture authorities rather than enterprise PKI',
'the live gate proves direct custody resolution rather than physical Edge storage behavior',
],
};
}
test('accepts the exact content-free Vault KV direct custody report', () => {
assert.deepEqual(validateVaultKvWorkerSecretLiveReport(fixture()), {
schemaVersion: 1,
fixture: FIXTURE,
findings: [],
compatible: true,
});
});
test('rejects false, missing or widened Vault KV gates', () => {
const falseGate = fixture();
falseGate.gates.sealedVaultFailsClosed = false;
assert.equal(
validateVaultKvWorkerSecretLiveReport(falseGate).compatible,
false,
);
const widened = fixture();
widened.gates.unreviewed = true;
assert.equal(
validateVaultKvWorkerSecretLiveReport(widened).compatible,
false,
);
const missing = fixture();
delete missing.gates.tokenRevalidatedPerResolution;
assert.equal(
validateVaultKvWorkerSecretLiveReport(missing).compatible,
false,
);
});
test('rejects sensitive material or widened report shape', () => {
const sensitive = fixture();
sensitive.limitations[0] =
'vault-private-generation-one-must-never-enter-the-report';
assert.match(
validateVaultKvWorkerSecretLiveReport(sensitive).findings.join('; '),
/sensitive material/,
);
const widened = fixture();
widened.endpoint = 'https://vault.private:8200';
const findings = validateVaultKvWorkerSecretLiveReport(widened).findings;
assert.ok(findings.includes('report envelope is invalid'));
assert.match(findings.join('; '), /endpoint is forbidden/);
});
+1 -1
View File
@@ -102,7 +102,7 @@ test('audits one source-derived QingLong 3 release identity', () => {
legacyRootExcluded: true,
workspacePackageCount: 18,
containerRootCount: 4,
deploymentFileCount: 242,
deploymentFileCount: 246,
deploymentImageReferences: 32,
deploymentVersionOccurrences: 36,
compatible: true,