blib/lib/StorageDisplay/Data/LUKS.pm

filter: Statementstmt 90.8% 99 / 109 Branchbran 50.0% 1 / 2 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 88.0% 22 / 25 Podpod 0.0% 0 / 9 totaltotal 83.1% 123 / 148 CC 3 SCAR 2.3
CC
3
Cov
89%
BUILD
2.0
__ANON__
2.0
__ANON__
2.0
CRAP 1.3
« blib/lib/StorageDisplay/Collect/CMD/Remote.pm ↑ Summary
1 #
2 # This file is part of StorageDisplay
3 #
4 # This software is copyright (c) 2014-2023 by Vincent Danjean.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 package StorageDisplay::Data::LUKS;
13 # ABSTRACT: Handle LUKS data for StorageDisplay
14  
15 9 our $VERSION = '2.06'; # VERSION
16  
17 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 9 extends 'StorageDisplay::Data::Elem';
20  
21 9 with (
22 'StorageDisplay::Role::HasBlock',
23 'StorageDisplay::Role::Style::IsSubGraph',
24 'StorageDisplay::Role::Style::Grey',
25 );
26  
27 9 has 'encrypted' => (
28 is => 'ro',
29 isa => 'StorageDisplay::Data::LUKS::Encrypted',
30 writer => '_encrypted',
31 required => 0,
32 );
33  
34 9 has 'decrypted' => (
35 is => 'ro',
36 isa => 'StorageDisplay::Data::LUKS::Decrypted',
37 writer => '_decrypted',
38 required => 0,
39 );
40  
41 9 has 'luks_version' => (
42 is => 'ro',
43 isa => 'Str',
44 required => 1,
45 );
46  
47 5 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
48 5 my $orig = shift;
49 5 my $class = shift;
50 5 my $devname = shift;
51 5 my $st = shift;
52  
53 #$st->get_infos
54 5 $st->log({level=>1}, 'LUKS for device '.$devname);
55  
56 5 my $info = $st->get_info('luks', $devname);
57 5 my $block = $st->block($devname);
58  
59 return $class->$orig(
60 'name' => $block->name,
61 'block' => $block,
62 'consume' => [],
63 'st' => $st,
64 'luks-info' => $info,
65 'luks_version' => $info->{VERSION},
66 @_
67 5 );
68 9 };
69  
70 5 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=7.1
Pod undocumented
71 5 my $self=shift;
72 5 my $args=shift;
73 5 my $st = $args->{st};
74  
75 $self->_encrypted($self->newChild('LUKS::Encrypted',
76 5 $self, $st, $args->{'luks-info'}));
77 5 ▶ if (defined($args->{'luks-info'}->{decrypted})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args->{'luks-info'}{'decrypted'}) { } 5 0 5
78 $self->_decrypted(
79 $self->newChild('LUKS::Decrypted::Present',
80 5 $self, $st, $args->{'luks-info'}));
81 } else {
82 $self->_decrypted(
83 $self->newChild('LUKS::Decrypted::None',
84 0 $self, $st, $args->{'luks-info'}));
85 }
86 5 return $self;
87 };
88  
89 10 ▶sub dname {
Subroutine dname: called CC=1 SCAR=0.0
Pod undocumented
90 10 my $self=shift;
91 10 return 'LUKS: '.$self->block->dname;
92 }
93  
94 10 ▶sub dotLabel {
Subroutine dotLabel: called CC=1 SCAR=0.0
Pod undocumented
95 10 my $self = shift;
96 return (
97 10 $self->block->dname,
98 'LUKS version '.$self->luks_version,
99 );
100 }
101  
102 5 ▶sub dotLinks {
Subroutine dotLinks: called CC=1 SCAR=0.0
Pod undocumented
103 5 my $self = shift;
104 return (
105 5 $self->encrypted->linkname.' -> '.$self->decrypted->linkname
106 );
107 }
108  
109 9 1;
110  
111 ##################################################################
112 package StorageDisplay::Data::LUKS::Encrypted;
113  
114 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
115 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
116 9 extends 'StorageDisplay::Data::Elem';
117  
118 9 with (
119 'StorageDisplay::Role::HasBlock',
120 'StorageDisplay::Role::Style::WithSize',
121 'StorageDisplay::Role::Style::FromBlockState',
122 );
123  
124 5 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
125 5 my $orig = shift;
126 5 my $class = shift;
127 5 my $luks = shift;
128 5 my $st = shift;
129 5 my $info = shift;
130  
131 5 my $block = $luks->block;
132  
133 5 return $class->$orig(
134 'name' => $block->name,
135 'consume' => [$block],
136 'block' => $block,
137 'size' => $st->get_info('lsblk', $block->name, 'size'),
138 @_
139 );
140 9 };
141  
142 10 ▶sub dotLabel {
Subroutine dotLabel: called CC=1 SCAR=0.0
Pod undocumented
143 10 my $self = shift;
144 10 return ($self->block->dname);
145 }
146  
147 9 1;
148  
149 ##################################################################
150 package StorageDisplay::Data::LUKS::Decrypted;
151  
152 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
153 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
154 9 extends 'StorageDisplay::Data::Elem';
155  
156 9 1;
157  
158 ##################################################################
159 package StorageDisplay::Data::LUKS::Decrypted::Present;
160  
161 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
162 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
163 9 extends 'StorageDisplay::Data::LUKS::Decrypted';
164  
165 9 with (
166 'StorageDisplay::Role::HasBlock',
167 'StorageDisplay::Role::Style::WithSize',
168 'StorageDisplay::Role::Style::FromBlockState',
169 );
170  
171 5 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=2 SCAR=7.0
172 5 my $orig = shift;
173 5 my $class = shift;
174 5 my $luks = shift;
175 5 my $st = shift;
176 5 my $info = shift;
177  
178 5 ▶ my $block = $st->block($info->{'decrypted'}//($luks->name."none"));
Condition50%1/2
$info->{"decrypted"} // $luks->name . 'none'
l!l
50
MC/DC0%0/1
$info->{"decrypted"} // $luks->name . 'none'
$info->{"decrypted"}
Truth table50%1/2
A
A= $info->{"decrypted"}
Aresult
11
00
179  
180 5 return $class->$orig(
181 'name' => $block->name,
182 'consume' => [],
183 'block' => $block,
184 'size' => $st->get_info('lsblk', $block->name, 'size'),
185 @_
186 );
187 9 };
188  
189 5 ▶sub BUILD {
Subroutine BUILD: called CC=1 SCAR=0.0
Pod undocumented
190 5 my $self = shift;
191 5 $self->provideBlock($self->block);
192 }
193  
194 10 ▶sub dotLabel {
Subroutine dotLabel: called CC=1 SCAR=0.0
Pod undocumented
195 10 my $self = shift;
196 10 return ($self->block->dname);
197 }
198  
199 9 1;
200  
201 ##################################################################
202 package StorageDisplay::Data::LUKS::Decrypted::None;
203  
204 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
205 9 ▶use namespace::sweep;
Subroutine BEGIN: called CC=1 SCAR=0.0
206 9 extends 'StorageDisplay::Data::LUKS::Decrypted';
207  
208 9 with (
209 'StorageDisplay::Role::Style::Plain',
210 );
211  
212 0 ▶around BUILDARGS => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
213 0 my $orig = shift;
214 0 my $class = shift;
215 0 my $luks = shift;
216 0 my $st = shift;
217 0 my $info = shift;
218  
219 0 return $class->$orig(
220 'name' => $luks->name."@@",
221 'consume' => [],
222 @_
223 );
224 9 };
225  
226 0 ▶sub BUILD {
Subroutine BUILD: not called CC=1 SCAR=6.9
Pod undocumented
227 0 my $self = shift;
228 }
229  
230 0 ▶sub dotLabel {
Subroutine dotLabel: not called CC=1 SCAR=6.9
Pod undocumented
231 0 my $self = shift;
232 0 return ('Not decrypted');
233 }
234  
235 9 1;
236  
237 __END__
« blib/lib/StorageDisplay/Collect/CMD/Remote.pm ↑ Summary