blib/lib/Langertha/Holmgang/Sim/Linux/SshAccess.pm

filter: Statementstmt 94.8% 278 / 293 Branchbran 73.6% 137 / 186 Conditioncond 55.0% 87 / 158 MC/DCmcdc 28.4% 23 / 81 Subroutinesub 94.2% 33 / 35 Podpod 100% 6 / 6 totaltotal 74.3% 564 / 759 CC 168 SCAR 44.8
CC
168
Cov
79%
check
221.6
_criteria_match
17.1
_config
11.0
CRAP 88.0
« blib/lib/Langertha/Holmgang/Sim/Linux/Sshd.pm ↑ Summary blib/lib/Langertha/Holmgang/Lint.pm »
1 package Langertha::Holmgang::Sim::Linux::SshAccess;
2 # ABSTRACT: Whether a user can log in over SSH: port, firewall, Match, account, authorized_keys, StrictModes
3  
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 3 ▶use Langertha::Holmgang::Sim::Linux::Nft ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 3 our $VERSION = '0.001';
11  
12  
13 3 my $MAIN = '/etc/ssh/sshd_config';
14  
15 168 ▶sub _files { my ($dev) = @_; return ref $dev->{files} eq 'HASH' ? $dev->{files} : {} }
Subroutine _files: called CC=2 SCAR=7.2
Branch: 1 branch
BranchTrueFalseTotal
ref $$dev{'files'} eq 'HASH' ? : 168 0 168
16  
17 304 ▶sub _svc {
Subroutine _svc: called CC=3 SCAR=12.5
18 304 my ($dev) = @_;
19 304 ▶ my $s = $dev->{services} || {};
Condition50%1/2
$$dev{'services'} || {}
l!l
3040
MC/DC0%0/1
$$dev{'services'} || {}
$$dev{'services'}
Truth table50%1/2
A
A= $$dev{'services'}
Aresult
11
00
20 304 ▶ return $s->{ssh} // $s->{sshd};
Condition33%1/3
$$s{"ssh"} // $$s{"sshd"}
l!l&&r!l&&!r
30400
MC/DC0%0/2
$$s{"ssh"} // $$s{"sshd"}
$$s{"ssh"} $$s{"sshd"}
Truth table33%1/3
A // B
A= $$s{"ssh"}B= $$s{"sshd"}
ABresult
1X1
011
000
21 }
22  
23 145 ▶sub _text {
Subroutine _text: called CC=4 SCAR=14.2
24 145 my ( $files, $p ) = @_;
25 145 my $e = $files->{$p};
26 145 ▶ return undef unless defined $e;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $e 0 145 145
27 145 ▶ return ref $e eq 'HASH' ? ( $e->{content} // '' ) : $e;
Branch: 1 branch
BranchTrueFalseTotal
ref $e eq 'HASH' ? : 2 143 145
Condition50%1/2
$$e{"content"} // ""
l!l
20
MC/DC0%0/1
$$e{"content"} // ""
$$e{"content"}
Truth table50%1/2
A
A= $$e{"content"}
Aresult
11
00
28 }
29  
30  
31 174 ▶sub remember {
Subroutine remember: called CC=3 SCAR=11.0
Pod documented
32 174 my ($dev) = @_;
33 174 ▶ my $svc = _svc($dev) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $svc = _svc($dev) or return 174 0 174
34 174 ▶ return if exists $svc->{_loaded};
Branch: 1 branch
BranchTrueFalseTotal
if exists $$svc{"_loaded"} 137 37 174
35 37 loaded($dev);
36 37 return;
37 }
38  
39  
40 44 ▶sub loaded {
Subroutine loaded: called CC=3 SCAR=11.0
Pod documented
41 44 my ($dev) = @_;
42 44 ▶ my $svc = _svc($dev) or return;
Branch: 1 branch
BranchTrueFalseTotal
my $svc = _svc($dev) or return 44 0 44
43 44 my $f = _files($dev);
44 44 ▶ $svc->{_loaded} = { map { $_ => _text( $f, $_ ) } grep { m{\A/etc/ssh/} && !m{/ssh_host_} } keys %$f };
Condition100%3/3
m[\A/etc/ssh/] && !m[/ssh_host_]
!ll&&!rl&&r
28269112
MC/DC100%2/2
m[\A/etc/ssh/] && !m[/ssh_host_]
m[\A/etc/ssh/] !m[/ssh_host_]
Truth table100%3/3
A && not(B)
A= m[\A/etc/ssh/]B= !m[/ssh_host_]
ABresult
0X0
100
111
45 44 return;
46 }
47  
48 56 ▶sub _snapshot {
Subroutine _snapshot: called CC=3 SCAR=11.0
49 56 my ($dev) = @_;
50 56 ▶ my $svc = _svc($dev) || {};
Condition50%1/2
_svc($dev) || {}
l!l
560
MC/DC0%0/1
_svc($dev) || {}
_svc($dev)
Truth table50%1/2
A
A= _svc($dev)
Aresult
11
00
51 56 ▶ return $svc->{_loaded} if ref $svc->{_loaded} eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $$svc{"_loaded"} eq "HASH" 27 29 56
52 29 my $f = _files($dev);
53 29 return { map { $_ => _text( $f, $_ ) } grep { m{\A/etc/ssh/} } keys %$f };
54 }
55  
56 # Zeilen der Konfiguration mit aufgeloesten Include (wie sshd, an Ort und Stelle)
57 60 ▶sub _lines {
Subroutine _lines: called CC=10 SCAR=23.9
58 60 my ( $snap, $file, $depth ) = @_;
59 60 ▶ return () if $depth > 8;
Branch: 1 branch
BranchTrueFalseTotal
if $depth > 8 0 60 60
60 60 ▶ my $t = $snap->{$file} // return ();
Condition50%1/2
$$snap{$file} // (return ())
l!l
600
MC/DC0%0/1
$$snap{$file} // (return ())
$$snap{$file}
Truth table50%1/2
A
A= $$snap{$file}
Aresult
11
00
61 60 my @out;
62 60 for my $line ( split /\n/, $t ) {
63 125 ( my $l = $line ) =~ s/\A\s+|\s+\z//g;
64 125 ▶ next if $l eq '' || $l =~ /\A#/;
Branch: 1 branch
BranchTrueFalseTotal
if $l eq "" or $l =~ /\A#/ 0 125 125
Condition33%1/3
$l eq "" or $l =~ /\A#/
l!l&&r!l&&!r
00125
MC/DC0%0/2
$l eq "" or $l =~ /\A#/
$l eq "" $l =~ /\A#/
Truth table33%1/3
A or B
A= $l eq ""B= $l =~ /\A#/
ABresult
1X1
011
000
65 125 ▶ if ( $l =~ /\AInclude\s+(.+)\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ /\AInclude\s+(.+)\z/i) 40 85 125
66 40 for my $pat ( split /\s+/, $1 ) {
67 40 ▶ $pat = "/etc/ssh/$pat" unless $pat =~ m{\A/};
Branch: 1 branch
BranchTrueFalseTotal
unless $pat =~ m[\A/] 0 40 40
68 40 ( my $re = quotemeta $pat ) =~ s/\\\*/[^\/]*/g;
69 40 push @out, _lines( $snap, $_, $depth + 1 ) for sort grep {/\A$re\z/} keys %$snap;
70 }
71 40 next;
72 }
73 85 push @out, $l;
74 }
75 60 return @out;
76 }
77  
78 85 ▶sub _kv {
Subroutine _kv: called CC=2 SCAR=7.0
79 85 my ($l) = @_;
80 85 ▶ my ( $k, $v ) = $l =~ /\A(\S+?)(?:\s*=\s*|\s+)(.*)\z/ or return;
Branch: 1 branch
BranchTrueFalseTotal
() = $l =~ /\A(\S+?)(?:\s*=\s*|\s+)(.*)\z/ or return 85 0 85
81 85 $v =~ s/\A"(.*)"\z/$1/;
82 85 return ( lc $k, $v );
83 }
84  
85 3 my %LIST = map { $_ => 1 } qw( allowusers allowgroups denyusers denygroups port listenaddress authorizedkeysfile );
86  
87 15 ▶sub _ip_in {
Subroutine _ip_in: called CC=9 SCAR=22.1
88 15 my ( $ip, $pat ) = @_;
89 15 ▶ return 0 unless defined $ip;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ip 0 15 15
90 15 ▶ if ( $pat =~ m{/} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pat =~ m[/]) 11 4 15
91 11 ▶ my $r = Langertha::Holmgang::Sim::Linux::Nft::_range($pat) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $r = Langertha::Holmgang::Sim::Linux::Nft::_range($pat) or return 0 11 0 11
92 11 ▶ my ( $f, $b ) = Langertha::Holmgang::Sim::Linux::Nft::_addr_bin($ip) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
() = Langertha::Holmgang::Sim::Linux::Nft::_addr_bin($ip) or return 0 8 3 11
93 8 ▶ return 0 unless $f == $r->[0];
Branch: 1 branch
BranchTrueFalseTotal
unless $f == $$r[0] 0 8 8
94 8 my $bits = unpack( 'B*', $b );
95 8 ▶ return $bits ge $r->[1] && $bits le $r->[2] ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$bits ge $$r[1] && $bits le $$r[2] ? : 4 4 8
Condition100%3/3
$bits ge $$r[1] and $bits le $$r[2]
!ll&&!rl&&r
314
MC/DC100%2/2
$bits ge $$r[1] and $bits le $$r[2]
$bits ge $$r[1] $bits le $$r[2]
Truth table100%3/3
A and B
A= $bits ge $$r[1]B= $bits le $$r[2]
ABresult
0X0
100
111
96 }
97 4 ( my $re = quotemeta $pat ) =~ s/\\\*/.*/g;
98 4 $re =~ s/\\\?/./g;
99 4 ▶ return $ip =~ /\A$re\z/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$ip =~ /\A$re\z/ ? : 1 3 4
100 }
101  
102 8 ▶sub _pat { my ( $p, $v ) = @_; ( my $re = quotemeta $p ) =~ s/\\\*/.*/g; $re =~ s/\\\?/./g; return defined $v && $v =~ /\A$re\z/ ? 1 : 0 }
Subroutine _pat: called CC=3 SCAR=11.0
Branch: 1 branch
BranchTrueFalseTotal
defined $v && $v =~ /\A$re\z/ ? : 3 5 8
Condition66%2/3
defined $v and $v =~ /\A$re\z/
!ll&&!rl&&r
053
MC/DC50%1/2
defined $v and $v =~ /\A$re\z/
defined $v $v =~ /\A$re\z/
Truth table66%2/3
A and B
A= defined $vB= $v =~ /\A$re\z/
ABresult
0X0
100
111
103  
104 # Musterliste wie sshd (Komma, ! verneint: passt ein verneintes, passt die Liste nicht)
105 16 ▶sub _list_match {
Subroutine _list_match: called CC=5 SCAR=16.1
106 16 my ( $list, $test ) = @_;
107 16 my $hit = 0;
108 16 for my $p ( split /\s*,\s*/, $list ) {
109 20 ▶ if ( $p =~ s/\A!// ) { return 0 if $test->($p) }
Branch: 3 branches
BranchTrueFalseTotal
if ($p =~ s/\A!//) { } 4 16 20
elsif (&$test($p)) { } 6 10 16
if &$test($p) 1 3 4
110 6 elsif ( $test->($p) ) { $hit = 1 }
111 }
112 15 return $hit;
113 }
114  
115 11 ▶sub _criteria_match {
Subroutine _criteria_match: called CC=13 SCAR=28.4
116 11 my ( $crit, $c ) = @_;
117 11 my @w = split /\s+/, $crit;
118 11 ▶ return 1 if @w == 1 && lc $w[0] eq 'all';
Branch: 1 branch
BranchTrueFalseTotal
if @w == 1 and lc $w[0] eq "all" 0 11 11
Condition33%1/3
@w == 1 and lc $w[0] eq "all"
!ll&&!rl&&r
1100
MC/DC0%0/2
@w == 1 and lc $w[0] eq "all"
@w == 1 lc $w[0] eq "all"
Truth table33%1/3
A and B
A= @w == 1B= lc $w[0] eq "all"
ABresult
0X0
100
111
119 11 ▶ while (@w) {
Branch: 1 branch
BranchTrueFalseTotal
if (@w) 12 3 15
120 12 my $k = lc shift @w;
121 12 ▶ my $v = shift @w // return 0;
Condition50%1/2
shift @w // (return 0)
l!l
120
MC/DC0%0/1
shift @w // (return 0)
shift @w
Truth table50%1/2
A
A= shift @w
Aresult
11
00
122 12 ▶ if ( $k eq 'user' ) { return 0 unless _list_match( $v, sub { _pat( $_[0], $c->{user} ) } ) }
Subroutine __ANON__: called CC=1 SCAR=0.3
Branch: 5 branches
BranchTrueFalseTotal
if ($k eq 'user') { } 1 11 12
elsif ($k eq 'group') { } 4 7 11
elsif ($k eq 'address') { } 7 0 7
elsif ($k eq 'localport') { } 0 0 0
unless _list_match($v, sub { _pat($_[0], $$c{"user"}); } ) 0 1 1
123 4 ▶ elsif ( $k eq 'group' ) { return 0 unless _list_match( $v, sub { my $p = $_[0]; grep { _pat( $p, $_ ) } @{ $c->{groups} } } ) }
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
unless _list_match($v, sub { my $p = $_[0]; grep {_pat($p, $_);} @{$$c{"groups"};}; } ) 3 1 4
124 7 ▶ elsif ( $k eq 'address' ) { return 0 unless _list_match( $v, sub { _ip_in( $c->{from}, $_[0] ) } ) }
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
unless _list_match($v, sub { _ip_in($$c{"from"}, $_[0]); } ) 5 2 7
125 0 ▶ elsif ( $k eq 'localport' ) { return 0 unless _list_match( $v, sub { $_[0] eq $c->{port} } ) }
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless _list_match($v, sub { $_[0] eq $$c{"port"}; } ) 0 0 0
126 0 else { return 0 } # Host, LocalAddress, RDomain: hier nicht nachgebildet -> trifft nicht zu
127 }
128 3 return 1;
129 }
130  
131  
132 56 ▶sub config_for {
Subroutine config_for: called CC=1 SCAR=0.0
Pod documented
133 56 my ( $dev, $c, $files ) = @_;
134 56 my ( $eff, $over ) = _config( $dev, $c, $files );
135 56 return $eff;
136 }
137  
138  
139 2 ▶sub match_overrides {
Subroutine match_overrides: called CC=1 SCAR=0.0
Pod documented
140 2 my ( $dev, $c, $files ) = @_;
141 2 my ( $eff, $over ) = _config( $dev, $c, $files );
142 2 return $over;
143 }
144  
145 58 ▶sub _config {
Subroutine _config: called CC=11 SCAR=24.0
146 58 my ( $dev, $c, $files ) = @_;
147 58 ▶ my $snap = $files ? { map { $_ => _text( _files($dev), $_ ) } grep { m{\A/etc/ssh/} } keys %{ _files($dev) } } : _snapshot($dev);
Branch: 1 branch
BranchTrueFalseTotal
$files ? : 2 56 58
148 58 my ( %glob, @blocks );
149 58 my $cur;
150 58 for my $l ( _lines( $snap, $MAIN, 0 ) ) {
151 85 ▶ my ( $k, $v ) = _kv($l) or next;
Branch: 1 branch
BranchTrueFalseTotal
() = _kv($l) or next 85 0 85
152 85 ▶ if ( $k eq 'match' ) { push @blocks, $cur = { crit => $v, set => {} }; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($k eq "match") 11 74 85
153 74 ▶ my $h = $cur ? $cur->{set} : \%glob;
Branch: 1 branch
BranchTrueFalseTotal
$cur ? : 11 63 74
154 74 ▶ if ( $LIST{$k} ) { push @{ $h->{$k} }, split /\s+/, $v; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($LIST{$k}) 21 53 74
155 53 ▶ $h->{$k} = $v unless exists $h->{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $$h{$k} 51 2 53
156 }
157 58 my %eff = %glob;
158 58 my %over;
159 58 for my $b ( grep { _criteria_match( $_->{crit}, $c ) } @blocks ) {
160 3 for my $k ( grep { !/\A_/ } keys %{ $b->{set} } ) {
161 3 ▶ next if exists $over{$k};
Branch: 1 branch
BranchTrueFalseTotal
if exists $over{$k} 0 3 3
162 3 $eff{$k} = $over{$k} = $b->{set}{$k};
163 }
164 }
165 58 return ( \%eff, \%over );
166 }
167  
168 96 ▶sub _yes { my ( $v, $def ) = @_; return lc( $v // $def ) eq 'yes' ? 1 : 0 }
Subroutine _yes: called CC=3 SCAR=11.1
Branch: 1 branch
BranchTrueFalseTotal
lc($v // $def) eq 'yes' ? : 77 19 96
Condition66%2/3
$v // $def
l!l&&r!l&&!r
22740
MC/DC0%0/2
$v // $def
$v $def
Truth table66%2/3
A // B
A= $vB= $def
ABresult
1X1
011
000
169  
170 89 ▶sub _entry {
Subroutine _entry: called CC=5 SCAR=16.2
171 89 my ( $dev, $p ) = @_;
172 89 my $f = _files($dev);
173 89 ▶ return ( ref $f->{$p} eq 'HASH' ? $f->{$p} : { content => $f->{$p} } ) if exists $f->{$p};
Branch: 2 branches
BranchTrueFalseTotal
if exists $$f{$p} 40 49 89
ref $$f{$p} eq 'HASH' ? : 40 0 40
174 49 ▶ return ( { mode => '0755', %{ $dev->{dirs}{$p} } }, 'dir' ) if ( $dev->{dirs} || {} )->{$p};
Branch: 1 branch
BranchTrueFalseTotal
if ($$dev{"dirs"} || {})->{$p} 36 13 49
Condition50%1/2
$$dev{'dirs'} || {}
l!l
490
MC/DC0%0/1
$$dev{'dirs'} || {}
$$dev{'dirs'}
Truth table50%1/2
A
A= $$dev{'dirs'}
Aresult
11
00
175 13 return;
176 }
177  
178 # StrictModes: Datei und Verzeichnisse bis zum Heimatverzeichnis
179 20 ▶sub _strict_bad {
Subroutine _strict_bad: called CC=8 SCAR=21.3
180 20 my ( $dev, $user, $home, $file ) = @_;
181 20 my ( $e ) = _entry( $dev, $file );
182 56 ▶ my $chk = sub {
Subroutine __ANON__: called CC=7 SCAR=20.1
183 56 my ( $x, $p, $what ) = @_;
184 56 ▶ my $o = $x->{owner} // 'root';
Condition50%1/2
$$x{"owner"} // "root"
l!l
560
MC/DC0%0/1
$$x{"owner"} // "root"
$$x{"owner"}
Truth table50%1/2
A
A= $$x{"owner"}
Aresult
11
00
185 56 ▶ my $m = oct( $x->{mode} // ( $what eq 'file' ? '0644' : '0755' ) );
Branch: 1 branch
BranchTrueFalseTotal
$what eq 'file' ? : 0 0 0
Condition50%1/2
$$x{"mode"} // ($what eq "file" ? "0644" : "0755")
l!l
560
MC/DC0%0/1
$$x{"mode"} // ($what eq "file" ? "0644" : "0755")
$$x{"mode"}
Truth table50%1/2
A
A= $$x{"mode"}
Aresult
11
00
186 56 ▶ return "bad ownership or modes for $what $p" if ( $o ne $user && $o ne 'root' ) || ( $m & 022 );
Branch: 1 branch
BranchTrueFalseTotal
if $o ne $user and $o ne "root" or $m & 18 4 52 56
Condition100%6/6
$o ne $user and $o ne "root" or $m & 18
l!l&&r!l&&!r
1352
$o ne $user and $o ne "root"
!ll&&!rl&&r
5411
MC/DC100%3/3
$o ne $user and $o ne "root" or $m & 18
$o ne $user $o ne "root" $m & 18
Truth table80%4/5
A and B or C
A= $o ne $userB= $o ne "root"C= $m & 18
ABCresult
11X1
0X11
1011
0X00
1000
187 52 return undef;
188 20 };
189 20 my $bad = $chk->( $e, $file, 'file' );
190 20 ▶ return $bad if $bad;
Branch: 1 branch
BranchTrueFalseTotal
if $bad 2 18 20
191 18 ( my $d = $file ) =~ s{/[^/]+\z}{};
192 18 ▶ while ( length $d >= length $home ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $d >= length $home) 36 0 36
193 36 my ($de) = _entry( $dev, $d );
194 36 ▶ $de //= { mode => '0755', owner => $d eq $home ? $user : 'root' };
Branch: 1 branch
BranchTrueFalseTotal
$d eq $home ? : 0 0 0
Condition50%1/2
$de //= {"mode", "0755", "owner", $d eq $home ? $user : "root"}
l!l
360
MC/DC0%0/1
$de //= {"mode", "0755", "owner", $d eq $home ? $user : "root"}
$de
Truth table50%1/2
A
A= $de
Aresult
11
00
195 36 $bad = $chk->( $de, $d, 'directory' );
196 36 ▶ return $bad if $bad;
Branch: 1 branch
BranchTrueFalseTotal
if $bad 2 34 36
197 34 ▶ last if $d eq $home;
Branch: 1 branch
BranchTrueFalseTotal
if $d eq $home 16 18 34
198 18 ▶ $d =~ s{/[^/]+\z}{} or last;
Branch: 1 branch
BranchTrueFalseTotal
$d =~ s[/[^/]+\z][] or last 18 0 18
199 }
200 16 return undef;
201 }
202  
203 17 ▶sub _key_parts {
Subroutine _key_parts: called CC=9 SCAR=22.6
204 17 my ($line) = @_;
205 17 my @t;
206 17 my $s = $line;
207 17 ▶ while ( length $s ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $s) 55 17 72
208 55 $s =~ s/\A\s+//;
209 55 ▶ last unless length $s;
Branch: 1 branch
BranchTrueFalseTotal
unless length $s 0 55 55
210 0 ▶ if ( $s =~ s/\A((?:[^\s"]|"[^"]*")+)// ) { push @t, $1 } else { last }
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ s/\A((?:[^\s"]|"[^"]*")+)//) { } 55 0 55
211 }
212 17 my $i = 0;
213 17 ▶ $i++ while $i < @t && $t[$i] !~ /\A(?:ssh-|ecdsa-|sk-)/;
Branch: 1 branch
BranchTrueFalseTotal
$i < @t and not $t[$i] =~ /\A(?:ssh-|ecdsa-|sk-)/ and do { ++$i } 4 17 21
Condition66%2/3
$i < @t and not $t[$i] =~ /\A(?:ssh-|ecdsa-|sk-)/
!ll&&!rl&&r
0174
MC/DC50%1/2
$i < @t and not $t[$i] =~ /\A(?:ssh-|ecdsa-|sk-)/
$i < @t not $t[$i] =~ /\A(?:ssh-|ecdsa-|sk-)/
Truth table66%2/3
A and not(B)
A= $i < @tB= not $t[$i] =~ /\A(?:ssh-|ecdsa-|sk-)/
ABresult
0X0
100
111
214 17 ▶ return if $i >= @t;
Branch: 1 branch
BranchTrueFalseTotal
if $i >= @t 0 17 17
215 17 ▶ my $opts = $i ? $t[0] : '';
Branch: 1 branch
BranchTrueFalseTotal
$i ? : 4 13 17
216 17 ▶ return ( $opts, $t[$i], $t[ $i + 1 ] // '' );
Condition50%1/2
$t[$i + 1] // ""
l!l
170
MC/DC0%0/1
$t[$i + 1] // ""
$t[$i + 1]
Truth table50%1/2
A
A= $t[$i + 1]
Aresult
11
00
217 }
218  
219 11 ▶sub _from_ok {
Subroutine _from_ok: called CC=2 SCAR=6.9
220 11 my ( $opts, $from ) = @_;
221 11 ▶ return 1 unless $opts =~ /(?:\A|,)from="([^"]*)"/;
Branch: 1 branch
BranchTrueFalseTotal
unless $opts =~ /(?:\A|,)from="([^"]*)"/ 7 4 11
222 4 ▶ return _list_match( $1, sub { _ip_in( $from, $_[0] ) } );
Subroutine __ANON__: called CC=1 SCAR=0.0
223 }
224  
225  
226 30 ▶sub check {
Subroutine check: called CC=76 SCAR=54.0
Pod documented
227 30 my ( $dev, $t, $host ) = @_;
228 30 ▶ $host //= 'host';
Condition50%1/2
$host //= "host"
l!l
300
MC/DC0%0/1
$host //= "host"
$host
Truth table50%1/2
A
A= $host
Aresult
11
00
229 30 ▶ my $user = $t->{user} // 'root';
Condition50%1/2
$$t{"user"} // "root"
l!l
300
MC/DC0%0/1
$$t{"user"} // "root"
$$t{"user"}
Truth table50%1/2
A
A= $$t{"user"}
Aresult
11
00
230 30 ▶ my $from = $t->{from} // '0.0.0.0';
Condition50%1/2
$$t{"from"} // "0.0.0.0"
l!l
300
MC/DC0%0/1
$$t{"from"} // "0.0.0.0"
$$t{"from"}
Truth table50%1/2
A
A= $$t{"from"}
Aresult
11
00
231 30 ▶ my $port = $t->{port} // 22;
Condition100%2/2
$$t{"port"} // 22
l!l
624
MC/DC100%1/1
$$t{"port"} // 22
$$t{"port"}
Truth table100%2/2
A
A= $$t{"port"}
Aresult
11
00
232 30 my $sport = 50000 + ( unpack( '%16C*', "$user$from" ) % 10000 );
233 30 ▶ my $deny = sub { my ( $methods, @log ) = @_; return ( 0, "$user\@$host: Permission denied ($methods).", @log ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
234 30 my $svc = _svc($dev);
235 30 ▶ return ( 0, "ssh: connect to host $host port $port: Connection refused" ) unless $svc && $svc->{active};
Branch: 1 branch
BranchTrueFalseTotal
unless $svc and $$svc{"active"} 1 29 30
Condition66%2/3
$svc and $$svc{"active"}
!ll&&!rl&&r
0129
MC/DC50%1/2
$svc and $$svc{"active"}
$svc $$svc{"active"}
Truth table66%2/3
A and B
A= $svcB= $$svc{"active"}
ABresult
0X0
100
111
236 29 my $glob = config_for( $dev, { user => "\0", from => "\0", groups => [], port => $port } );
237 29 ▶ my @ports = @{ $glob->{port} || [22] };
Condition100%2/2
$$glob{'port'} || [22]
l!l
326
MC/DC100%1/1
$$glob{'port'} || [22]
$$glob{'port'}
Truth table100%2/2
A
A= $$glob{'port'}
Aresult
11
00
238 29 ▶ return ( 0, "ssh: connect to host $host port $port: Connection refused" ) unless grep { $_ == $port } @ports;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ == $port;} @ports 1 28 29
239 28 ▶ if ( ref $dev->{nft} eq 'HASH' && %{ $dev->{nft} } && defined $t->{daddr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $$dev{"nft"} eq "HASH" and %{$$dev{"nft"};} and defined $$t{"daddr"}) 2 26 28
Condition66%4/6
ref $$dev{"nft"} eq "HASH" and %{$$dev{"nft"};} and defined $$t{"daddr"}
!ll&&!rl&&r
2602
ref $$dev{"nft"} eq "HASH" and %{$$dev{"nft"};}
!ll&&!rl&&r
2602
MC/DC33%1/3
ref $$dev{"nft"} eq "HASH" and %{$$dev{"nft"};} and defined $$t{"daddr"}
ref $$dev{"nft"} eq "HASH" %{$$dev{"nft"};} defined $$t{"daddr"}
Truth table50%2/4
A and B and C
A= ref $$dev{"nft"} eq "HASH"B= %{$$dev{"nft"};}C= defined $$t{"daddr"}
ABCresult
0XX0
10X0
1100
1111
240 my ($v) = Langertha::Holmgang::Sim::Linux::Nft::verdict( $dev, { hook => 'input', proto => 'tcp', dport => $port, sport => $sport,
241 2 ▶ saddr => $from, daddr => $t->{daddr}, ( defined $t->{iif} ? ( iif => $t->{iif} ) : () ) } );
Branch: 1 branch
BranchTrueFalseTotal
defined $$t{'iif'} ? : 2 0 2
242 2 ▶ return ( 0, "ssh: connect to host $host port $port: Connection timed out" ) if defined $v && $v eq 'drop';
Branch: 1 branch
BranchTrueFalseTotal
if defined $v and $v eq "drop" 1 1 2
Condition66%2/3
defined $v and $v eq "drop"
!ll&&!rl&&r
011
MC/DC50%1/2
defined $v and $v eq "drop"
defined $v $v eq "drop"
Truth table66%2/3
A and B
A= defined $vB= $v eq "drop"
ABresult
0X0
100
111
243 }
244 0 ▶ my $u = $user eq 'root' ? { home => '/root', groups => ['root'], %{ ( $dev->{users} || {} )->{root} || {} } } : ( $dev->{users} || {} )->{$user};
Branch: 1 branch
BranchTrueFalseTotal
$user eq 'root' ? : 0 27 27
Condition16%1/6
($$dev{'users'} || {})->{'root'} || {}
l!l
00
$$dev{'users'} || {}
l!l
00
$$dev{'users'} || {}
l!l
270
MC/DC0%0/1
($$dev{'users'} || {})->{'root'} || {}
$$dev{'users'}
Truth table0%0/2
A
A= $$dev{'users'}
Aresult
11
00
245 27 my $conn = "from $from port $sport";
246 27 ▶ return $deny->( 'publickey', "Invalid user $user $conn", "Connection closed by invalid user $user $from port $sport [preauth]" ) unless $u;
Branch: 1 branch
BranchTrueFalseTotal
unless $u 1 26 27
247 26 ▶ my @groups = @{ $u->{groups} || [$user] };
Condition50%1/2
$$u{'groups'} || [$user]
l!l
260
MC/DC0%0/1
$$u{'groups'} || [$user]
$$u{'groups'}
Truth table50%1/2
A
A= $$u{'groups'}
Aresult
11
00
248 26 my $eff = config_for( $dev, { user => $user, from => $from, groups => \@groups, port => $port } );
249 my $methods = join ',', ( _yes( $eff->{pubkeyauthentication}, 'yes' ) ? 'publickey' : () ),
250 26 ▶ ( _yes( $eff->{passwordauthentication}, 'yes' ) ? 'password' : () );
Branch: 2 branches
BranchTrueFalseTotal
_yes($$eff{'pubkeyauthentication'}, 'yes') ? : 26 0 26
_yes($$eff{'passwordauthentication'}, 'yes') ? : 8 18 26
251 26 ▶ $methods ||= 'none';
Condition50%1/2
$methods ||= "none"
l!l
260
MC/DC0%0/1
$methods ||= "none"
$methods
Truth table50%1/2
A
A= $methods
Aresult
11
00
252 26 my $closed = "Connection closed by authenticating user $user $from port $sport [preauth]";
253 26 ▶ my $shell = $u->{shell} // '/bin/bash';
Condition50%1/2
$$u{"shell"} // "/bin/bash"
l!l
260
MC/DC0%0/1
$$u{"shell"} // "/bin/bash"
$$u{"shell"}
Truth table50%1/2
A
A= $$u{"shell"}
Aresult
11
00
254 26 ▶ return $deny->( $methods, "User $user not allowed because account has expired", $closed ) if $u->{expired};
Branch: 1 branch
BranchTrueFalseTotal
if $$u{"expired"} 0 26 26
255 26 ▶ return $deny->( $methods, "User $user not allowed because shell $shell does not exist", $closed ) if $shell =~ m{/(?:nologin|false)\z};
Branch: 1 branch
BranchTrueFalseTotal
if $shell =~ m[/(?:nologin|false)\z] 1 25 26
256 25 ▶ if ( $user eq 'root' && lc( $eff->{permitrootlogin} // 'prohibit-password' ) eq 'no' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($user eq "root" and lc($$eff{"permitrootlogin"} // "prohibit-password") eq "no") 0 25 25
Condition20%1/5
$user eq "root" and lc($$eff{"permitrootlogin"} // "prohibit-password") eq "no"
!ll&&!rl&&r
2500
$$eff{"permitrootlogin"} // "prohibit-password"
l!l
00
MC/DC0%0/2
$user eq "root" and lc($$eff{"permitrootlogin"} // "prohibit-password") eq "no"
$user eq "root" $$eff{"permitrootlogin"}
Truth table33%1/3
A and B
A= $user eq "root"B= $$eff{"permitrootlogin"}
ABresult
0X0
100
111
257 0 return $deny->( $methods, "ROOT LOGIN REFUSED $conn", $closed );
258 }
259 25 ▶ my $um = sub { my $p = shift; my ( $pu, $ph ) = split /@/, $p, 2; _pat( $pu, $user ) && ( !defined $ph || _ip_in( $from, $ph ) ) };
Subroutine __ANON__: called CC=3 SCAR=11.4
Branch: 1 branch
BranchTrueFalseTotal
_pat($pu, $user) and !defined($ph) || _ip_in($from, $ph) 1 3 4
Condition50%3/6
_pat($pu, $user) && (!defined($ph) || _ip_in($from, $ph))
!ll&&!rl&&r
301
not defined $ph or _ip_in($from, $ph)
l!l&&r!l&&!r
100
MC/DC33%1/3
_pat($pu, $user) && (!defined($ph) || _ip_in($from, $ph))
_pat($pu, $user) not defined $ph _ip_in($from, $ph)
Truth table50%2/4
A && not(B) or C
A= _pat($pu, $user)B= not defined $phC= _ip_in($from, $ph)
ABCresult
0XX0
1000
11X1
1011
260 0 ▶ my $gm = sub { my $p = shift; grep { _pat( $p, $_ ) } @groups };
Subroutine __ANON__: not called CC=1 SCAR=3.5
261 0 ▶ return $deny->( $methods, "User $user from $from not allowed because listed in DenyUsers", $closed ) if grep { $um->($_) } @{ $eff->{denyusers} || [] };
Branch: 1 branch
BranchTrueFalseTotal
if grep {&$um($_);} @{$$eff{"denyusers"} or [];} 0 25 25
Condition50%1/2
$$eff{'denyusers'} || []
l!l
025
MC/DC0%0/1
$$eff{'denyusers'} || []
$$eff{'denyusers'}
Truth table50%1/2
A
A= $$eff{'denyusers'}
Aresult
11
00
262 return $deny->( $methods, "User $user from $from not allowed because not listed in AllowUsers", $closed )
263 25 ▶ if $eff->{allowusers} && !grep { $um->($_) } @{ $eff->{allowusers} };
Branch: 1 branch
BranchTrueFalseTotal
if $$eff{"allowusers"} and not grep({&$um($_);} @{$$eff{"allowusers"};}) 2 23 25
Condition100%3/3
$$eff{"allowusers"} and not grep({&$um($_);} @{$$eff{"allowusers"};})
!ll&&!rl&&r
2212
MC/DC100%2/2
$$eff{"allowusers"} and not grep({&$um($_);} @{$$eff{"allowusers"};})
$$eff{"allowusers"} not grep({&$um($_);} @{$$eff{"allowusers"};})
Truth table100%3/3
A and not(B)
A= $$eff{"allowusers"}B= not grep({&$um($_);} @{$$eff{"allowusers"};})
ABresult
0X0
100
111
264 0 ▶ return $deny->( $methods, "User $user from $from not allowed because a group is listed in DenyGroups", $closed ) if grep { $gm->($_) } @{ $eff->{denygroups} || [] };
Branch: 1 branch
BranchTrueFalseTotal
if grep {&$gm($_);} @{$$eff{"denygroups"} or [];} 0 23 23
Condition50%1/2
$$eff{'denygroups'} || []
l!l
023
MC/DC0%0/1
$$eff{'denygroups'} || []
$$eff{'denygroups'}
Truth table50%1/2
A
A= $$eff{'denygroups'}
Aresult
11
00
265 return $deny->( $methods, "User $user from $from not allowed because none of user's groups are listed in AllowGroups", $closed )
266 0 ▶ if $eff->{allowgroups} && !grep { $gm->($_) } @{ $eff->{allowgroups} };
Branch: 1 branch
BranchTrueFalseTotal
if $$eff{"allowgroups"} and not grep({&$gm($_);} @{$$eff{"allowgroups"};}) 0 23 23
Condition33%1/3
$$eff{"allowgroups"} and not grep({&$gm($_);} @{$$eff{"allowgroups"};})
!ll&&!rl&&r
2300
MC/DC0%0/2
$$eff{"allowgroups"} and not grep({&$gm($_);} @{$$eff{"allowgroups"};})
$$eff{"allowgroups"} not grep({&$gm($_);} @{$$eff{"allowgroups"};})
Truth table33%1/3
A and not(B)
A= $$eff{"allowgroups"}B= not grep({&$gm($_);} @{$$eff{"allowgroups"};})
ABresult
0X0
100
111
267  
268 23 ▶ my $auth = $t->{auth} // 'publickey';
Condition100%2/2
$$t{"auth"} // "publickey"
l!l
221
MC/DC100%1/1
$$t{"auth"} // "publickey"
$$t{"auth"}
Truth table100%2/2
A
A= $$t{"auth"}
Aresult
11
00
269 23 ▶ if ( $auth eq 'password' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($auth eq "password") 2 21 23
270 2 ▶ return $deny->( $methods, $closed ) unless _yes( $eff->{passwordauthentication}, 'yes' ) && $u->{password} && !$u->{locked};
Branch: 1 branch
BranchTrueFalseTotal
unless _yes($$eff{"passwordauthentication"}, "yes") and $$u{"password"} and not $$u{"locked"} 1 1 2
Condition66%4/6
_yes($$eff{"passwordauthentication"}, "yes") and $$u{"password"} and not $$u{"locked"}
!ll&&!rl&&r
101
_yes($$eff{"passwordauthentication"}, "yes") and $$u{"password"}
!ll&&!rl&&r
101
MC/DC33%1/3
_yes($$eff{"passwordauthentication"}, "yes") and $$u{"password"} and not $$u{"locked"}
_yes($$eff{"passwordauthentication"}, "yes") $$u{"password"} not $$u{"locked"}
Truth table50%2/4
A and B and not(C)
A= _yes($$eff{"passwordauthentication"}, "yes")B= $$u{"password"}C= not $$u{"locked"}
ABCresult
0XX0
10X0
1100
1111
271 return $deny->( $methods, "Failed password for root $conn ssh2", $closed )
272 1 ▶ if $user eq 'root' && lc( $eff->{permitrootlogin} // 'prohibit-password' ) ne 'yes';
Branch: 1 branch
BranchTrueFalseTotal
if $user eq "root" and lc($$eff{"permitrootlogin"} // "prohibit-password") ne "yes" 0 1 1
Condition20%1/5
$user eq "root" and lc($$eff{"permitrootlogin"} // "prohibit-password") ne "yes"
!ll&&!rl&&r
100
$$eff{"permitrootlogin"} // "prohibit-password"
l!l
00
MC/DC0%0/2
$user eq "root" and lc($$eff{"permitrootlogin"} // "prohibit-password") ne "yes"
$user eq "root" $$eff{"permitrootlogin"}
Truth table33%1/3
A and B
A= $user eq "root"B= $$eff{"permitrootlogin"}
ABresult
0X0
100
111
273 1 return ( 1, "Linux $host 6.1.0-26-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.112-1 x86_64", "Accepted password for $user $conn ssh2" );
274 }
275 21 ▶ return $deny->( $methods, $closed ) unless _yes( $eff->{pubkeyauthentication}, 'yes' );
Branch: 1 branch
BranchTrueFalseTotal
unless _yes($$eff{"pubkeyauthentication"}, "yes") 0 21 21
276 21 ▶ my $home = $u->{home} // ( $user eq 'root' ? '/root' : "/home/$user" );
Branch: 1 branch
BranchTrueFalseTotal
$user eq 'root' ? : 0 0 0
Condition50%1/2
$$u{"home"} // ($user eq "root" ? "/root" : "/home/$user")
l!l
210
MC/DC0%0/1
$$u{"home"} // ($user eq "root" ? "/root" : "/home/$user")
$$u{"home"}
Truth table50%1/2
A
A= $$u{"home"}
Aresult
11
00
277 21 ▶ my @akf = @{ $eff->{authorizedkeysfile} || [qw( .ssh/authorized_keys .ssh/authorized_keys2 )] };
Condition100%2/2
$$eff{'authorizedkeysfile'} || ['.ssh/authorized_keys', '.ssh/authorized_keys2']
l!l
219
MC/DC100%1/1
$$eff{'authorizedkeysfile'} || ['.ssh/authorized_keys', '.ssh/authorized_keys2']
$$eff{'authorizedkeysfile'}
Truth table100%2/2
A
A= $$eff{'authorizedkeysfile'}
Aresult
11
00
278 21 my $strict = _yes( $eff->{strictmodes}, 'yes' );
279 21 ▶ my ( $ktype, $kblob ) = split /\s+/, $t->{key} // '';
Condition50%1/2
$$t{"key"} // ""
l!l
210
MC/DC0%0/1
$$t{"key"} // ""
$$t{"key"}
Truth table50%1/2
A
A= $$t{"key"}
Aresult
11
00
280 21 my @log;
281 21 for my $raw (@akf) {
282 33 ▶ next if lc $raw eq 'none';
Branch: 1 branch
BranchTrueFalseTotal
if lc $raw eq "none" 0 33 33
283 33 ( my $p = $raw ) =~ s/%h/$home/g;
284 33 $p =~ s/%u/$user/g;
285 33 $p =~ s/%%/%/g;
286 33 ▶ $p = "$home/$p" unless $p =~ m{\A/};
Branch: 1 branch
BranchTrueFalseTotal
unless $p =~ m[\A/] 32 1 33
287 33 my ($e) = _entry( $dev, $p );
288 33 ▶ next unless $e && defined $e->{content};
Branch: 1 branch
BranchTrueFalseTotal
unless $e and defined $$e{"content"} 13 20 33
Condition66%2/3
$e and defined $$e{"content"}
!ll&&!rl&&r
13020
MC/DC50%1/2
$e and defined $$e{"content"}
$e defined $$e{"content"}
Truth table66%2/3
A and B
A= $eB= defined $$e{"content"}
ABresult
0X0
100
111
289 20 ▶ if ($strict) {
Branch: 1 branch
BranchTrueFalseTotal
if ($strict) 20 0 20
290 20 ▶ if ( my $bad = _strict_bad( $dev, $user, $home, $p ) ) { push @log, "Authentication refused: $bad"; next }
Branch: 1 branch
BranchTrueFalseTotal
if (my $bad = _strict_bad($dev, $user, $home, $p)) 4 16 20
291 }
292 16 ▶ my $m = oct( $e->{mode} // '0644' );
Condition50%1/2
$$e{"mode"} // "0644"
l!l
160
MC/DC0%0/1
$$e{"mode"} // "0644"
$$e{"mode"}
Truth table50%1/2
A
A= $$e{"mode"}
Aresult
11
00
293 16 ▶ my $readable = ( $e->{owner} // 'root' ) eq $user ? ( $m & 0400 ) : ( $m & 0004 );
Branch: 1 branch
BranchTrueFalseTotal
($$e{'owner'} // 'root') eq $user ? : 16 0 16
Condition50%1/2
$$e{"owner"} // "root"
l!l
160
MC/DC0%0/1
$$e{"owner"} // "root"
$$e{"owner"}
Truth table50%1/2
A
A= $$e{"owner"}
Aresult
11
00
294 16 ▶ next unless $readable || $user eq 'root';
Branch: 1 branch
BranchTrueFalseTotal
unless $readable or $user eq "root" 0 16 16
Condition33%1/3
$readable or $user eq "root"
l!l&&r!l&&!r
1600
MC/DC0%0/2
$readable or $user eq "root"
$readable $user eq "root"
Truth table33%1/3
A or B
A= $readableB= $user eq "root"
ABresult
1X1
011
000
295 16 my $n = 0;
296 16 for my $line ( split /\n/, $e->{content} ) {
297 16 $n++;
298 16 ▶ next if $line =~ /\A\s*(?:#|\z)/;
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /\A\s*(?:#|\z)/ 0 16 16
299 16 ▶ my ( $opts, $type, $blob ) = _key_parts($line) or next;
Branch: 1 branch
BranchTrueFalseTotal
() = _key_parts($line) or next 16 0 16
300 16 ▶ next unless defined $ktype && $type eq $ktype && $blob eq ( $kblob // '' );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ktype and $type eq $ktype and $blob eq ($kblob // "") 5 11 16
Condition75%6/8
defined $ktype and $type eq $ktype and $blob eq ($kblob // "")
!ll&&!rl&&r
3211
defined $ktype and $type eq $ktype
!ll&&!rl&&r
3013
$kblob // ""
l!l
130
MC/DC66%2/3
defined $ktype and $type eq $ktype and $blob eq ($kblob // "")
defined $ktype $type eq $ktype $blob eq ($kblob // "")
MC/DC0%0/1
$kblob // ""
$kblob
Truth table75%3/4
A and B and C
A= defined $ktypeB= $type eq $ktypeC= $blob eq ($kblob // "")
ABCresult
0XX0
10X0
1100
1111
Truth table50%1/2
A
A= $kblob
Aresult
11
00
301 11 ▶ if ( $user eq 'root' && lc( $eff->{permitrootlogin} // '' ) eq 'forced-commands-only' && $opts !~ /(?:\A|,)command="/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($user eq "root" and lc($$eff{"permitrootlogin"} // "") eq "forced-commands-only" and not $opts =~ /(?:\A|,)command="/) 0 11 11
Condition25%2/8
$user eq "root" and lc($$eff{"permitrootlogin"} // "") eq "forced-commands-only" and not $opts =~ /(?:\A|,)command="/
!ll&&!rl&&r
1100
$user eq "root" and lc($$eff{"permitrootlogin"} // "") eq "forced-commands-only"
!ll&&!rl&&r
1100
$$eff{"permitrootlogin"} // ""
l!l
00
MC/DC0%0/3
$user eq "root" and lc($$eff{"permitrootlogin"} // "") eq "forced-commands-only" and not $opts =~ /(?:\A|,)command="/
$user eq "root" $$eff{"permitrootlogin"} not $opts =~ /(?:\A|,)command="/
Truth table25%1/4
A and B and not(C)
A= $user eq "root"B= $$eff{"permitrootlogin"}C= not $opts =~ /(?:\A|,)command="/
ABCresult
0XX0
10X0
1100
1111
302 0 push @log, "ROOT LOGIN REFUSED $conn";
303 0 next;
304 }
305 11 ▶ if ( !_from_ok( $opts, $from ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (_from_ok($opts, $from)) 3 8 11
306 3 push @log, "Authentication tried for $user with correct key but not from a permitted host (host=$from, ip=$from).";
307 3 next;
308 }
309 8 ▶ return ( 1, "Linux $host 6.1.0-26-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.112-1 x86_64",
Condition50%1/2
($type =~ /ssh-(\w+)/)[0] // "KEY"
l!l
80
MC/DC0%0/1
($type =~ /ssh-(\w+)/)[0] // "KEY"
($type =~ /ssh-(\w+)/)[0]
Truth table50%1/2
A
A= ($type =~ /ssh-(\w+)/)[0]
Aresult
11
00
310 "Accepted publickey for $user $conn ssh2: " . uc( ( $type =~ /ssh-(\w+)/ )[0] // 'KEY' ) . ' SHA256:' . substr( $blob, 12, 43 ) );
311 }
312 }
313 13 return $deny->( $methods, @log, $closed );
314 }
315  
316  
317 2 ▶sub journal {
Subroutine journal: called CC=5 SCAR=16.7
Pod documented
318 2 my ( $dev, $host ) = @_;
319 2 ▶ $host //= $dev->{hostname} // 'localhost';
Condition25%1/4
$host //= $$dev{"hostname"} // "localhost"
l!l
20
$$dev{"hostname"} // "localhost"
l!l
00
MC/DC0%0/1
$host //= $$dev{"hostname"} // "localhost"
$host
Truth table50%1/2
A
A= $host
Aresult
11
00
320 2 my @l;
321 2 my $min = 10;
322 2 ▶ for my $t ( @{ $dev->{ssh_tries} || [] } ) {
Condition50%1/2
$$dev{'ssh_tries'} || []
l!l
20
MC/DC0%0/1
$$dev{'ssh_tries'} || []
$$dev{'ssh_tries'}
Truth table50%1/2
A
A= $$dev{'ssh_tries'}
Aresult
11
00
323 2 my ( $ok, undef, @log ) = check( $dev, $t, $host );
324 2 push @l, map { sprintf( 'Oct 24 07:%02d:%02d %s sshd[%d]: %s', $min, 11, $host, 3100 + $min, $_ ) } @log;
325 2 $min++;
326 }
327 2 return @l;
328 }
329  
330 3 1;
331  
332 __END__
« blib/lib/Langertha/Holmgang/Sim/Linux/Sshd.pm ↑ Summary blib/lib/Langertha/Holmgang/Lint.pm »