Skip to content

Commit

Permalink
Added extractor definition tests for m-z
Browse files Browse the repository at this point in the history
  • Loading branch information
devttys0 committed Nov 1, 2024
1 parent eaf8780 commit 4b44587
Show file tree
Hide file tree
Showing 10 changed files with 212 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/extractors/tarball.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
use crate::extractors;

/// Describes how to run the tar utility to extract tarball archives
///
/// ```
/// use std::io::ErrorKind;
/// use std::process::Command;
/// use binwalk::extractors::common::ExtractorType;
/// use binwalk::extractors::tarball::tarball_extractor;
///
/// match tarball_extractor().utility {
/// ExtractorType::None => panic!("Invalid extractor type of None"),
/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func),
/// ExtractorType::External(cmd) => {
/// if let Err(e) = Command::new(&cmd).output() {
/// if e.kind() == ErrorKind::NotFound {
/// panic!("External extractor '{}' not found", cmd);
/// } else {
/// panic!("Failed to execute external extractor '{}': {}", cmd, e);
/// }
/// }
/// }
/// }
/// ```
pub fn tarball_extractor() -> extractors::common::Extractor {
extractors::common::Extractor {
utility: extractors::common::ExtractorType::External("tar".to_string()),
Expand Down
21 changes: 21 additions & 0 deletions src/extractors/trx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@ use crate::extractors::common::{Chroot, ExtractionResult, Extractor, ExtractorTy
use crate::structures::trx::parse_trx_header;

/// Defines the internal TRX extractor
///
/// ```
/// use std::io::ErrorKind;
/// use std::process::Command;
/// use binwalk::extractors::common::ExtractorType;
/// use binwalk::extractors::trx::trx_extractor;
///
/// match trx_extractor().utility {
/// ExtractorType::None => panic!("Invalid extractor type of None"),
/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func),
/// ExtractorType::External(cmd) => {
/// if let Err(e) = Command::new(&cmd).output() {
/// if e.kind() == ErrorKind::NotFound {
/// panic!("External extractor '{}' not found", cmd);
/// } else {
/// panic!("Failed to execute external extractor '{}': {}", cmd, e);
/// }
/// }
/// }
/// }
/// ```
pub fn trx_extractor() -> Extractor {
Extractor {
utility: ExtractorType::Internal(extract_trx_partitions),
Expand Down
21 changes: 21 additions & 0 deletions src/extractors/ubi.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
use crate::extractors;

/// Describes how to run the ubireader_extract_images utility to extract UBI images
///
/// ```
/// use std::io::ErrorKind;
/// use std::process::Command;
/// use binwalk::extractors::common::ExtractorType;
/// use binwalk::extractors::ubi::ubi_extractor;
///
/// match ubi_extractor().utility {
/// ExtractorType::None => panic!("Invalid extractor type of None"),
/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func),
/// ExtractorType::External(cmd) => {
/// if let Err(e) = Command::new(&cmd).output() {
/// if e.kind() == ErrorKind::NotFound {
/// panic!("External extractor '{}' not found", cmd);
/// } else {
/// panic!("Failed to execute external extractor '{}': {}", cmd, e);
/// }
/// }
/// }
/// }
/// ```
pub fn ubi_extractor() -> extractors::common::Extractor {
extractors::common::Extractor {
utility: extractors::common::ExtractorType::External(
Expand Down
23 changes: 22 additions & 1 deletion src/extractors/uefi.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
use crate::extractors;

/* Describes how to run the uefi-firmware-parser utility to extract UEFI images */
/// Describes how to run the uefi-firmware-parser utility to extract UEFI images
///
/// ```
/// use std::io::ErrorKind;
/// use std::process::Command;
/// use binwalk::extractors::common::ExtractorType;
/// use binwalk::extractors::uefi::uefi_extractor;
///
/// match uefi_extractor().utility {
/// ExtractorType::None => panic!("Invalid extractor type of None"),
/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func),
/// ExtractorType::External(cmd) => {
/// if let Err(e) = Command::new(&cmd).output() {
/// if e.kind() == ErrorKind::NotFound {
/// panic!("External extractor '{}' not found", cmd);
/// } else {
/// panic!("Failed to execute external extractor '{}': {}", cmd, e);
/// }
/// }
/// }
/// }
/// ```
pub fn uefi_extractor() -> extractors::common::Extractor {
extractors::common::Extractor {
utility: extractors::common::ExtractorType::External("uefi-firmware-parser".to_string()),
Expand Down
22 changes: 22 additions & 0 deletions src/extractors/uimage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@ use crate::common::crc32;
use crate::extractors::common::{Chroot, ExtractionResult, Extractor, ExtractorType};
use crate::structures::uimage::parse_uimage_header;

/// Describes the internal extractor for carving uImage files to disk
///
/// ```
/// use std::io::ErrorKind;
/// use std::process::Command;
/// use binwalk::extractors::common::ExtractorType;
/// use binwalk::extractors::uimage::uimage_extractor;
///
/// match uimage_extractor().utility {
/// ExtractorType::None => panic!("Invalid extractor type of None"),
/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func),
/// ExtractorType::External(cmd) => {
/// if let Err(e) = Command::new(&cmd).output() {
/// if e.kind() == ErrorKind::NotFound {
/// panic!("External extractor '{}' not found", cmd);
/// } else {
/// panic!("Failed to execute external extractor '{}': {}", cmd, e);
/// }
/// }
/// }
/// }
/// ```
pub fn uimage_extractor() -> Extractor {
Extractor {
utility: ExtractorType::Internal(extract_uimage),
Expand Down
21 changes: 21 additions & 0 deletions src/extractors/vxworks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@ use crate::structures::vxworks::{
use serde_json;

/// Describes the VxWorks symbol table extractor
///
/// ```
/// use std::io::ErrorKind;
/// use std::process::Command;
/// use binwalk::extractors::common::ExtractorType;
/// use binwalk::extractors::vxworks::vxworks_symtab_extractor;
///
/// match vxworks_symtab_extractor().utility {
/// ExtractorType::None => panic!("Invalid extractor type of None"),
/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func),
/// ExtractorType::External(cmd) => {
/// if let Err(e) = Command::new(&cmd).output() {
/// if e.kind() == ErrorKind::NotFound {
/// panic!("External extractor '{}' not found", cmd);
/// } else {
/// panic!("Failed to execute external extractor '{}': {}", cmd, e);
/// }
/// }
/// }
/// }
/// ```
pub fn vxworks_symtab_extractor() -> Extractor {
Extractor {
do_not_recurse: true,
Expand Down
21 changes: 21 additions & 0 deletions src/extractors/wince.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@ use crate::extractors::common::{Chroot, ExtractionResult, Extractor, ExtractorTy
use crate::structures::wince::{parse_wince_block_header, parse_wince_header};

/// Defines the internal extractor function for extracting Windows CE images
///
/// ```
/// use std::io::ErrorKind;
/// use std::process::Command;
/// use binwalk::extractors::common::ExtractorType;
/// use binwalk::extractors::wince::wince_extractor;
///
/// match wince_extractor().utility {
/// ExtractorType::None => panic!("Invalid extractor type of None"),
/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func),
/// ExtractorType::External(cmd) => {
/// if let Err(e) = Command::new(&cmd).output() {
/// if e.kind() == ErrorKind::NotFound {
/// panic!("External extractor '{}' not found", cmd);
/// } else {
/// panic!("Failed to execute external extractor '{}': {}", cmd, e);
/// }
/// }
/// }
/// }
/// ```
pub fn wince_extractor() -> Extractor {
Extractor {
utility: ExtractorType::Internal(wince_dump),
Expand Down
21 changes: 21 additions & 0 deletions src/extractors/yaffs2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
use crate::extractors;

/// Describes how to run the unyaffs utility to extract YAFFS2 file systems
///
/// ```
/// use std::io::ErrorKind;
/// use std::process::Command;
/// use binwalk::extractors::common::ExtractorType;
/// use binwalk::extractors::yaffs2::yaffs2_extractor;
///
/// match yaffs2_extractor().utility {
/// ExtractorType::None => panic!("Invalid extractor type of None"),
/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func),
/// ExtractorType::External(cmd) => {
/// if let Err(e) = Command::new(&cmd).output() {
/// if e.kind() == ErrorKind::NotFound {
/// panic!("External extractor '{}' not found", cmd);
/// } else {
/// panic!("Failed to execute external extractor '{}': {}", cmd, e);
/// }
/// }
/// }
/// }
/// ```
pub fn yaffs2_extractor() -> extractors::common::Extractor {
extractors::common::Extractor {
utility: extractors::common::ExtractorType::External("unyaffs".to_string()),
Expand Down
21 changes: 21 additions & 0 deletions src/extractors/zlib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ use crate::extractors::inflate;
pub const CHECKSUM_SIZE: usize = 4;

/// Defines the internal extractor function for decompressing zlib data
///
/// ```
/// use std::io::ErrorKind;
/// use std::process::Command;
/// use binwalk::extractors::common::ExtractorType;
/// use binwalk::extractors::zlib::zlib_extractor;
///
/// match zlib_extractor().utility {
/// ExtractorType::None => panic!("Invalid extractor type of None"),
/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func),
/// ExtractorType::External(cmd) => {
/// if let Err(e) = Command::new(&cmd).output() {
/// if e.kind() == ErrorKind::NotFound {
/// panic!("External extractor '{}' not found", cmd);
/// } else {
/// panic!("Failed to execute external extractor '{}': {}", cmd, e);
/// }
/// }
/// }
/// }
/// ```
pub fn zlib_extractor() -> Extractor {
Extractor {
utility: ExtractorType::Internal(zlib_decompress),
Expand Down
21 changes: 21 additions & 0 deletions src/extractors/zstd.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
use crate::extractors;

/// Describes how to run the zstd utility to extract ZSTD compressed files
///
/// ```
/// use std::io::ErrorKind;
/// use std::process::Command;
/// use binwalk::extractors::common::ExtractorType;
/// use binwalk::extractors::zstd::zstd_extractor;
///
/// match zstd_extractor().utility {
/// ExtractorType::None => panic!("Invalid extractor type of None"),
/// ExtractorType::Internal(func) => println!("Internal extractor OK: {:?}", func),
/// ExtractorType::External(cmd) => {
/// if let Err(e) = Command::new(&cmd).output() {
/// if e.kind() == ErrorKind::NotFound {
/// panic!("External extractor '{}' not found", cmd);
/// } else {
/// panic!("Failed to execute external extractor '{}': {}", cmd, e);
/// }
/// }
/// }
/// }
/// ```
pub fn zstd_extractor() -> extractors::common::Extractor {
extractors::common::Extractor {
utility: extractors::common::ExtractorType::External("zstd".to_string()),
Expand Down

0 comments on commit 4b44587

Please sign in to comment.