fix(staging): rotate SSH secret handling and env ownership
Staging Backend Quality Gate / validate (pull_request) Successful in 16m32s
Staging Backend Quality Gate / publish (pull_request) Has been skipped

This commit is contained in:
Jesse
2026-08-06 15:34:31 +08:00
parent eccd831ae9
commit cfc7af6b46
16 changed files with 153 additions and 22 deletions
@@ -192,6 +192,37 @@ test("database env validator rejects symlinks and unsafe modes", () => {
}
});
test("database env validator enforces an explicit staging owner uid without printing values", () => {
const root = mkdtempSync(join(tmpdir(), "jyotisha-database-env-owner-"));
const envFile = join(root, ".env.staging.database");
try {
writeFileSync(envFile, `${validEnvironment.join("\n")}\n`, { mode: 0o600 });
chmodSync(envFile, 0o600);
const currentUid = process.getuid?.();
assert.equal(typeof currentUid, "number");
const accepted = spawnSync("bash", [validator, envFile], {
encoding: "utf8",
env: { ...process.env, EXPECTED_STAGING_ENV_OWNER_UID: String(currentUid) },
});
assert.equal(accepted.status, 0, accepted.stderr);
const rejected = spawnSync("bash", [validator, envFile], {
encoding: "utf8",
env: { ...process.env, EXPECTED_STAGING_ENV_OWNER_UID: String((currentUid ?? 0) + 1) },
});
assert.notEqual(rejected.status, 0);
assert.match(rejected.stderr, /invalid owner/);
assert.doesNotMatch(
`${rejected.stdout}${rejected.stderr}`,
/postgres-test-password|schema-owner-test-password|staging-backup-test-password/,
);
} finally {
rmSync(root, { recursive: true, force: true });
}
});
test("database env validator accepts a private valid file without printing values", () => {
const root = mkdtempSync(join(tmpdir(), "jyotisha-database-env-"));
const envFile = join(root, ".env.staging.database");