INNER CODE UNIT · TypeScript

isSafeLockFilePath

ZaxbyHub/opencode-swarm · src/cli/index.ts:202

export function isSafeLockFilePath(p: string): boolean {
	const resolved = path.resolve(p);
	const home = path.resolve(os.homedir());
	if (resolved === '/' || resolved === home || resolved.length <= home.length) {
		return false;
	}
	if (segmentDepthBelowRoot(resolved) < 4) {
		return false;
	}
	const leaf = path.basename(resolved);
	if (
		leaf !== 'bun.lock' &&
		leaf !== 'bun.lockb' &&
		leaf !== 'package-lock.json'
	) {
		return false;
	}
	const parent = path.basename(path.dirname(resolved));

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…