diff --git a/disassemblers/ofrak_angr/Makefile b/disassemblers/ofrak_angr/Makefile index 97482e4b5..f7da7aa5e 100644 --- a/disassemblers/ofrak_angr/Makefile +++ b/disassemblers/ofrak_angr/Makefile @@ -17,6 +17,3 @@ inspect: test: inspect $(PYTHON) -m pytest -n auto --cov=ofrak_angr ofrak_angr_test fun-coverage --cov-fail-under=100 - -.PHONY: dependencies -dependencies: diff --git a/disassemblers/ofrak_binary_ninja/Makefile b/disassemblers/ofrak_binary_ninja/Makefile index b6b0fba9d..dd2052fa1 100644 --- a/disassemblers/ofrak_binary_ninja/Makefile +++ b/disassemblers/ofrak_binary_ninja/Makefile @@ -17,8 +17,3 @@ inspect: test: inspect $(PYTHON) -m pytest --cov=ofrak_binary_ninja --cov-report=term-missing ofrak_binary_ninja_test fun-coverage --cov-fail-under=100 - -.PHONY: dependencies -dependencies: - test -f license.dat - chmod +x ./install_binary_ninja_headless_linux.sh diff --git a/disassemblers/ofrak_capstone/Makefile b/disassemblers/ofrak_capstone/Makefile index 2af971dc8..71746f688 100644 --- a/disassemblers/ofrak_capstone/Makefile +++ b/disassemblers/ofrak_capstone/Makefile @@ -17,6 +17,3 @@ inspect: test: inspect $(PYTHON) -m pytest ofrak_capstone_test --cov=ofrak_capstone --cov-report=term-missing fun-coverage --cov-fail-under=100 - -.PHONY: dependencies -dependencies: diff --git a/disassemblers/ofrak_ghidra/Makefile b/disassemblers/ofrak_ghidra/Makefile index ebd7b4f35..c4a4f96bd 100644 --- a/disassemblers/ofrak_ghidra/Makefile +++ b/disassemblers/ofrak_ghidra/Makefile @@ -10,5 +10,3 @@ develop: test: $(PYTHON) -m pytest --cov=ofrak_ghidra --cov-report=term-missing ofrak_ghidra_test fun-coverage --cov-fail-under=100 - -dependencies: diff --git a/docs/contributor-guide/getting-started.md b/docs/contributor-guide/getting-started.md index 474a18d05..613141167 100644 --- a/docs/contributor-guide/getting-started.md +++ b/docs/contributor-guide/getting-started.md @@ -137,10 +137,45 @@ ofrak_package_x |--setup.py |--ofrak_package_x_python_module |... + |--ofrak_package_x_python_module_test + |... ``` -`Makefile` must contain a rule `dependencies`. This rule should take care of any setup that needs to be done for that package before the Docker build. +### Makefile +At a minimum, an OFRAK package Makefile should contain the following targets: + +- `install`: a phony target that installs the package +- `develop`: a phony target that installs the package in editable mode (for development) +- `inspect`: a phony target that runs static code analysis on the package +- `test`: a phony target that: + - has a dependency on `inspect` + - runs the packages tests, recording "term-missing" coverage information + - uses [fun-coverage](https://pypi.org/project/fun-coverage/) to assert that the package has 100% function coverage + +An example of such a Makefile for `ofrak_package_x` is: +```make +PYTHON=python3 +PIP=pip3 + +.PHONY: install +install: + $(PIP) install . + +.PHONY: develop +develop: + $(PIP) install -e .[test] + +.PHONY: inspect +inspect: + mypy + +.PHONY: test +test: inspect + $(PYTHON) -m pytest -n auto --cov=ofrak_package_x_python_module --cov-report=term-missing --cov-fail-under=100 ofrak_package_x_python_module_test + fun-coverage --cov-fail-under=100 +``` +### Dockerstub & Dockerstage `Dockerstub` should read as a normal Dockerfile, only without a base image specified at the top. This file should contain all of the steps necessary to install this package in a Docker image. During build, all packages' `Dockerstub`s will be concatenated, so specifying a base image is unnecessary. Also, any specified entrypoint may be overridden. The build relies on the following assumptions: @@ -149,6 +184,17 @@ The build relies on the following assumptions: - All rules in `Makefile` should assume the working directory is `ofrak_package_x` (but at a different path as explained above) - `Dockerstub` and `Dockerstage` should be written assuming the build context is the parent directory of `ofrak_package_x`. Do not assume anything is present in the build context besides the contents of `ofrak_package_x` and what `Makefile` adds to `ofrak_package_x` in the `dependencies` rule. +## Static Code Analysis +The repository has several automated static code anaysis workflows. + +1. [Pre-commit](#pre-commit) is used, both as a pre-commit hook and as a CI/CD workflow, to ensure repository-wide: + 1. [PEP8 compliance](#pep-8) (this is done using [black](#black)). + 1. No Python modules contain unused imports. + 1. Files are either empty or end with a newline. +1. Each package contains an `inspect` target responsible for static code analysis for that package. + 1. As part of this, [MyPy](#type-annotations-and-mypy) is used to perform static type checking. + +
diff --git a/ofrak_core/Makefile b/ofrak_core/Makefile index 0276517ae..8c1b8996c 100644 --- a/ofrak_core/Makefile +++ b/ofrak_core/Makefile @@ -18,9 +18,6 @@ test: inspect $(PYTHON) -m pytest -n auto test_ofrak --cov=ofrak --cov-report=term-missing fun-coverage --cov-fail-under=100 -.PHONY: dependencies -dependencies: - ofrak/gui/public: if [ -d /ofrak_gui ] ; then \ cp -r /ofrak_gui ofrak/gui/public ; \ diff --git a/ofrak_io/Makefile b/ofrak_io/Makefile index 314389017..0f5724824 100644 --- a/ofrak_io/Makefile +++ b/ofrak_io/Makefile @@ -17,9 +17,3 @@ inspect: test: inspect $(PYTHON) -m pytest -n auto --cov=ofrak_io --cov-report=term-missing --cov-fail-under=100 ofrak_io_test fun-coverage --cov-fail-under=100 - -.PHONY: dependencies -dependencies: ; - -.PHONY: clean -clean: ; diff --git a/ofrak_patch_maker/Makefile b/ofrak_patch_maker/Makefile index b76c197ba..3b85f9017 100644 --- a/ofrak_patch_maker/Makefile +++ b/ofrak_patch_maker/Makefile @@ -25,9 +25,3 @@ inspect: test: inspect $(PYTHON) -m pytest -n auto --cov=ofrak_patch_maker --cov-report=term-missing ofrak_patch_maker_test fun-coverage --cov-fail-under=100 - -.PHONY: dependencies -dependencies: - -clean: - -rm -rf lib diff --git a/ofrak_type/Makefile b/ofrak_type/Makefile index 5bbb7c03f..2272aa437 100644 --- a/ofrak_type/Makefile +++ b/ofrak_type/Makefile @@ -17,9 +17,3 @@ inspect: test: inspect $(PYTHON) -m pytest -n auto --cov=ofrak_type --cov-report=term-missing --cov-fail-under=100 ofrak_type_test fun-coverage --cov-fail-under=100 - -.PHONY: dependencies -dependencies: ; - -.PHONY: clean -clean: ;