Commit 734e5f75 by Enkelmann

add Ghidra-based acceptance checks to CI pipeline (#91)

parent 730bc805
...@@ -2,4 +2,5 @@ ...@@ -2,4 +2,5 @@
docker run --rm -t cwe-checker make codestyle-check \ docker run --rm -t cwe-checker make codestyle-check \
&& docker run --rm -t cwe-checker cargo test \ && docker run --rm -t cwe-checker cargo test \
&& docker run --rm -t cwe-checker dune runtest \ && docker run --rm -t cwe-checker dune runtest \
&& pytest && pytest \
&& docker run --rm -t cwe-checker-ghidra cargo test --no-fail-fast -p acceptance_tests_ghidra -- --show-output --ignored --test-threads 1
[workspace] [workspace]
members = ["cwe_checker_rs", "caller"] members = ["cwe_checker_rs", "caller", "test"]
...@@ -24,10 +24,15 @@ endif ...@@ -24,10 +24,15 @@ endif
test: test:
cargo test cargo test
ifeq (,$(wildcard ${HOME}/.config/cwe_checker/ghidra.json))
cd test/unit/ && ./specify_test_files_for_compilation.sh cd test/unit/ && ./specify_test_files_for_compilation.sh
dune runtest dune runtest
cd test/artificial_samples; scons; cd ../.. cd test/artificial_samples; scons; cd ../..
pytest -v --ignore=_build pytest -v --ignore=_build
else
cd test/artificial_samples; scons; cd ../..
cargo test --no-fail-fast -p acceptance_tests_ghidra -- --show-output --ignored
endif
codestyle-check: codestyle-check:
cargo fmt -- --check cargo fmt -- --check
......
...@@ -197,20 +197,17 @@ fn get_project_from_ghidra(file_path: &Path) -> Project { ...@@ -197,20 +197,17 @@ fn get_project_from_ghidra(file_path: &Path) -> Project {
.unwrap() .unwrap()
.as_millis() .as_millis()
); );
let output_filename = format!( let filename = file_path
"{}_{}.json", .file_name()
file_path .expect("Invalid file name")
.file_name() .to_string_lossy();
.expect("Invalid file name") let output_filename = format!("{}_{}.json", filename, timestamp_suffix);
.to_string_lossy(),
timestamp_suffix
);
let output_path = tmp_folder.join(output_filename); let output_path = tmp_folder.join(output_filename);
let ghidra_plugin_path = get_ghidra_plugin_path("p_code_extractor"); let ghidra_plugin_path = get_ghidra_plugin_path("p_code_extractor");
// Execute Ghidra // Execute Ghidra
let output = Command::new(&headless_path) let output = Command::new(&headless_path)
.arg(&tmp_folder) // The folder where temporary files should be stored .arg(&tmp_folder) // The folder where temporary files should be stored
.arg(format!("PcodeExtractor_{}", timestamp_suffix)) // The name of the temporary Ghidra Project. .arg(format!("PcodeExtractor_{}_{}", filename, timestamp_suffix)) // The name of the temporary Ghidra Project.
.arg("-import") // Import a file into the Ghidra project .arg("-import") // Import a file into the Ghidra project
.arg(file_path) // File import path .arg(file_path) // File import path
.arg("-postScript") // Execute a script after standard analysis by Ghidra finished .arg("-postScript") // Execute a script after standard analysis by Ghidra finished
......
[package]
name = "acceptance_tests_ghidra"
version = "0.1.0"
authors = ["Enkelmann <nils-edvin.enkelmann@fkie.fraunhofer.de>"]
edition = "2018"
[dependencies]
colored = "2.0"
This diff is collapsed. Click to expand it.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment