Commit 734e5f75 by Enkelmann

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

parent 730bc805
......@@ -2,4 +2,5 @@
docker run --rm -t cwe-checker make codestyle-check \
&& docker run --rm -t cwe-checker cargo test \
&& 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]
members = ["cwe_checker_rs", "caller"]
members = ["cwe_checker_rs", "caller", "test"]
......@@ -24,10 +24,15 @@ endif
test:
cargo test
ifeq (,$(wildcard ${HOME}/.config/cwe_checker/ghidra.json))
cd test/unit/ && ./specify_test_files_for_compilation.sh
dune runtest
cd test/artificial_samples; scons; cd ../..
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:
cargo fmt -- --check
......
......@@ -197,20 +197,17 @@ fn get_project_from_ghidra(file_path: &Path) -> Project {
.unwrap()
.as_millis()
);
let output_filename = format!(
"{}_{}.json",
file_path
.file_name()
.expect("Invalid file name")
.to_string_lossy(),
timestamp_suffix
);
let filename = file_path
.file_name()
.expect("Invalid file name")
.to_string_lossy();
let output_filename = format!("{}_{}.json", filename, timestamp_suffix);
let output_path = tmp_folder.join(output_filename);
let ghidra_plugin_path = get_ghidra_plugin_path("p_code_extractor");
// Execute Ghidra
let output = Command::new(&headless_path)
.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(file_path) // File import path
.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