Skip to main content

sys_shred/cli/
args.rs

1//! # CLI Argument Schema
2//!
3//! Defines the structured inputs for the `sys-shred` application using `clap`.
4//! This module ensures that all user inputs are validated and mapped to
5//! actionable internal configurations.
6
7use clap::{Parser, ValueEnum};
8use std::path::PathBuf;
9
10/// Standard algorithms for secure data erasure.
11#[derive(ValueEnum, Clone, Debug, serde::Serialize)]
12pub enum ShredMethod {
13    /// Overwrite with zero bytes (Fastest).
14    Zero,
15    /// Overwrite with cryptographically secure random bytes (Balanced).
16    Random,
17    /// US DoD 5220.22-M (3 passes: 0x00, 0xFF, Random).
18    Dod,
19    /// Gutmann method (35 passes - Extreme security for older magnetic media).
20    Gutmann,
21}
22
23/// Output formats for the audit log.
24#[derive(ValueEnum, Clone, Debug, Default)]
25pub enum AuditFormat {
26    /// Human-readable text format.
27    #[default]
28    Text,
29    /// Machine-readable JSON format.
30    Json,
31}
32
33/// Secure File Erasure Utility (Anti-Forensics)
34///
35/// `sys-shred` is a specialized tool designed to irreversibly destroy file data.
36/// It works by performing multiple cryptographic overwrite passes, randomizing
37/// file metadata (name and timestamps), and finally unlinking the file from
38/// the filesystem to prevent forensic recovery.
39#[derive(Parser, Debug)]
40#[command(
41    author = "V1lleneuve",
42    version = "1.1.1",
43    about = "Securely shreds files using cryptographic data and metadata obfuscation",
44    long_about = "A high-integrity secure deletion tool that bypasses OS file-system caching to ensure hardware-level data destruction."
45)]
46pub struct Args {
47    /// The absolute or relative path to the target file or directory.
48    #[arg(
49        value_name = "PATH",
50        help = "Path to the file or directory to be destroyed"
51    )]
52    pub path: PathBuf,
53
54    /// Number of overwrite passes to perform.
55    #[arg(
56        short,
57        long,
58        default_value_t = 3,
59        help = "Number of cryptographic overwrite passes (Ignored for DoD/Gutmann)"
60    )]
61    pub passes: u32,
62
63    /// Recursively shred directories and their contents.
64    #[arg(
65        short,
66        long,
67        help = "Recursively destroy directories and their contents"
68    )]
69    pub recursive: bool,
70
71    /// Algorithm to use for data destruction.
72    #[arg(
73        short,
74        long,
75        value_enum,
76        default_value_t = ShredMethod::Random,
77        help = "Erasure method to utilize"
78    )]
79    pub method: ShredMethod,
80
81    /// Perform a trial run without modifying the filesystem.
82    #[arg(
83        long,
84        help = "Show what would be destroyed without performing actual deletion"
85    )]
86    pub dry_run: bool,
87
88    /// Verify overwrites by reading back data after writing.
89    #[arg(long, help = "Enable read-back verification after each overwrite pass")]
90    pub verify: bool,
91
92    /// Exclude files matching specific glob patterns.
93    #[arg(
94        short,
95        long,
96        help = "Exclude files matching patterns (e.g. *.log, secret/*)"
97    )]
98    pub exclude: Vec<String>,
99
100    /// informs the SSD to discard the blocks used by the file (TRIM).
101    #[arg(
102        long,
103        help = "Send a TRIM/Discard command to the SSD after shredding (Linux/Windows only)"
104    )]
105    pub trim: bool,
106
107    /// Force destruction without interactive confirmation.
108    #[arg(short, long, help = "Skip interactive confirmation prompts")]
109    pub force: bool,
110
111    /// Path to save the forensic audit log.
112
113    #[arg(
114        long,
115        value_name = "LOG_PATH",
116        help = "Path to generate a forensic audit report"
117    )]
118    pub audit_log: Option<PathBuf>,
119
120    /// Format of the forensic audit log.
121    #[arg(
122        long,
123        value_enum,
124        default_value_t = AuditFormat::Text,
125        help = "Format of the audit report (text or json)"
126    )]
127    pub audit_format: AuditFormat,
128
129    /// Enable verbose logging for granular visibility into the shredding process.
130    #[arg(short, long, help = "Enable detailed debug output")]
131    pub verbose: bool,
132
133    /// Obfuscate and truncate the file but skip the final unlinking (deletion).
134    #[arg(
135        long,
136        help = "Perform overwriting and obfuscation but do not delete the final file"
137    )]
138    pub keep: bool,
139}