fix(windows): remove cancelled snapshot outputs (#957)

* fix(windows): remove cancelled snapshot outputs

* fix(windows): allow readback of retained runtime files

* test(windows): verify retained runtime file protection
This commit is contained in:
morluto
2026-10-07 23:45:16 +08:00
committed by GitHub
parent 9f496ef2d4
commit d76f7d1508
2 changed files with 73 additions and 5 deletions
+51
View File
@@ -263,6 +263,57 @@ try {
]);
native.call("runtime_snapshot_cancel", [runtime.handle]);
await assert.rejects(cancelled, /cancelled/u);
assert.equal(await exists(join(runtime.path, "cancelled.bin")), false);
const readbackRuntime = WindowsPrivateRuntime.create(
workspace.replaceAll("\\", "/"),
"readback-",
);
try {
readbackRuntime.writeFile("written.txt", "runtime-write-readback");
assert.equal(
readbackRuntime.readFile("written.txt"),
"runtime-write-readback",
);
const readbackSnapshot = await readbackRuntime.snapshot(
source,
"snapshot.bin",
);
assert.equal(
readbackSnapshot.sha256,
createHash("sha256")
.update(await readFile(source))
.digest("hex"),
);
assert.equal(
readbackRuntime.readFile("snapshot.bin"),
await readFile(source, "utf8"),
);
const writtenPath = join(readbackRuntime.observation.path, "written.txt");
await assert.rejects(writeFile(writtenPath, "replace"));
await assert.rejects(rename(writtenPath, `${writtenPath}.renamed`));
await assert.rejects(rm(writtenPath));
assert.equal(
readbackRuntime.readFile("written.txt"),
"runtime-write-readback",
);
const snapshotPath = join(
readbackRuntime.observation.path,
"snapshot.bin",
);
await assert.rejects(rename(snapshotPath, `${snapshotPath}.renamed`));
await assert.rejects(rm(snapshotPath));
assert.equal(
readbackRuntime.readFile("snapshot.bin"),
await readFile(source, "utf8"),
);
report.controls = {
...report.controls,
completedRuntimeFileReadback: true,
completedRuntimeFileMutationDenied: true,
};
} finally {
await readbackRuntime.close();
}
report.controls = {
...report.controls,
protectedDaclReadback: true,