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

jasonish / suricata / 22802647571

07 Mar 2026 04:23PM UTC coverage: 75.827% (-3.4%) from 79.233%
22802647571

push

github

jasonish
github-ci: add schema ordering check for yaml schema

253365 of 334137 relevant lines covered (75.83%)

3384729.69 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✔
36
        return - 1;
×
37
    }
4✔
38
    if SCDetectBufferSetActiveList(de, s, G_PGSQL_QUERY_BUFFER_ID) < 0 {
4✔
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,193✔
64
    let kw = SigTableElmtStickyBuffer {
2,193✔
65
        name: String::from("pgsql.query"),
2,193✔
66
        desc: String::from("match PGSQL  query request content"),
2,193✔
67
        url: String::from("/rules/pgsql-keywords.html#pgsql.query"),
2,193✔
68
        setup: pgsql_detect_query_setup,
2,193✔
69
    };
2,193✔
70
    let _g_pgsql_query_kw_id = helper_keyword_register_sticky_buffer(&kw);
2,193✔
71
    G_PGSQL_QUERY_BUFFER_ID = SCDetectHelperBufferMpmRegister(
2,193✔
72
        b"pgsql.query\0".as_ptr() as *const libc::c_char,
2,193✔
73
        b"pgsql query request content\0".as_ptr() as *const libc::c_char,
2,193✔
74
        ALPROTO_PGSQL,
2,193✔
75
        STREAM_TOSERVER,
2,193✔
76
        Some(pgsql_detect_query_get_data),
2,193✔
77
    );
2,193✔
78
}
2,193✔
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