Skip to content

Commit

Permalink
fix(matchers): fixed windash modifier #1392
Browse files Browse the repository at this point in the history
  • Loading branch information
hitenkoku committed Aug 10, 2024
1 parent bb3bb6e commit 090e153
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/detections/rule/matchers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,12 +618,32 @@ impl LeafMatcher for DefaultMatcher {
FastMatch::StartsWith(s) => Self::starts_with_ignore_case(event_value_str, s),
FastMatch::EndsWith(s) => Self::ends_with_ignore_case(event_value_str, s),
FastMatch::Contains(s) | FastMatch::AllOnly(s) => {
Some(utils::contains_str(&event_value_str.to_lowercase(), s))
if self.pipes.contains(&PipeElement::Windash) {
Some(utils::contains_str(
&event_value_str
.replacen(['-', '–', '—', '―'], "/", 1)
.to_lowercase(),
s,
))
} else {
Some(utils::contains_str(&event_value_str.to_lowercase(), s))
}
}
}
} else {
Some(fast_matcher.iter().any(|fm| match fm {
FastMatch::Contains(s) => utils::contains_str(event_value_str, s),
FastMatch::Contains(s) => {
if self.pipes.contains(&PipeElement::Windash) {
utils::contains_str(
&event_value_str
.replacen(['-', '–', '—', '―'], "/", 1)
.to_lowercase(),
s,
)
} else {
utils::contains_str(event_value_str, s)
}
}
_ => false,
}))
};
Expand Down

0 comments on commit 090e153

Please sign in to comment.