cape: make some pe fields optional

closes #2632

but, pe.imagebase is required, so keeping that (so test field will
continue to fail).
This commit is contained in:
Willi Ballenthin
2025-03-18 10:42:38 +00:00
committed by Willi Ballenthin
parent fa90aae3dc
commit c1c71613a9
2 changed files with 5 additions and 4 deletions

View File

@@ -54,7 +54,8 @@ class CapeExtractor(DynamicFeatureExtractor):
def get_base_address(self) -> Union[AbsoluteVirtualAddress, _NoAddress, None]:
# value according to the PE header, the actual trace may use a different imagebase
assert self.report.static is not None and self.report.static.pe is not None
assert self.report.static is not None
assert self.report.static.pe is not None
return AbsoluteVirtualAddress(self.report.static.pe.imagebase)
def extract_global_features(self) -> Iterator[tuple[Feature, Address]]:

View File

@@ -188,15 +188,15 @@ class PE(FlexibleModel):
# timestamp: str
# list[ImportedDll], or dict[basename(dll), ImportedDll]
imports: Union[list[ImportedDll], dict[str, ImportedDll]]
imports: list[ImportedDll] | dict[str, ImportedDll] = Field(default_factory=list) # type: ignore
# imported_dll_count: Optional[int] = None
# imphash: str
# exported_dll_name: Optional[str] = None
exports: list[ExportedSymbol]
exports: list[ExportedSymbol] = Field(default_factory=list)
# dirents: list[DirectoryEntry]
sections: list[Section]
sections: list[Section] = Field(default_factory=list)
# ep_bytes: Optional[HexBytes] = None