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

OISF / suricata / 22550902417

01 Mar 2026 07:32PM UTC coverage: 68.401% (-5.3%) from 73.687%
22550902417

Pull #14922

github

web-flow
github-actions: bump actions/upload-artifact from 6.0.0 to 7.0.0

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 6.0.0 to 7.0.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v6...v7)

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

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #14922: github-actions: bump actions/upload-artifact from 6.0.0 to 7.0.0

218243 of 319063 relevant lines covered (68.4%)

3284926.58 hits per line

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

46.88
/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(
100,079✔
49
        flow: *mut Flow, stream_slice: &StreamSlice, frame_start: &[u8], frame_len: i64,
100,079✔
50
        frame_type: u8, tx_id: Option<u64>,
100,079✔
51
    ) -> Option<Self> {
100,079✔
52
        let offset = frame_start.as_ptr() as usize - stream_slice.as_slice().as_ptr() as usize;
100,079✔
53
        SCLogDebug!(
100,079✔
54
            "offset {} stream_slice.len() {} frame_start.len() {}",
100,079✔
55
            offset,
100,079✔
56
            stream_slice.len(),
100,079✔
57
            frame_start.len()
100,079✔
58
        );
100,079✔
59
        let frame = unsafe {
100,079✔
60
            SCAppLayerFrameNewByRelativeOffset(
100,079✔
61
                flow,
100,079✔
62
                stream_slice as *const _ as *const c_void,
100,079✔
63
                offset as u32,
100,079✔
64
                frame_len,
100,079✔
65
                (stream_slice.flags() & STREAM_TOSERVER == 0).into(),
100,079✔
66
                frame_type,
100,079✔
67
            )
100,079✔
68
        };
100,079✔
69
        if !frame.is_null() {
100,079✔
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
100,079✔
83
        }
84
    }
100,079✔
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(
75✔
91
        _flow: *const Flow, _stream_slice: &StreamSlice, _frame_start: &[u8], _frame_len: i64,
75✔
92
        _frame_type: u8, _tx_id: Option<u64>,
75✔
93
    ) -> Option<Self> {
75✔
94
        None
75✔
95
    }
75✔
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