lib/SMB/v1/Header.pm

filter: Statementstmt 61.9% 13 / 21 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 13 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 57.1% 4 / 7 Podpod 33.3% 1 / 3 totaltotal 34.6% 18 / 52 SCAR 29.8
CC
7
Cov
36%
is_signed
20.0
new
12.0
is_response
6.0
CRAP 19.8
« blib/lib/SMB/v2/Command/TreeConnect.pm ↑ Summary lib/SMB/v1/Commands.pm »
1 # SMB Perl library, Copyright (C) 2014 Mikhael Goikhman, migo@cpan.org
2 #
3 # This program is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation, either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15  
16 package SMB::v1::Header;
17  
18 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use parent 'SMB::Header';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 use constant {
24 # the command is a response, otherwise a request
25 1 FLAGS_RESPONSE => 0x80,
26 # client supports signing, server forces signing
27 FLAGS2_SECURITY_SIGNATURE => 0x0004,
28 # client desires compression, server agrees to compress
29 FLAGS2_COMPRESSED => 0x0008,
30 # client supports signing, server forces signing
31 FLAGS2_SECURITY_SIGNATURE_REQUIRED => 0x0010,
32 # extended security negotiation is supported
33 FLAGS2_EXTENDED_SECURITY_NEGOTIATION => 0x0800,
34 # string are in Unicode (UTF-16LE) encoding
35 FLAGS2_UNICODE => 0x8000,
36 # NT statuses used
37 FLAGS2_NT_STATUS => 0x4000,
38 1 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
39  
40 sub new ($%) {
41 0 ▶ my $class = shift;
Subroutine new: not called CC=3 SCAR=24.8
Pod documented
42 0 my %options = @_;
43  
44 return $class->SUPER::new(
45 pid => delete $options{pid} || 0,
46 0 ▶ flags2 => delete $options{flags2} || 0,
Condition0%0/4
delete $options{'pid'} || 0
l!l
00
delete $options{'flags2'} || 0
l!l
00
MC/DC0%0/1
delete $options{'pid'} || 0
delete $options{'pid'}
MC/DC0%0/1
delete $options{'flags2'} || 0
delete $options{'flags2'}
Truth table0%0/2
A
A= delete $options{'pid'}
Aresult
11
00
Truth table0%0/2
A
A= delete $options{'flags2'}
Aresult
11
00
47 %options,
48 );
49 }
50  
51 sub is_response ($) {
52 0 ▶ my $self = shift;
Subroutine is_response: not called CC=2 SCAR=17.9
Pod undocumented
53  
54 0 ▶ return $self->flags & FLAGS_RESPONSE ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->flags & 128 ? : 0 0 0
55 }
56  
57 sub is_signed ($) {
58 0 ▶ my $self = shift;
Subroutine is_signed: not called CC=4 SCAR=30.0
Pod undocumented
59 0 my $signature = $self->signature;
60  
61 0 ▶ return ref($signature) eq 'ARRAY' && @$signature == 8 &&
Condition0%0/9
ref $signature eq 'ARRAY' && @$signature == 8 && "$signature" ne "\000\000\000\000\000\000\000\000" && ($self->flags2 & 4) != 0
!ll&&!rl&&r
000
ref $signature eq "ARRAY" and @$signature == 8 and "$signature" ne "\0\0\0\0\0\0\0\0"
!ll&&!rl&&r
000
ref $signature eq "ARRAY" and @$signature == 8
!ll&&!rl&&r
000
MC/DC0%0/4
ref $signature eq 'ARRAY' && @$signature == 8 && "$signature" ne "\000\000\000\000\000\000\000\000" && ($self->flags2 & 4) != 0
ref $signature eq "ARRAY" @$signature == 8 "$signature" ne "\0\0\0\0\0\0\0\0" ($self->flags2 & 4) != 0
Truth table0%0/5
A and B and C && D
A= ref $signature eq "ARRAY"B= @$signature == 8C= "$signature" ne "\0\0\0\0\0\0\0\0"D= ($self->flags2 & 4) != 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
62 (join('', $signature) ne "\0" x 8) &&
63 ($self->flags2 & FLAGS2_SECURITY_SIGNATURE) != 0;
64 }
65  
66 1 1;
« blib/lib/SMB/v2/Command/TreeConnect.pm ↑ Summary lib/SMB/v1/Commands.pm »