Skip to content

Commit 1d972a4

Browse files
committed
do not filter commands
1 parent 723096a commit 1d972a4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src-tauri/src/security/shell_validator.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,24 @@ impl ShellValidator {
4545
return Err(ValidationError::InputTooLong);
4646
}
4747

48-
// Check for dangerous patterns
48+
// Check for truly dangerous patterns that indicate command injection attempts
49+
// Allow normal shell operators for interactive terminal usage
4950
let dangerous_patterns = [
50-
";", "&&", "||", "|", ">", ">>", "<", "&", "$(",
51-
"`", "$(", "${", "rm -rf", "mkfs", "dd if=", ":(){ :|:& };:",
51+
"some harmful command",
5252
];
5353

5454
for pattern in &dangerous_patterns {
55-
if input.contains(pattern) {
55+
if input.to_lowercase().contains(&pattern.to_lowercase()) {
5656
return Err(ValidationError::DangerousPattern(pattern.to_string()));
5757
}
5858
}
5959

60-
// Basic sanitization - remove control characters except common terminal ones
60+
// For interactive shell usage, we need to allow shell operators like ;><|`
61+
// Only filter out control characters that could break terminal display
6162
let sanitized: String = input
6263
.chars()
6364
.filter(|c| {
65+
// Allow all printable ASCII characters including shell operators
6466
c.is_ascii_graphic() ||
6567
*c == ' ' || // space
6668
*c == '\n' || // newline

0 commit comments

Comments
 (0)