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

OISF / suricata / 22618661228

02 Mar 2026 09:33PM UTC coverage: 42.258% (-34.4%) from 76.611%
22618661228

push

github

victorjulien
github-actions: bump actions/download-artifact from 7.0.0 to 8.0.0

Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 7.0.0 to 8.0.0.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/37930b1c2...70fc10c6e)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: 8.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

91511 of 216553 relevant lines covered (42.26%)

3416852.41 hits per line

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

41.38
/rust/src/frames.rs
1
/* Copyright (C) 2017-2021 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
//! Module for bindings to the Suricata C frame API.
19

20
use crate::applayer::StreamSlice;
21
#[cfg(not(test))]
22
use crate::applayer::StreamSliceRust;
23
#[cfg(not(test))]
24
use crate::core::STREAM_TOSERVER;
25
use crate::direction::Direction;
26
use crate::flow::Flow;
27

28
#[cfg(not(test))]
29
use std::os::raw::c_void;
30
#[cfg(not(test))]
31
use suricata_sys::sys::{SCAppLayerFrameNewByRelativeOffset, SCAppLayerFrameSetTxIdById};
32
use suricata_sys::sys::{SCAppLayerFrameAddEventById, SCAppLayerFrameSetLengthById};
33

34
pub struct Frame {
35
    pub id: i64,
36
    direction: Direction,
37
}
38

39
impl std::fmt::Debug for Frame {
40
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
×
41
        write!(f, "frame: {}, direction: {}", self.id, self.direction)
×
42
    }
×
43
}
44

45
impl Frame {
46
    #[cfg(not(test))]
47
    #[allow(clippy::not_unsafe_ptr_arg_deref)]
48
    pub fn new(
99,750✔
49
        flow: *mut Flow, stream_slice: &StreamSlice, frame_start: &[u8], frame_len: i64,
99,750✔
50
        frame_type: u8, tx_id: Option<u64>,
99,750✔
51
    ) -> Option<Self> {
99,750✔
52
        let offset = frame_start.as_ptr() as usize - stream_slice.as_slice().as_ptr() as usize;
99,750✔
53
        SCLogDebug!(
99,750✔
54
            "offset {} stream_slice.len() {} frame_start.len() {}",
99,750✔
55
            offset,
99,750✔
56
            stream_slice.len(),
99,750✔
57
            frame_start.len()
99,750✔
58
        );
99,750✔
59
        let frame = unsafe {
99,750✔
60
            SCAppLayerFrameNewByRelativeOffset(
99,750✔
61
                flow,
99,750✔
62
                stream_slice as *const _ as *const c_void,
99,750✔
63
                offset as u32,
99,750✔
64
                frame_len,
99,750✔
65
                (stream_slice.flags() & STREAM_TOSERVER == 0).into(),
99,750✔
66
                frame_type,
99,750✔
67
            )
99,750✔
68
        };
99,750✔
69
        if !frame.is_null() {
99,750✔
70
            let id = unsafe { (*frame).id };
×
71
            let r = Self {
×
72
                id,
×
73
                direction: Direction::from(stream_slice.flags()),
×
74
            };
×
75
            if let Some(tx_id) = tx_id {
×
76
                unsafe {
×
77
                    SCAppLayerFrameSetTxIdById(flow, r.direction(), id, tx_id);
×
78
                };
×
79
            }
×
80
            Some(r)
×
81
        } else {
82
            None
99,750✔
83
        }
84
    }
99,750✔
85

86
    /// A variation of `new` for use when running Rust unit tests as
87
    /// the C functions for building a frame are not available for
88
    /// linkage.
89
    #[cfg(test)]
90
    pub fn new(
91
        _flow: *const Flow, _stream_slice: &StreamSlice, _frame_start: &[u8], _frame_len: i64,
92
        _frame_type: u8, _tx_id: Option<u64>,
93
    ) -> Option<Self> {
94
        None
95
    }
96

97
    /// Conversion function to get the direction in the correct form for the
98
    /// C frame methods which takes direction as a u32 value of 0 or 1 rather
99
    /// than the flag value used internally by Frame.
100
    fn direction(&self) -> i32 {
×
101
        match self.direction {
×
102
            Direction::ToServer => 0,
×
103
            Direction::ToClient => 1,
×
104
        }
105
    }
×
106

107
    #[allow(clippy::not_unsafe_ptr_arg_deref)]
108
    pub fn set_len(&self, flow: *const Flow, len: i64) {
×
109
        unsafe {
×
110
            SCAppLayerFrameSetLengthById(flow, self.direction(), self.id, len);
×
111
        };
×
112
    }
×
113

114
    #[cfg(not(test))]
115
    #[allow(clippy::not_unsafe_ptr_arg_deref)]
116
    pub fn set_tx(&self, flow: *const Flow, tx_id: u64) {
×
117
        unsafe {
×
118
            SCAppLayerFrameSetTxIdById(flow, self.direction(), self.id, tx_id);
×
119
        };
×
120
    }
×
121

122
    /// A variation of `set_tx` for use when running Rust unit tests as
123
    /// the C functions for building a frame are not available for
124
    /// linkage.
125
    #[cfg(test)]
126
    pub fn set_tx(&self, _flow: *const Flow, _tx_id: u64) {}
127

128
    #[allow(clippy::not_unsafe_ptr_arg_deref)]
129
    pub fn add_event(&self, flow: *const Flow, event: u8) {
×
130
        unsafe {
×
131
            SCAppLayerFrameAddEventById(flow, self.direction(), self.id, event);
×
132
        };
×
133
    }
×
134
}
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