fix: validate multipass output paths

This commit is contained in:
Shakker
2026-04-09 00:33:13 +01:00
committed by Shakker
parent a04c331cc1
commit 445fe55331
2 changed files with 12 additions and 1 deletions

View File

@@ -7,6 +7,15 @@ describe("qa multipass runtime", () => {
vi.unstubAllEnvs();
});
it("rejects output directories outside the mounted repo root", () => {
expect(() =>
createQaMultipassPlan({
repoRoot: process.cwd(),
outputDir: "/tmp/qa-out",
}),
).toThrow("qa suite --runner multipass requires --output-dir to stay under the repo root");
});
it("reuses suite scenario semantics and resolves mounted artifact paths", () => {
const repoRoot = process.cwd();
const outputDir = path.join(repoRoot, ".artifacts", "qa-e2e", "multipass-test");

View File

@@ -234,7 +234,9 @@ function createQaMultipassOutputDir(repoRoot: string) {
function resolveGuestMountedPath(repoRoot: string, hostPath: string) {
const relativePath = path.relative(repoRoot, hostPath);
if (relativePath.startsWith("..") || path.isAbsolute(relativePath) || relativePath.length === 0) {
throw new Error(`unable to resolve Multipass mounted path for ${hostPath}`);
throw new Error(
`qa suite --runner multipass requires --output-dir to stay under the repo root (${repoRoot}), got ${hostPath}.`,
);
}
return path.posix.join(MULTIPASS_MOUNTED_REPO_PATH, ...relativePath.split(path.sep));
}