• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OISF / suricata / 22553492142

01 Mar 2026 09:48PM UTC coverage: 70.74% (-2.9%) from 73.687%
22553492142

Pull #14920

github

web-flow
Merge e15a765bc into 90823fa90
Pull Request #14920: draft: rust based configuration file parser and loader - v4

38209 of 77306 branches covered (49.43%)

Branch coverage included in aggregate %.

533 of 779 new or added lines in 5 files covered. (68.42%)

11924 existing lines in 491 files now uncovered.

252429 of 333548 relevant lines covered (75.68%)

2403268.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.12
/rust/src/pgsql/detect.rs
1
/* Copyright (C) 2025 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
// written by Juliana Fajardini <jufajardini@oisf.net>
19

20
use super::pgsql::{PgsqlTransaction, ALPROTO_PGSQL};
21
use crate::pgsql::parser::PgsqlFEMessage;
22
use crate::core::{STREAM_TOSERVER};
23
use crate::detect::{helper_keyword_register_sticky_buffer, SigTableElmtStickyBuffer};
24
use suricata_sys::sys::{
25
    DetectEngineCtx, SCDetectBufferSetActiveList, SCDetectHelperBufferMpmRegister, SCDetectSignatureSetAppProto,
26
    Signature,
27
};
28
use std::os::raw::{c_int, c_void};
29

30
static mut G_PGSQL_QUERY_BUFFER_ID: c_int = 0;
31

32
unsafe extern "C" fn pgsql_detect_query_setup(
4✔
33
    de: *mut DetectEngineCtx, s: *mut Signature, _raw: *const std::os::raw::c_char,) -> c_int
4✔
34
{
4✔
35
    if SCDetectSignatureSetAppProto(s, ALPROTO_PGSQL) != 0 {
4✔
UNCOV
36
        return - 1;
×
37
    }
4✔
38
    if SCDetectBufferSetActiveList(de, s, G_PGSQL_QUERY_BUFFER_ID) < 0 {
4✔
UNCOV
39
        return - 1;
×
40
    }
4✔
41
    0
4✔
42
}
4✔
43

44
unsafe extern "C" fn pgsql_detect_query_get_data(
33✔
45
    tx: *const c_void, _flags: u8, buffer: *mut *const u8, buffer_len: *mut u32,
33✔
46
) -> bool {
33✔
47
    let tx = cast_pointer!(tx, PgsqlTransaction);
33✔
48

49
    for request in &tx.requests {
42✔
50
        if let PgsqlFEMessage::SimpleQuery(ref query) = request {
33✔
51
            *buffer = query.payload.as_ptr();
24✔
52
            *buffer_len = query.payload.len() as u32;
24✔
53
            return true;
24✔
54
        }
9✔
55
    }
56

57
    *buffer = std::ptr::null();
9✔
58
    *buffer_len = 0;
9✔
59
    false
9✔
60
}
33✔
61

62
#[no_mangle]
63
pub unsafe extern "C" fn SCDetectPgsqlRegister() {
2,159✔
64
    let kw = SigTableElmtStickyBuffer {
2,159✔
65
        name: String::from("pgsql.query"),
2,159✔
66
        desc: String::from("match PGSQL  query request content"),
2,159✔
67
        url: String::from("/rules/pgsql-keywords.html#pgsql.query"),
2,159✔
68
        setup: pgsql_detect_query_setup,
2,159✔
69
    };
2,159✔
70
    let _g_pgsql_query_kw_id = helper_keyword_register_sticky_buffer(&kw);
2,159✔
71
    G_PGSQL_QUERY_BUFFER_ID = SCDetectHelperBufferMpmRegister(
2,159✔
72
        b"pgsql.query\0".as_ptr() as *const libc::c_char,
2,159✔
73
        b"pgsql query request content\0".as_ptr() as *const libc::c_char,
2,159✔
74
        ALPROTO_PGSQL,
2,159✔
75
        STREAM_TOSERVER,
2,159✔
76
        Some(pgsql_detect_query_get_data),
2,159✔
77
    );
2,159✔
78
}
2,159✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc