mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 21:46:01 +00:00
perf(elf): bound kernel module signature digest reads (#14024)
This commit is contained in:
1 parent
fabe0da74b
commit
7487261a35
4 files changed
+149
-45
No files matched your search
@@ -102,6 +102,57 @@ it("rejects relative paths, extra arguments and invalid field budgets before rea
|
||||
expect(calls).toBe(0);
|
||||
});
|
||||
|
||||
it("requires a nonempty PKCS#7 range ending at the file trailer", async () => {
|
||||
const valid = {
|
||||
status: "present",
|
||||
reason: null,
|
||||
magic: { offset: 484, bytes: 28 },
|
||||
info: {
|
||||
location: { offset: 472, bytes: 12 },
|
||||
algo: 0,
|
||||
hash: 0,
|
||||
id_type: 2,
|
||||
signer_len: 0,
|
||||
key_id_len: 0,
|
||||
pad: [0, 0, 0],
|
||||
sig_len: 5,
|
||||
},
|
||||
pkcs7: { location: { offset: 467, bytes: 5 }, sha256: digest },
|
||||
} satisfies KernelModule["signature"];
|
||||
const empty = {
|
||||
...valid,
|
||||
info: { ...valid.info, sig_len: 0 },
|
||||
pkcs7: {
|
||||
location: { offset: valid.info.location.offset, bytes: 0 },
|
||||
sha256:
|
||||
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
},
|
||||
};
|
||||
const beforeEof = {
|
||||
...valid,
|
||||
magic: { ...valid.magic, offset: 483 },
|
||||
info: { ...valid.info, location: { ...valid.info.location, offset: 471 } },
|
||||
pkcs7: {
|
||||
...valid.pkcs7,
|
||||
location: { ...valid.pkcs7.location, offset: 466 },
|
||||
},
|
||||
};
|
||||
const outcomes = await Promise.all(
|
||||
[valid, empty, beforeEof].map((signature) =>
|
||||
new KernelModuleService({
|
||||
identity,
|
||||
inspect: () => Promise.resolve(ok({ ...report, signature })),
|
||||
}).inspect({ path: report.artifact.path }),
|
||||
),
|
||||
);
|
||||
expect(outcomes.map((outcome) => outcome.ok)).toEqual([true, false, false]);
|
||||
for (const outcome of outcomes.slice(1)) {
|
||||
if (outcome.ok)
|
||||
throw new Error("Expected inconsistent signature rejection");
|
||||
expect(outcome.error).toBeInstanceOf(AnalysisOutputError);
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects a report whose entry count does not match the examined sections", async () => {
|
||||
const result = await new KernelModuleService({
|
||||
identity,
|
||||
|
||||
Reference in new issue
Block a user