Skip to content

Commit

Permalink
docs: document track_pattern_match a bit better.
Browse files Browse the repository at this point in the history
  • Loading branch information
plusvic committed Sep 21, 2024
1 parent 65d3205 commit 0e998e4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/src/scanner/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,18 @@ impl ScanContext<'_> {
bits.set(rule_id.into(), true);
}

/// Called during the scan process when a pattern has matched for tracking
/// the matching patterns.
/// Called during the scan process when a pattern match has been found.
///
/// `pattern_id` is the ID of the matching pattern, `match_` contains
/// details about the match (range and xor key), and `replace_if_longer`
/// indicates whether existing matches for the same pattern at the same
/// offset should be replaced by the current match if the current is
/// longer.
pub(crate) fn track_pattern_match(
&mut self,
pattern_id: PatternId,
match_: Match,
replace: bool,
replace_if_longer: bool,
) {
let wasm_store = unsafe { self.wasm_store.as_mut() };
let mem = self.main_memory.unwrap().data_mut(wasm_store);
Expand All @@ -332,7 +337,7 @@ impl ScanContext<'_> {

bits.set(pattern_id.into(), true);

if !self.pattern_matches.add(pattern_id, match_, replace) {
if !self.pattern_matches.add(pattern_id, match_, replace_if_longer) {
self.limit_reached.insert(pattern_id);
}
}
Expand Down

0 comments on commit 0e998e4

Please sign in to comment.