Prepare verified laboratory 2 implementation and evidence

This commit is contained in:
rey
2026-11-17 17:31:17 +03:00
parent 65003b6119
commit 62d7c2023c
85 changed files with 9426 additions and 38 deletions
+22
View File
@@ -0,0 +1,22 @@
import { mkdir, writeFile, chmod, access } from 'node:fs/promises';
import { resolve } from 'node:path';
const root = resolve(import.meta.dir, '..');
const local = resolve(root, '.local');
const files = ['pg_password', 'database_url', 'cache_url', 'valkey.conf'];
const present = await Promise.all(files.map(async name => {try {await access(resolve(local, name));return true;} catch {return false;}}));
if (present.some(Boolean)) {
if (!present.every(Boolean)) throw new Error('Incomplete local configuration; preserve it and investigate before bootstrap');
console.log('Local configuration exists');
} else {
await mkdir(local, { recursive: true, mode: 0o700 });
const pg = crypto.randomUUID().replaceAll('-', '') + crypto.randomUUID().replaceAll('-', '');
const cache = crypto.randomUUID().replaceAll('-', '');
const values = [pg, `postgres://messenger:${pg}@postgres:5432/messenger?sslmode=disable`, `redis://:${cache}@valkey:6379/0`, `bind 0.0.0.0\nprotected-mode yes\nrequirepass ${cache}\nappendonly yes\nappendfsync always\ndir /data\n`];
for (let i = 0; i < files.length; i++) {
const destination = resolve(local, files[i]);
await writeFile(destination, values[i] + '\n', { mode: 0o600, flag: 'wx' });
await chmod(destination, 0o644); // Compose secrets must be readable by nonroot containers; parent is 0700.
}
console.log('Created local synthetic stand credentials');
}