Closed mariesosa closed 1 year ago
Fix to handle path objects such as pathlib.Path in DotNetPEParser, which currently raise an error (see below).
pathlib.Path
DotNetPEParser
>>>from pathlib import Path >>>import dotnetfile >>>filepath = Path("<path_2_file>") >>>dotnetfile.DotNetPE(filepath) ~/.virtualenvs/dotnet/lib/python3.7/site-packages/dotnetfile-0.1.0-py3.7.egg/dotnetfile/dotnetfile.py in __init__(self, path) 161 class DotNetPE(DotNetPEParser): 162 def __init__(self, path): --> 163 super().__init__(path) 164 self.AntiMetadataAnalysis = AntiMetadataAnalysis(self) 165 self.Cor20Header = Cor20Header(self) ~/.virtualenvs/dotnet/lib/python3.7/site-packages/dotnetfile-0.1.0-py3.7.egg/dotnetfile/parser.py in __init__(self, file_ref, parse, log_level, *args, **kwargs) 77 } 78 ---> 79 if not self.is_dotnet_file(): 80 raise CLRFormatError('File is not a .NET assembly.') 81 ~/.virtualenvs/dotnet/lib/python3.7/site-packages/dotnetfile-0.1.0-py3.7.egg/dotnetfile/parser.py in is_dotnet_file(self) 153 dotnet_data_dir = DIRECTORY_ENTRY['IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR'] 154 --> 155 if self.is_dotnet_data_directory_hidden(): 156 result = True 157 else: ~/.virtualenvs/dotnet/lib/python3.7/site-packages/dotnetfile-0.1.0-py3.7.egg/dotnetfile/parser.py in is_dotnet_data_directory_hidden(self) 123 124 dotnet_dir_number = DIRECTORY_ENTRY['IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR'] --> 125 number_of_rva_and_sizes = self.OPTIONAL_HEADER.NumberOfRvaAndSizes 126 127 try: AttributeError: 'DotNetPE' object has no attribute 'OPTIONAL_HEADER'
This error was due to a bad handling of variable file_ref used to instantiate DotNetPEParser.
file_ref
Thanks for your contribution and excuse the very long delay! This has been added to version 0.2.4
Summary
Fix to handle path objects such as
pathlib.Path
inDotNetPEParser
, which currently raise an error (see below).Previous behavior
This error was due to a bad handling of variable
file_ref
used to instantiate DotNetPEParser.