mirror of
https://github.com/affaan-m/ECC.git
synced 2026-08-17 21:15:40 +02:00
* feat(install): add hardened Docker test harness * feat(docker): complete isolated CLI session lifecycle * fix(docker): exercise packed public CLI offline * fix(docker): close hardened harness review gaps * test(docker): bound harness subprocesses
37 lines
876 B
JavaScript
37 lines
876 B
JavaScript
#!/usr/bin/env node
|
|
|
|
'use strict';
|
|
|
|
const path = require('path');
|
|
|
|
const WORKSPACE_ROOT = '/workspace';
|
|
|
|
function resolveProjectDir(candidate) {
|
|
if (
|
|
typeof candidate !== 'string'
|
|
|| !path.posix.isAbsolute(candidate)
|
|
|| /[\0\r\n]/.test(candidate)
|
|
) {
|
|
throw new Error('ECC_PROJECT_DIR must be an absolute path within /workspace.');
|
|
}
|
|
|
|
const resolved = path.posix.resolve(candidate);
|
|
if (resolved === WORKSPACE_ROOT || !resolved.startsWith(`${WORKSPACE_ROOT}/`)) {
|
|
throw new Error('ECC_PROJECT_DIR must be a child path within /workspace.');
|
|
}
|
|
return resolved;
|
|
}
|
|
|
|
function main() {
|
|
try {
|
|
process.stdout.write(`${resolveProjectDir(process.argv[2])}\n`);
|
|
} catch (error) {
|
|
process.stderr.write(`Error: ${error.message}\n`);
|
|
process.exitCode = 2;
|
|
}
|
|
}
|
|
|
|
if (require.main === module) main();
|
|
|
|
module.exports = { resolveProjectDir };
|