Coverage Report

Created: 2026-06-07 07:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/suricata7/rust/src/smb/session.rs
Line
Count
Source
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 crate::kerberos::*;
19
use crate::smb::smb::*;
20
use crate::smb::smb1_session::*;
21
use crate::smb::auth::*;
22
23
#[derive(Default, Debug)]
24
pub struct SMBTransactionSessionSetup {
25
    pub request_host: Option<SessionSetupRequest>,
26
    pub response_host: Option<SessionSetupResponse>,
27
    pub ntlmssp: Option<NtlmsspData>,
28
    pub krb_ticket: Option<Kerberos5Ticket>,
29
}
30
31
impl SMBTransactionSessionSetup {
32
183k
    pub fn new() -> Self {
33
183k
        return Default::default()
34
183k
    }
35
}
36
37
impl SMBState {
38
183k
    pub fn new_sessionsetup_tx(&mut self, hdr: SMBCommonHdr)
39
183k
        -> &mut SMBTransaction
40
    {
41
183k
        let mut tx = self.new_tx();
42
43
183k
        tx.hdr = hdr;
44
183k
        tx.type_data = Some(SMBTransactionTypeData::SESSIONSETUP(
45
183k
                    SMBTransactionSessionSetup::new()));
46
183k
        tx.request_done = true;
47
183k
        tx.response_done = self.tc_trunc; // no response expected if tc is truncated
48
49
        SCLogDebug!("SMB: TX SESSIONSETUP created: ID {}", tx.id);
50
183k
        self.transactions.push_back(tx);
51
183k
        let tx_ref = self.transactions.back_mut();
52
183k
        return tx_ref.unwrap();
53
183k
    }
54
55
79.5k
    pub fn get_sessionsetup_tx(&mut self, hdr: SMBCommonHdr)
56
79.5k
        -> Option<&mut SMBTransaction>
57
    {
58
2.74M
        for tx in &mut self.transactions {
59
2.68M
            let hit = tx.hdr.compare(&hdr) && match tx.type_data {
60
24.9k
                Some(SMBTransactionTypeData::SESSIONSETUP(_)) => { true },
61
25.5k
                _ => { false },
62
            };
63
2.68M
            if hit {
64
24.9k
                tx.tx_data.updated_tc = true;
65
24.9k
                tx.tx_data.updated_ts = true;
66
24.9k
                return Some(tx);
67
2.66M
            }
68
        }
69
54.6k
        return None;
70
79.5k
    }
71
}