Skip to content
Closed
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
2 changes: 1 addition & 1 deletion crates/aster-policy/src/rule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl Rule {
// also match `rmdir`.
Match::CommandPrefix(prefix) => match line.strip_prefix(prefix.as_str()) {
Some("") => true,
Some(rest) => rest.starts_with(char::is_whitespace),
Some(rest) => !rest.starts_with(char::is_whitespace),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

CommandPrefix match condition inverted, bypassing prefix rules — critical/security · 98% confident

The rule meant to catch commands starting with rm ignores a real rm -rf / command, so dangerous commands can slip through, while it also flags unrelated commands like rmdir.

Fix: Revert the negation: Some(rest) => rest.starts_with(char::is_whitespace), so a prefix only matches when followed by whitespace (or end-of-string via the Some("") arm).

None => false,
},
Match::Path(_) => false,
Expand Down
Loading