Skip to content

Commit

Permalink
Fix circular dependencies by making ofrak_angr and ofrak_capstone
Browse files Browse the repository at this point in the history
… optional for `ofrak_core` tests

Fixes redballoonsecurity#420
  • Loading branch information
ANogin committed Jan 14, 2025
1 parent 829f1de commit ac02665
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 52 deletions.
44 changes: 6 additions & 38 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ jobs:
cd frontend
make check
ofrak-ghidra:
name: Test main OFRAK components
ofrak-dev:
name: Test all OFRAK components
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
Expand All @@ -62,11 +62,11 @@ jobs:
python-version: '3.7'
cache: pip
cache-dependency-path: '**/setup.py'
- name: Build Ghidra image
- name: Build Dev image
run: |
python3 -m pip install PyYAML
python3 build_image.py \
--config ofrak-ghidra.yml \
--config ofrak-dev.yml \
--base \
--finish \
--cache-from redballoonsecurity/ofrak/core-dev-base:latest
Expand All @@ -77,7 +77,7 @@ jobs:
--rm \
--entrypoint bash \
--volume "$(pwd)":/ofrak \
redballoonsecurity/ofrak/ghidra:latest \
redballoonsecurity/ofrak/dev:latest \
-c "cd /ofrak \
&& mkdocs build --site-dir /tmp/docs"
- name: Test components
Expand All @@ -86,43 +86,11 @@ jobs:
--interactive \
--rm \
--entrypoint bash \
redballoonsecurity/ofrak/ghidra:latest \
redballoonsecurity/ofrak/dev:latest \
-c "python -m ofrak_ghidra.server start \
&& ofrak license --community --i-agree \
&& make test"
ofrak-angr:
name: Test OFRAK angr and capstone components
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
lfs: true
- uses: actions/setup-python@v4
with:
python-version: '3.7'
cache: pip
cache-dependency-path: '**/setup.py'
- name: Build angr image
run: |
python3 -m pip install PyYAML
python3 build_image.py \
--config ofrak-angr.yml \
--base \
--finish \
--cache-from redballoonsecurity/ofrak/core-dev-base:latest
- name: Test components
run: |
docker run \
--interactive \
--rm \
--entrypoint bash \
--volume "$(pwd)":/ofrak \
redballoonsecurity/ofrak/angr:latest \
-c "ofrak license --community --i-agree \
&& make -C /ofrak_angr test \
&& make -C /ofrak_capstone test"
ofrak-tutorial:
name: Test OFRAK examples and tutorial notebooks
runs-on: ubuntu-22.04
Expand Down
12 changes: 1 addition & 11 deletions ofrak_core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,7 @@ def read_requirements(requirements_path):
+ read_requirements("requirements.txt"),
extras_require={
"docs": read_requirements("requirements-docs.txt"),
"test": [
"importlib-resources", # Needed because of https://github.com/redballoonsecurity/ofrak/issues/398
"ofrak_angr~=1.0",
# Running the tests requires this version of capstone.
# If building a Docker image, it should already be installed on the system.
# If you are running the tests in another environment, you will need to make sure
# that this version is installed from GitHub, since it depends on ofrak==3.3.0rc0
# and neither of these are yet released on PyPI.
# "ofrak_capstone>=1.1.0rc0",
]
+ read_requirements("requirements-test.txt"),
"test": read_requirements("requirements-test.txt"),
"non-pypi": read_requirements("requirements-non-pypi.txt"),
},
author="Red Balloon Security",
Expand Down
4 changes: 2 additions & 2 deletions ofrak_core/test_ofrak/components/test_patch_from_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from ofrak_patch_maker.toolchain.llvm_12 import LLVM_12_0_1_Toolchain

import ofrak_angr
import ofrak_capstone
ofrak_angr = pytest.importorskip("ofrak_angr")
ofrak_capstone = pytest.importorskip("ofrak_capstone")
from ofrak import OFRAKContext, Resource, ResourceAttributeValueFilter, ResourceFilter
from ofrak.core import (
Allocatable,
Expand Down
2 changes: 1 addition & 1 deletion ofrak_core/test_ofrak/components/test_symbolic_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest

import ofrak_angr
ofrak_angr = pytest.importorskip("ofrak_angr")
from ofrak import OFRAKContext, Resource, ResourceFilter
from ofrak.core import (
ElfSymbolType,
Expand Down

0 comments on commit ac02665

Please sign in to comment.