Coverage Report

Created: 2026-05-16 07:38

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
187k
    pub fn new() -> Self {
33
187k
        return Default::default()
34
187k
    }
35
}
36
37
impl SMBState {
38
187k
    pub fn new_sessionsetup_tx(&mut self, hdr: SMBCommonHdr)
39
187k
        -> &mut SMBTransaction
40
    {
41
187k
        let mut tx = self.new_tx();
42
43
187k
        tx.hdr = hdr;
44
187k
        tx.type_data = Some(SMBTransactionTypeData::SESSIONSETUP(
45
187k
                    SMBTransactionSessionSetup::new()));
46
187k
        tx.request_done = true;
47
187k
        tx.response_done = self.tc_trunc; // no response expected if tc is truncated
48
49
        SCLogDebug!("SMB: TX SESSIONSETUP created: ID {}", tx.id);
50
187k
        self.transactions.push_back(tx);
51
187k
        let tx_ref = self.transactions.back_mut();
52
187k
        return tx_ref.unwrap();
53
187k
    }
54
55
81.0k
    pub fn get_sessionsetup_tx(&mut self, hdr: SMBCommonHdr)
56
81.0k
        -> Option<&mut SMBTransaction>
57
    {
58
2.61M
        for tx in &mut self.transactions {
59
2.55M
            let hit = tx.hdr.compare(&hdr) && match tx.type_data {
60
23.7k
                Some(SMBTransactionTypeData::SESSIONSETUP(_)) => { true },
61
23.4k
                _ => { false },
62
            };
63
2.55M
            if hit {
64
23.7k
                tx.tx_data.updated_tc = true;
65
23.7k
                tx.tx_data.updated_ts = true;
66
23.7k
                return Some(tx);
67
2.53M
            }
68
        }
69
57.2k
        return None;
70
81.0k
    }
71
}