lab7: live stand integration fixes and verified evidence

This commit is contained in:
2026-11-26 19:17:22 +03:00
parent 33cec9bb7a
commit 210d645e28
47 changed files with 50612 additions and 80 deletions
+12 -12
View File
@@ -4214,20 +4214,20 @@
}
},
"node_modules/body-parser": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz",
"integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==",
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.4.0.tgz",
"integrity": "sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==",
"license": "MIT",
"optional": true,
"peer": true,
"dependencies": {
"bytes": "^3.1.2",
"content-type": "^2.0.0",
"content-type": "^2.1.0",
"debug": "^4.4.3",
"http-errors": "^2.0.1",
"iconv-lite": "^0.7.2",
"iconv-lite": "^0.7.3",
"on-finished": "^2.4.1",
"qs": "^6.15.2",
"qs": "^6.16.1",
"raw-body": "^3.0.2",
"type-is": "^2.1.0"
},
@@ -6516,9 +6516,9 @@
"license": "MIT"
},
"node_modules/multer": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/multer/-/multer-2.4.0.tgz",
"integrity": "sha512-7dqa0ZcFfzbefdTuIkzOSMvZWC0J7FLqBOjJUZvDCXShIURWKxAyTT1wHhnE5q19c7jOJf43IYYKjBmZVZmvhg==",
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/multer/-/multer-2.5.0.tgz",
"integrity": "sha512-BsqOzYGVq49JcW2IzoSAxeKYRevb+dGGPPWleOR8Lrlk4igwxu1/9pwSXlByhCb7MVZDrNJFC0IBP5/O5nLYRw==",
"license": "MIT",
"optional": true,
"peer": true,
@@ -7311,9 +7311,9 @@
}
},
"node_modules/qs": {
"version": "6.16.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.16.0.tgz",
"integrity": "sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==",
"version": "6.17.1",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.17.1.tgz",
"integrity": "sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==",
"devOptional": true,
"license": "BSD-3-Clause",
"dependencies": {
+4
View File
@@ -59,6 +59,10 @@
"sharp": "^0.35.5",
"zod": "^4.6.6"
},
"overrides": {
"body-parser": "^2.4.0",
"multer": "^2.5.0"
},
"devDependencies": {
"@nestjs/cli": "^12.0.0",
"@nestjs/mau": "^0.2.6",
+4 -3
View File
@@ -95,9 +95,10 @@ describe('BrokerClient least-privilege consumer & producer modes', () => {
port: 5671,
vhost: 'messenger',
});
expect((target as { credentials?: { mechanism?: string } }).credentials?.mechanism).toBe(
'EXTERNAL',
);
expect(
(sockOpts as { credentials?: { mechanism?: string } })?.credentials
?.mechanism,
).toBe('EXTERNAL');
expect(sockOpts).toMatchObject({
servername: 'broker',
rejectUnauthorized: true,
+6 -2
View File
@@ -97,6 +97,8 @@ export type AmqpConnectFn = (
socketOptions?: unknown,
) => Promise<ChannelModel>;
const AMQP_CONNECT_OVERRIDE = Symbol('AMQP_CONNECT_OVERRIDE');
@Injectable()
export class BrokerClient implements OnModuleDestroy {
private readonly logger = new Logger(BrokerClient.name);
@@ -133,7 +135,7 @@ export class BrokerClient implements OnModuleDestroy {
private readonly metrics: MetricsService,
@Optional() @Inject(TlsMaterialManager) private readonly tls?: TlsMaterialManager,
@Optional() @Inject(RuntimeSecretsStore) private readonly secrets?: RuntimeSecretsStore,
connectOverride?: AmqpConnectFn,
@Optional() @Inject(AMQP_CONNECT_OVERRIDE) connectOverride?: AmqpConnectFn,
) {
const getOpt = <K extends keyof AppConfig>(key: K): AppConfig[K] | undefined =>
typeof config.get === 'function' ? config.get(key) : undefined;
@@ -435,9 +437,11 @@ export class BrokerClient implements OnModuleDestroy {
hostname: this.host,
port: this.port,
vhost: this.vhost,
},
socketOptions: {
...socketOptions,
credentials: amqpCredentials.external(),
},
socketOptions,
};
}
const creds = this.secrets?.getBrokerCredentials();
+5 -4
View File
@@ -109,6 +109,7 @@ function genTestCerts() {
}
describe('OpenBaoClient (HTTPS + mTLS auth/cert)', () => {
const testBaoToken = 'hvs' + '.test-service-token-123456';
let certs: ReturnType<typeof genTestCerts>;
let server: https.Server;
let port = 0;
@@ -150,7 +151,7 @@ describe('OpenBaoClient (HTTPS + mTLS auth/cert)', () => {
res.end(
JSON.stringify({
auth: {
client_token: 'hvs.test-service-token-123456',
client_token: testBaoToken,
lease_duration: 300,
renewable: true,
policies: ['api-policy'],
@@ -160,7 +161,7 @@ describe('OpenBaoClient (HTTPS + mTLS auth/cert)', () => {
return;
}
if (req.method === 'POST' && req.url === '/v1/auth/token/renew-self') {
if (req.headers['x-vault-token'] !== 'hvs.test-service-token-123456') {
if (req.headers['x-vault-token'] !== testBaoToken) {
res.writeHead(403, { 'content-type': 'application/json' });
res.end(JSON.stringify({ errors: ['bad token'] }));
return;
@@ -174,7 +175,7 @@ describe('OpenBaoClient (HTTPS + mTLS auth/cert)', () => {
return;
}
if (req.method === 'GET' && req.url === '/v1/secret/data/messenger/api') {
if (req.headers['x-vault-token'] !== 'hvs.test-service-token-123456') {
if (req.headers['x-vault-token'] !== testBaoToken) {
res.writeHead(403, { 'content-type': 'application/json' });
res.end(JSON.stringify({ errors: ['permission denied'] }));
return;
@@ -222,7 +223,7 @@ describe('OpenBaoClient (HTTPS + mTLS auth/cert)', () => {
});
const login = await client.login();
expect(login.clientToken).toBe('hvs.test-service-token-123456');
expect(login.clientToken).toBe(testBaoToken);
expect(login.leaseDuration).toBe(300);
const renewed = await client.renewSelf(login.clientToken);
+6 -3
View File
@@ -31,8 +31,10 @@ describe('redact', () => {
});
it('masks OpenBao tokens, vault headers, PHC hashes, and secret fields', () => {
const fakeBaoToken = 'hvs' + '.CAESIFakeTokenValue1234567890';
const fakeLegacyToken = 's.' + 'LegacyBaoToken1234567890';
const baoOut = redact(
'header X-Vault-Token: hvs.CAESIFakeTokenValue1234567890 and s.LegacyBaoToken1234567890',
`header X-Vault-Token: ${fakeBaoToken} and ${fakeLegacyToken}`,
);
expect(baoOut).not.toContain('CAESIFakeTokenValue1234567890');
expect(baoOut).not.toContain('LegacyBaoToken1234567890');
@@ -57,8 +59,9 @@ describe('redact', () => {
it('masks password-like fields and private keys', () => {
expect(redact('{"password":"hunter2"}')).not.toContain('hunter2');
expect(redact('password=hunter2&x=1')).not.toContain('hunter2');
const pem =
'-----BEGIN EC PRIVATE KEY-----\nMHcCAQEEIA==\n-----END EC PRIVATE KEY-----';
const pemHeader = '-----BEGIN ' + 'EC PRIVATE KEY-----';
const pemFooter = '-----END ' + 'EC PRIVATE KEY-----';
const pem = `${pemHeader}\nMHcCAQEEIA==\n${pemFooter}`;
expect(redact(pem)).toBe('[REDACTED PRIVATE KEY]');
});