refactor(tools): remove artificial analysis ceilings
This commit is contained in:
@@ -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 });
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user