From 6f3f98c9e3e117bedd073b676d3be08818408af5 Mon Sep 17 00:00:00 2001 From: clearbluejar <3752074+clearbluejar@users.noreply.github.com> Date: Sat, 9 Sep 2023 22:15:19 +0000 Subject: [PATCH] move get_parser, bump ver, add testing in setup.cfg --- ghidriff/__init__.py | 5 +++-- ghidriff/__main__.py | 20 +++++++++++++++----- setup.cfg | 18 +++++++++++++++--- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/ghidriff/__init__.py b/ghidriff/__init__.py index efd6bd6..de029cc 100644 --- a/ghidriff/__init__.py +++ b/ghidriff/__init__.py @@ -1,4 +1,4 @@ -__version__ = '0.3.0' +__version__ = '0.4.0' __author__ = 'clearbluejar' # Expose API @@ -6,7 +6,8 @@ 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" ] diff --git a/ghidriff/__main__.py b/ghidriff/__main__.py index db0e823..3a95674 100644 --- a/ghidriff/__main__.py +++ b/ghidriff/__main__.py @@ -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='+', @@ -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() @@ -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, diff --git a/setup.cfg b/setup.cfg index fdaf9e2..cde2b5b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,14 +3,14 @@ name = ghidriff author = clearbluejar author_email = clearbluejar@clearbluejar.com 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 @@ -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 \ No newline at end of file + -p no:faulthandler + +[pycodestyle] +max_line_length = 130 \ No newline at end of file