Skip to content

Commit c61f1cb

Browse files
catenacybervictorjulien
authored andcommitted
detect/integers: rename index all1 to all
And all to all_or_absent Ticket: 7929
1 parent eb5a2d6 commit c61f1cb

3 files changed

Lines changed: 31 additions & 27 deletions

File tree

doc/userguide/rules/integer-keywords.rst

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,27 @@ They expand the syntax of a single integer::
121121

122122
.. table:: **Index values for multi-integers keyword**
123123

124-
========= ================================================
125-
Value Description
126-
========= ================================================
127-
[default] Match with any index
128-
any Match with any index
129-
all Match only if all indexes match
130-
all1 Match only if all and at least one indexes match
131-
nb Matches a number of times
132-
or_absent Match with any index or no values
133-
0>= Match specific index
134-
0< Match specific index with back to front indexing
135-
oob_or Match with specific index or index out of bounds
136-
========= ================================================
137-
138-
The index ``all`` will match if there is no value.
139-
The index ``all1`` will not match if there is no value and behaves
140-
like ``all`` if there is at least one value.
124+
============= ===========================================================
125+
Value Description
126+
============= ===========================================================
127+
[default] Match with any index
128+
any Match with any index
129+
all Match only if all and at least one indexes match
130+
all_or_absent Match only if all indexes match or matches on an empty list
131+
nb x Matches a number of times
132+
or_absent Match with any index or matches on an empty list
133+
0>= Match specific index
134+
0< Match specific index with back to front indexing
135+
oob_or x Match with specific index or index out of bounds
136+
============= ===========================================================
137+
138+
**Please note that:**
139+
140+
The index ``all`` will not match if there is no value.
141+
142+
The index ``all_or_absent`` will match if there is no value
143+
and behaves like ``all`` if there is at least one value.
144+
141145
These keywords will wait for transaction completion to run, to
142146
be sure to have the final number of elements.
143147

rust/src/detect/uint.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ pub struct DetectUintData<T> {
5353
#[derive(Debug, PartialEq)]
5454
pub enum DetectUintIndex {
5555
Any,
56+
AllOrAbsent,
5657
All,
57-
All1,
5858
OrAbsent,
5959
Index((bool, i32)),
6060
NumberMatches(DetectUintData<u32>),
@@ -123,7 +123,7 @@ fn parse_uint_index(parts: &[&str]) -> Option<DetectUintIndex> {
123123
let index = if parts.len() >= 2 {
124124
match parts[1] {
125125
"all" => DetectUintIndex::All,
126-
"all1" => DetectUintIndex::All1,
126+
"all_or_absent" => DetectUintIndex::AllOrAbsent,
127127
"any" => DetectUintIndex::Any,
128128
"or_absent" => DetectUintIndex::OrAbsent,
129129
// not only a literal, but some numeric value
@@ -289,7 +289,7 @@ pub(crate) fn detect_uint_match_at_index<T, U: DetectIntType>(
289289
}
290290
return 0;
291291
}
292-
DetectUintIndex::All => {
292+
DetectUintIndex::AllOrAbsent => {
293293
if !eof {
294294
return 0;
295295
}
@@ -302,7 +302,7 @@ pub(crate) fn detect_uint_match_at_index<T, U: DetectIntType>(
302302
}
303303
return 1;
304304
}
305-
DetectUintIndex::All1 => {
305+
DetectUintIndex::All => {
306306
if !eof {
307307
return 0;
308308
}

rust/src/detect/vlan.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::ffi::{c_int, c_void, CStr};
2323

2424
pub const DETECT_VLAN_ID_ANY: i8 = i8::MIN;
2525
pub const DETECT_VLAN_ID_ALL: i8 = i8::MAX;
26-
pub const DETECT_VLAN_ID_ALL1: i8 = i8::MAX - 1;
26+
pub const DETECT_VLAN_ID_ALL_OR_ABSENT: i8 = i8::MAX - 1;
2727
pub const DETECT_VLAN_ID_OR_ABSENT: i8 = i8::MAX - 2;
2828
pub const DETECT_VLAN_ID_ERROR: i8 = i8::MAX - 3;
2929
pub static VLAN_MAX_LAYERS: i32 = 3;
@@ -54,7 +54,7 @@ pub fn detect_parse_vlan_id(s: &str) -> Option<DetectUintArrayData<u16>> {
5454
// keep previous behavior that vlan.id: all matched only if there was vlan
5555
return Some(DetectUintArrayData {
5656
du: a.du.clone(),
57-
index: DetectUintIndex::All1,
57+
index: DetectUintIndex::All,
5858
start: a.start,
5959
end: a.end,
6060
});
@@ -108,7 +108,7 @@ pub unsafe extern "C" fn SCDetectVlanIdPrefilterMatch(
108108
let index = match ctx.layer {
109109
DETECT_VLAN_ID_ANY => DetectUintIndex::Any,
110110
DETECT_VLAN_ID_ALL => DetectUintIndex::All,
111-
DETECT_VLAN_ID_ALL1 => DetectUintIndex::All1,
111+
DETECT_VLAN_ID_ALL_OR_ABSENT => DetectUintIndex::AllOrAbsent,
112112
DETECT_VLAN_ID_OR_ABSENT => DetectUintIndex::OrAbsent,
113113
i => DetectUintIndex::Index((false, i.into())),
114114
};
@@ -130,7 +130,7 @@ pub unsafe extern "C" fn SCDetectVlanIdPrefilter(
130130
let layer = match ctx.index {
131131
DetectUintIndex::Any => DETECT_VLAN_ID_ANY,
132132
DetectUintIndex::All => DETECT_VLAN_ID_ALL,
133-
DetectUintIndex::All1 => DETECT_VLAN_ID_ALL1,
133+
DetectUintIndex::AllOrAbsent => DETECT_VLAN_ID_ALL_OR_ABSENT,
134134
DetectUintIndex::OrAbsent => DETECT_VLAN_ID_OR_ABSENT,
135135
DetectUintIndex::Index((_, i)) => i as i8,
136136
DetectUintIndex::NumberMatches(_) => DETECT_VLAN_ID_ERROR,
@@ -151,7 +151,7 @@ pub unsafe extern "C" fn SCDetectVlanIdPrefilterable(ctx: *const c_void) -> bool
151151
match ctx.index {
152152
DetectUintIndex::Any => true,
153153
DetectUintIndex::All => true,
154-
DetectUintIndex::All1 => true,
154+
DetectUintIndex::AllOrAbsent => true,
155155
DetectUintIndex::OrAbsent => true,
156156
// do not prefilter for precise index with "or out of bounds"
157157
DetectUintIndex::Index((oob, _)) => !oob,
@@ -201,7 +201,7 @@ mod test {
201201
arg2: 0,
202202
mode: DetectUintMode::DetectUintModeEqual,
203203
},
204-
index: DetectUintIndex::All1,
204+
index: DetectUintIndex::All,
205205
start: 0,
206206
end: 0,
207207
}

0 commit comments

Comments
 (0)