mirror of
https://github.com/vee1e/flare-floss.git
synced 2026-09-01 17:57:06 +00:00
55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
# Copyright (C) 2022 Mandiant, Inc. All Rights Reserved.
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at: [package root]/LICENSE.txt
|
|
# Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and limitations under the License.
|
|
|
|
import os
|
|
import sys
|
|
import subprocess
|
|
from functools import lru_cache
|
|
|
|
import pytest
|
|
|
|
CD = os.path.dirname(__file__)
|
|
|
|
|
|
def get_script_path(s):
|
|
return os.path.join(CD, "..", "scripts", s)
|
|
|
|
|
|
def get_file_path():
|
|
return os.path.join(CD, "data", "test-decode-to-stack.exe")
|
|
|
|
|
|
def run_program(script_path, args):
|
|
args = [sys.executable] + [script_path] + args
|
|
print("running: '%s'" % args)
|
|
return subprocess.run(args, capture_output=True)
|
|
|
|
|
|
@lru_cache()
|
|
def get_results_file_path():
|
|
res_path = "results.json"
|
|
p = run_program("floss/main.py", ["--no", "static", "-j", get_file_path()])
|
|
with open(res_path, "w") as f:
|
|
f.write(p.stdout.decode("utf-8"))
|
|
return res_path
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"script,args",
|
|
[
|
|
pytest.param("render-binja-import-script.py", [get_results_file_path()]),
|
|
pytest.param("render-ghidra-import-script.py", [get_results_file_path()]),
|
|
pytest.param("render-ida-import-script.py", [get_results_file_path()]),
|
|
pytest.param("render-r2-import-script.py", [get_results_file_path()]),
|
|
pytest.param("render-x64dbg-database.py", [get_results_file_path()]),
|
|
],
|
|
)
|
|
def test_scripts(script, args):
|
|
script_path = get_script_path(script)
|
|
p = run_program(script_path, args)
|
|
assert p.returncode == 0
|