Skip to content

Commit

Permalink
move get_parser, bump ver, add testing in setup.cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
clearbluejar committed Sep 9, 2023
1 parent ef72f91 commit 6f3f98c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
5 changes: 3 additions & 2 deletions ghidriff/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
__version__ = '0.3.0'
__version__ = '0.4.0'
__author__ = 'clearbluejar'

# Expose API
from .ghidra_diff_engine import GhidraDiffEngine
from .version_tracking_diff import VersionTrackingDiff
from .simple_diff import SimpleDiff
from .structural_graph_diff import StructualGraphDiff
from .__main__ import get_parser, get_engine_classes

__all__ = [
"GhidraDiffEngine", "SimpleDiff", "StructualGraphDiff", "VersionTrackingDiff"
"GhidraDiffEngine", "SimpleDiff", "StructualGraphDiff", "VersionTrackingDiff", "get_parser", "get_engine_classes"
]
20 changes: 15 additions & 5 deletions ghidriff/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ def get_engine_classes() -> dict:

return engines


def main():
def get_parser() -> argparse.ArgumentParser:
"""
ghidriff - GhidraDiffEngine module main function
Build main ghidriff parser
"""

parser = argparse.ArgumentParser(description='ghidriff - A Command Line Ghidra Binary Diffing Engine',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
formatter_class=argparse.ArgumentDefaultsHelpFormatter)

parser.add_argument('old', nargs=1, help="Path to old version of binary '/somewhere/bin.old'")
parser.add_argument('new', action='append', nargs='+',
Expand All @@ -34,9 +33,19 @@ def main():
parser.add_argument('--engine', help='The diff implementation to use.',
default='VersionTrackingDiff', choices=engines.keys())

parser.add_argument('-o', '--output-path', help='Output path for resulting diffs', default='.ghidriffs')
parser.add_argument('-o', '--output-path', help='Output path for resulting diffs', default='ghidriffs')
parser.add_argument('--summary', help='Add a summary diff if more than two bins are provided', default=False)

return parser


def main():
"""
ghidriff - GhidraDiffEngine module main function
"""

parser = get_parser()

GhidraDiffEngine.add_ghidra_args_to_parser(parser)

args = parser.parse_args()
Expand All @@ -61,6 +70,7 @@ def main():

project_name = f'{args.project_name}-{binary_paths[0].name}-{binary_paths[-1].name}'

engines = get_engine_classes()
DiffEngine: GhidraDiffEngine = engines[args.engine]

d: GhidraDiffEngine = DiffEngine(args=args,
Expand Down
18 changes: 15 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name = ghidriff
author = clearbluejar
author_email = [email protected]
version = attr:ghidriff.__version__
description = A binary diffing engine leveraging Ghidra and its FlatProgramAPI
description = Ghidra Binary Diffing Engine
long_description_content_type = text/markdown
long_description = file:README.md
license = GPL-3.0 license
license_files =
LICENSE
url = https://github.com/clearbluejar/ghidriff
keywords = patchdiff, binaries, bindiff, ghidra
keywords = patchdiff, binaries, bindiff, ghidra, ghidriff
platform = any
classifiers =
Development Status :: 3 - Alpha
Expand All @@ -35,7 +35,19 @@ install_requires =
console_scripts =
ghidriff = ghidriff.__main__:main

[options.extras_require]
testing =
pytest
requests
pytest-datadir

[tool:pytest]
testpaths = tests
required_plugins =
pytest-datadir

addopts =
-p no:faulthandler
-p no:faulthandler

[pycodestyle]
max_line_length = 130

0 comments on commit 6f3f98c

Please sign in to comment.