-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
* text eol=lf | ||
*.md text eol=lf | ||
*.png binary | ||
*.png binary | ||
*.bin binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
mod common; | ||
|
||
#[test] | ||
fn pdf_integration() { | ||
const SIGNATURE_TYPE: &str = "arcadyan"; | ||
const INPUT_FILE_NAME: &str = "arcadyan.bin"; | ||
let _ = common::integration_test(SIGNATURE_TYPE, INPUT_FILE_NAME); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use binwalk::{AnalysisResults, Binwalk}; | ||
|
||
pub fn integration_test(signature_filter: &str, file_name: &str) -> AnalysisResults { | ||
// Build the path to the input file | ||
let file_path = std::path::Path::new("tests") | ||
.join("inputs") | ||
.join(file_name) | ||
.display() | ||
.to_string(); | ||
|
||
// Build the path to the output directory | ||
let output_directory = std::path::Path::new(&std::env::temp_dir().display().to_string()) | ||
.join("binwalk_integration_test_extractions") | ||
.display() | ||
.to_string(); | ||
|
||
// Delete the output directory, if it exists | ||
let _ = std::fs::remove_dir_all(&output_directory); | ||
|
||
// Configure binwalk | ||
let binwalker = Binwalk::configure( | ||
Some(file_path), | ||
Some(output_directory.clone()), | ||
Some(vec![signature_filter.to_string()]), | ||
None, | ||
None, | ||
false, | ||
) | ||
.expect("Binwalk initialization failed"); | ||
|
||
// Run analysis | ||
let results = binwalker.analyze(&binwalker.base_target_file, true); | ||
|
||
// Each test is expected to have a single result at offset 0 in the file | ||
assert!(results.file_map.len() == 1); | ||
assert!(results.file_map[0].offset == 0); | ||
|
||
// Tests which support extraction are expected to have a single successful extraction | ||
if !results.extractions.is_empty() { | ||
assert!(results.extractions.len() == 1); | ||
assert!(results.extractions[&results.file_map[0].id].success); | ||
} | ||
|
||
// Clean up the output directory | ||
let _ = std::fs::remove_dir_all(output_directory); | ||
|
||
results | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
mod common; | ||
|
||
#[test] | ||
fn gzip_integration() { | ||
const SIGNATURE_TYPE: &str = "gzip"; | ||
const INPUT_FILE_NAME: &str = "gzip.bin"; | ||
let _ = common::integration_test(SIGNATURE_TYPE, INPUT_FILE_NAME); | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
mod common; | ||
|
||
#[test] | ||
fn pdf_integration() { | ||
const SIGNATURE_TYPE: &str = "pdf"; | ||
const INPUT_FILE_NAME: &str = "pdf.bin"; | ||
let _ = common::integration_test(SIGNATURE_TYPE, INPUT_FILE_NAME); | ||
} |