lib/Mogura/Protocol.pm

filter: Statementstmt 100% 21 / 21 Branchbran 50.0% 3 / 6 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 4 totaltotal 72.3% 34 / 47 CC 6 SCAR 8.7
CC
6
Cov
81%
valid_id
4.1
random_id
3.2
artifact_name
2.1
CRAP 2.4
« lib/Mogura/Server/I18N.pm ↑ Summary blib/lib/Mogura.pm »
1 package Mogura::Protocol;
2 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use POSIX qw(strftime);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 our @EXPORT_OK = qw(random_id valid_id now artifact_name);
7  
8 78 ▶sub random_id {
Subroutine random_id: called CC=3 SCAR=11.7
Pod undocumented
9 78 ▶ open my $fh, '<:raw', '/dev/urandom' or die "random: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<:raw", "/dev/urandom" or die "random: $!" 78 0 78
10 78 ▶ read($fh, my $bytes, 16) == 16 or die 'Random source unavailable';
Branch: 1 branch
BranchTrueFalseTotal
read($fh, my $bytes, 16) == 16 or die "Random source unavailable" 78 0 78
11 78 return unpack('H*', $bytes);
12 }
13 206 ▶sub now { strftime('%Y-%m-%dT%H:%M:%SZ', gmtime) }
Subroutine now: called CC=1 SCAR=0.0
Pod undocumented
14 1022 ▶sub valid_id { defined $_[0] && !ref($_[0]) && $_[0] =~ /\A[0-9a-f]{32}\z/ }
Subroutine valid_id: called CC=3 SCAR=14.2
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] and not ref $_[0] and $_[0] =~ /\A[0-9a-f]{32}\z/ 1022 0 1022
Condition33%1/3
defined $_[0] and not ref $_[0]
!ll&&!rl&&r
001022
MC/DC0%0/2
defined $_[0] and not ref $_[0]
defined $_[0] not ref $_[0]
Truth table33%1/3
A and not(B)
A= defined $_[0]B= not ref $_[0]
ABresult
0X0
100
111
15  
16 198 ▶sub artifact_name {
Subroutine artifact_name: called CC=2 SCAR=7.2
Pod undocumented
17 198 my %files = (
18 syft => 'sbom.syft.json',
19 cdx => 'sbom.cdx.json',
20 grype => 'vulnerabilities.grype.json',
21 log => 'scan.log'
22 );
23 198 ▶ return $files{$_[0] // ''};
Condition50%1/2
$_[0] // ""
l!l
1980
MC/DC0%0/1
$_[0] // ""
$_[0]
Truth table50%1/2
A
A= $_[0]
Aresult
11
00
24 }
25 8 1;
« lib/Mogura/Server/I18N.pm ↑ Summary blib/lib/Mogura.pm »