Coverage Report

Created: 2025-07-23 07:29

/src/suricata7/rust/src/applayertemplate/logger.rs
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2018 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 super::template::TemplateTransaction;
19
use crate::jsonbuilder::{JsonBuilder, JsonError};
20
use std;
21
22
0
fn log_template(tx: &TemplateTransaction, js: &mut JsonBuilder) -> Result<(), JsonError> {
23
0
    if let Some(ref request) = tx.request {
24
0
        js.set_string("request", request)?;
25
0
    }
26
0
    if let Some(ref response) = tx.response {
27
0
        js.set_string("response", response)?;
28
0
    }
29
0
    Ok(())
30
0
}
31
32
#[no_mangle]
33
0
pub unsafe extern "C" fn rs_template_logger_log(
34
0
    tx: *mut std::os::raw::c_void, js: &mut JsonBuilder,
35
0
) -> bool {
36
0
    let tx = cast_pointer!(tx, TemplateTransaction);
37
0
    log_template(tx, js).is_ok()
38
0
}