Skip to content

Commit

Permalink
fix test data git clone
Browse files Browse the repository at this point in the history
  • Loading branch information
clearbluejar committed Sep 10, 2023
1 parent 41f19cd commit 52a89f7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
13 changes: 11 additions & 2 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,17 @@ fi
# install local workspace and test requirements
pip install -e ".[testing]"

# pull down test data
git clone [email protected]:clearbluejar/ghidriff-test-data.git tests/data
# git clone test data if dir doesn't exist
TEST_DATA_PATH="tests/data"

if [ -z "$(ls -A $TEST_DATA_PATH)" ]; then
git clone https://github.com/clearbluejar/ghidriff-test-data.git tests/data
pushd $TEST_DATA_PATH
git remote set-url origin [email protected]:clearbluejar/ghidriff-test-data.git
popd
fi



# Setup Ghidra Dev for Reference
# git clone https://github.com/NationalSecurityAgency/ghidra.git ~/ghidra-master
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/pytest-devcontainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ jobs:
push: never
runCmd: |
pip install --upgrade pip
# install package and testing
pip install -e ".[testing]"
# download data to shared data
git clone git@github.com:clearbluejar/ghidriff-test-data.git tests/data
# download data to shared test data
git clone https://github.com/clearbluejar/ghidriff-test-data.git tests/data
pytest -rA
31 changes: 21 additions & 10 deletions tests/test_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import json
import os

SYMBOLS_DIR = 'symbols'
BINS_DIR = 'bins'

def get_chrome_headers() -> dict:

headers = {
Expand Down Expand Up @@ -37,19 +40,27 @@ def test_diff_afd_cve_2023_21768(shared_datadir: Path):
test_name = 'cve-2023-21768'
output_path = shared_datadir / test_name
output_path.mkdir(exist_ok=True, parents=True)
symbols_path = shared_datadir / SYMBOLS_DIR
bins_path = shared_datadir / BINS_DIR


# setup bins
old_bin_path = shared_datadir / 'afd.sys.x64.10.0.22621.1028'
old_url = 'https://msdl.microsoft.com/download/symbols/afd.sys/0C5C6994A8000/afd.sys'
new_bin_path = shared_datadir / 'afd.sys.x64.10.0.22621.1415'
new_url = 'https://msdl.microsoft.com/download/symbols/afd.sys/50989142A9000/afd.sys'

old_bin_path = bins_path / 'afd.sys.x64.10.0.22621.1028'
new_bin_path = bins_path / 'afd.sys.x64.10.0.22621.1415'

# TODO figure out why these download are unreliable
# for now just git clone ghidriff-test-data
# old_bin_path = shared_datadir / 'afd.sys.x64.10.0.22621.1028'
# old_url = 'https://msdl.microsoft.com/download/symbols/afd.sys/0C5C6994A8000/afd.sys'
# new_bin_path = shared_datadir / 'afd.sys.x64.10.0.22621.1415'
# new_url = 'https://msdl.microsoft.com/download/symbols/afd.sys/50989142A9000/afd.sys'

# download binaries
# TODO this download can fail, store in repo?
headers = get_chrome_headers()
old_bin_path.write_bytes(requests.get(old_url,headers=headers).content)
new_bin_path.write_bytes(requests.get(new_url,headers=headers).content)
# download is unreliage
# headers = get_chrome_headers()
# old_bin_path.write_bytes(requests.get(old_url,headers=headers).content)
# new_bin_path.write_bytes(requests.get(new_url,headers=headers).content)

assert old_bin_path.exists()
assert new_bin_path.exists()
Expand All @@ -58,7 +69,7 @@ def test_diff_afd_cve_2023_21768(shared_datadir: Path):

GhidraDiffEngine.add_ghidra_args_to_parser(parser)

args = parser.parse_args([str(old_bin_path.absolute()),str(new_bin_path.absolute())])
args = parser.parse_args(['-s', str(symbols_path), str(old_bin_path.absolute()),str(new_bin_path.absolute())])

engine_log_path = output_path / parser.get_default('log_path')

Expand Down Expand Up @@ -87,7 +98,7 @@ def test_diff_afd_cve_2023_21768(shared_datadir: Path):
no_symbols=args.no_symbols,
engine_log_path=engine_log_path,
engine_log_level=args.log_level,
engine_file_log_level=args.file_log_level
engine_file_log_level=args.file_log_level,
)

d.setup_project(binary_paths, args.project_location, project_name, args.symbols_path)
Expand Down

0 comments on commit 52a89f7

Please sign in to comment.