Coverage Report

Created: 2025-11-16 07:09

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