Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ ipnetwork = "0.20"
default-net = "0.22"
directories = "6"
pcap = "2"
openssl = "0.10"
9 changes: 9 additions & 0 deletions src-tauri/config/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ prefer_rust_implementation = true
[paths]
pcap_output_dir = "captured"
pcap_filename = "arper.pcap"

[binary]
max_read_bytes = 1048576
hex_dump_bytes = 4096
decoded_text_max_chars = 16384
max_strings = 200
min_string_len = 4
magic_bytes_len = 16
max_flag_candidates = 50
17 changes: 15 additions & 2 deletions src-tauri/src/commands/binary.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
use serde::Serialize;

use crate::error::AppError;
use crate::AppState;

#[derive(Debug, Serialize, Clone)]
pub struct BinaryContent {
pub hex_dump: String,
pub decoded_text: String,
pub file_size: u64,
pub file_name: String,
pub magic_bytes: String,
pub file_type_guess: String,
pub sha256: String,
pub sha1: String,
pub md5: String,
pub printable_strings: Vec<String>,
pub flag_candidates: Vec<String>,
pub entropy: f64,
pub warnings: Vec<String>,
}

#[tauri::command]
pub async fn read_binary_file(file_path: String) -> Result<BinaryContent, AppError> {
crate::utils::binary::read_file(&file_path)
pub async fn read_binary_file(
state: tauri::State<'_, AppState>,
file_path: String,
) -> Result<BinaryContent, AppError> {
crate::utils::binary::read_file(&file_path, &state.config.binary)
}
28 changes: 28 additions & 0 deletions src-tauri/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ pub struct AppConfig {
pub network: NetworkConfig,
pub feature_flags: FeatureFlagsConfig,
pub paths: PathsConfig,
#[serde(default)]
pub binary: BinaryConfig,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve existing configs when adding binary defaults

When a user upgrades with an existing config/default.toml that predates this commit and therefore lacks [binary], this new required field makes toml::from_str in AppConfig::load fail; the app startup path then uses unwrap_or_default, so all of the user's customized scan/network/path settings are silently discarded. Add a serde/default fallback for binary (or merge with defaults) so older config files continue to load with only the new binary settings defaulted.

Useful? React with 👍 / 👎.

}

#[derive(Debug, Deserialize, Clone)]
Expand Down Expand Up @@ -52,6 +54,17 @@ pub struct PathsConfig {
pub pcap_filename: String,
}

#[derive(Debug, Deserialize, Clone)]
pub struct BinaryConfig {
pub max_read_bytes: usize,
pub hex_dump_bytes: usize,
pub decoded_text_max_chars: usize,
pub max_strings: usize,
pub min_string_len: usize,
pub magic_bytes_len: usize,
pub max_flag_candidates: usize,
}

impl AppConfig {
pub fn load() -> Result<Self, Box<dyn std::error::Error>> {
let config_path = Self::config_path();
Expand Down Expand Up @@ -107,6 +120,21 @@ impl Default for AppConfig {
pcap_output_dir: "captured".to_string(),
pcap_filename: "arper.pcap".to_string(),
},
binary: BinaryConfig::default(),
}
}
}

impl Default for BinaryConfig {
fn default() -> Self {
Self {
max_read_bytes: 1_048_576,
hex_dump_bytes: 4_096,
decoded_text_max_chars: 16_384,
max_strings: 200,
min_string_len: 4,
magic_bytes_len: 16,
max_flag_candidates: 50,
}
}
}
Loading
Loading