refactor(tools): remove artificial analysis ceilings

This commit is contained in:
morluto
2026-09-29 16:29:23 +08:00
parent 36aeec9586
commit 2f08c7c932
202 changed files with 2314 additions and 3072 deletions
@@ -14,6 +14,30 @@ import {
} from "./ManagedPe.fixture.js";
describe("managed artifact inventory", () => {
it("statically inspects PE files with more than 96 sections", () => {
const fixture = buildManagedPeFixture();
const peOffset = fixture.readUInt32LE(0x3c);
const coffOffset = peOffset + 4;
const optionalHeaderSize = fixture.readUInt16LE(coffOffset + 16);
const sectionOffset = coffOffset + 20 + optionalHeaderSize;
const sectionDataOffset = 0x1200;
const bytes = Buffer.alloc(sectionDataOffset + 0x0e00);
fixture.copy(bytes, 0, 0, 0x0200);
fixture.copy(bytes, sectionDataOffset, 0x0200, 0x1000);
bytes.writeUInt16LE(97, coffOffset + 2);
bytes.writeUInt32LE(sectionDataOffset, sectionOffset + 20);
const result = inspectManagedArtifactBytes(
bytes,
managedPeFixtureTarget(bytes),
MANAGED_ARTIFACT_FIXTURE_LIMITS,
);
expect(result.classification.status).toBe("managed");
expect(result.pe.section_count).toBe(97);
expect(sectionOffset + 97 * 40).toBeLessThanOrEqual(sectionDataOffset);
});
it("inventories module, assembly, framework, references, and resources without loading CLR code", () => {
const resource = Buffer.from("source-owned resource");
const bytes = buildManagedPeFixture({ resourceData: resource });
+2 -2
View File
@@ -226,11 +226,11 @@ const readCoffHeader = (bytes: Buffer): CoffHeader => {
const coff = peOffset + 4;
const machine = bytes.readUInt16LE(coff);
const sectionCount = bytes.readUInt16LE(coff + 2);
if (sectionCount === 0 || sectionCount > 96)
if (sectionCount === 0)
throw managedFailure(
"invalid-directory",
"pe.sections",
"PE section count is outside the admitted range",
"PE section count must be positive",
coff + 2,
);
const optionalSize = bytes.readUInt16LE(coff + 16);