Coverage Report

Created: 2025-12-31 06:43

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/suricata7/rust/src/detect/parser.rs
Line
Count
Source
1
/* Copyright (C) 2022 Open Information Security Foundation
2
 *
3
 * You can copy, redistribute or modify this Program under the terms of
4
 * the GNU General Public License version 2 as published by the Free
5
 * Software Foundation.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 * GNU General Public License for more details.
11
 *
12
 * You should have received a copy of the GNU General Public License
13
 * version 2 along with this program; if not, write to the Free Software
14
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15
 * 02110-1301, USA.
16
 */
17
18
use crate::detect::error::RuleParseError;
19
20
use nom7::bytes::complete::is_not;
21
use nom7::character::complete::multispace0;
22
use nom7::sequence::preceded;
23
use nom7::IResult;
24
25
static WHITESPACE: &str = " \t\r\n";
26
/// Parse all characters up until the next whitespace character.
27
32.4k
pub fn take_until_whitespace(input: &str) -> IResult<&str, &str, RuleParseError<&str>> {
28
32.4k
    nom7::bytes::complete::is_not(WHITESPACE)(input)
29
32.4k
}
30
31
/// Parse the next token ignoring leading whitespace.
32
///
33
/// A token is the next sequence of chars until a terminating character. Leading whitespace
34
/// is ignore.
35
11.8k
pub fn parse_token(input: &str) -> IResult<&str, &str, RuleParseError<&str>> {
36
11.8k
    let terminators = "\n\r\t,;: ";
37
11.8k
    preceded(multispace0, is_not(terminators))(input)
38
11.8k
}