fix: 限制NapCat自动化产物写入范围
This commit is contained in:
parent
65807e8ef3
commit
1e39a431b7
@ -182,6 +182,34 @@ export async function runSelfTest(): Promise<void> {
|
||||
);
|
||||
}
|
||||
}
|
||||
const unsafeSkeletonArtifactRootPath = path.resolve("/tmp/not-kt-skeleton");
|
||||
const unsafeSkeletonArtifactRootExisted = existsSync(
|
||||
unsafeSkeletonArtifactRootPath,
|
||||
);
|
||||
let unsafeSkeletonArtifactRootRejected = false;
|
||||
try {
|
||||
buildNapcatRuntimeReleaseReadiness({
|
||||
artifactRoot: "/tmp/not-kt-skeleton",
|
||||
});
|
||||
} catch (error) {
|
||||
unsafeSkeletonArtifactRootRejected = String(error).includes(
|
||||
"Unsafe NapCat Codex artifactRoot",
|
||||
);
|
||||
} finally {
|
||||
if (
|
||||
!unsafeSkeletonArtifactRootExisted &&
|
||||
existsSync(unsafeSkeletonArtifactRootPath)
|
||||
) {
|
||||
rmSync(unsafeSkeletonArtifactRootPath, { force: true, recursive: true });
|
||||
}
|
||||
}
|
||||
if (
|
||||
!unsafeSkeletonArtifactRootRejected ||
|
||||
(!unsafeSkeletonArtifactRootExisted &&
|
||||
existsSync(unsafeSkeletonArtifactRootPath))
|
||||
) {
|
||||
throw new Error("NapCat skeleton unsafe artifact root self-check failed");
|
||||
}
|
||||
if (
|
||||
napcatCandidateDefaults.candidateBranch !==
|
||||
napcatAutomationDefaults.candidateBranch ||
|
||||
|
||||
@ -165,6 +165,7 @@ function buildNapcatPromptSkeleton(config: NapcatPromptSkeletonConfig) {
|
||||
config.input,
|
||||
config.artifactSlug,
|
||||
);
|
||||
assertSafeNapcatCodexArtifactRoot(artifactRoot);
|
||||
const requestedExecute = config.input.execute === true;
|
||||
const promptText = loadNapcatAutomationPrompt(config.promptName).trim();
|
||||
const promptPath = joinNapcatArtifactPath(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user