fix: reject empty coverage counters

This commit is contained in:
DongHyeonka
2026-08-02 09:10:35 +09:00
parent 8d6fbb97e9
commit 6e05a35790
5 changed files with 505 additions and 39 deletions
+30
View File
@@ -131,6 +131,36 @@ describe("risk coverage CLI files", () => {
).rejects.toThrow(/changed during validation/u);
});
it("fails closed when an opened input has no stable file identity", async () => {
const repositoryRoot = await fixture();
await expect(
readRiskCoverageInput(
{
repositoryRoot,
relativePath: "config/testing/policy.json",
label: "policy",
},
{
openFile: async (target, flags) => {
const handle = await open(target, flags);
return {
stat: async () => {
const metadata = await handle.stat();
Object.defineProperties(metadata, {
dev: { value: 0 },
ino: { value: 0 },
});
return metadata;
},
readFile: async (encoding) => handle.readFile(encoding),
close: async () => handle.close(),
};
},
},
),
).rejects.toThrow(/stable file identity unavailable/u);
});
it("confines artifact output and rejects input overwrite or symlink ancestors", async () => {
const repositoryRoot = await fixture();
await expect(