Skip to content

Commit

Permalink
code to cover #68
Browse files Browse the repository at this point in the history
  • Loading branch information
clearbluejar committed Jan 2, 2024
1 parent b04d11f commit 45f1d01
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ghidriff/ghidra_diff_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,8 +865,12 @@ def get_pe_download_url(
"""

path = Path(path)
pe_info = get_pe_extra_data(path)
url = get_microsoft_download_url(filename, pe_info['timestamp'], pe_info['image_size'])
try:
pe_info = get_pe_extra_data(path)
url = get_microsoft_download_url(filename, pe_info['timestamp'], pe_info['image_size'])
except:
self.logger.warn(f'PE Parsing error. Exception thrown parsing {path.name}')
url = None

# from ghidra.app.util.bin.format.pe import PortableExecutable
# from ghidra.app.util.bin import FileByteProvider
Expand Down
21 changes: 21 additions & 0 deletions tests/test_pe_parsing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pytest
from pathlib import Path

from ghidriff import GhidraDiffEngine, VersionTrackingDiff, get_parser

SYMBOLS_DIR = 'symbols'

@pytest.mark.forked
def test_parsing_pe_garbage(shared_datadir: Path):

parser = get_parser()

args = parser.parse_args(['test', 'test2']) # these args will not be tested


not_a_pe_path = shared_datadir / SYMBOLS_DIR / 'pingme.txt'

DiffEngine: GhidraDiffEngine = VersionTrackingDiff
d = DiffEngine(args=args)

assert None == d.get_pe_download_url(not_a_pe_path,'junk')

0 comments on commit 45f1d01

Please sign in to comment.