| 1 | # ABSTRACT: SHA-256 checks of downloaded release artifacts | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | package Rex::Rancher::Checksum; | ||||||||||||||||||||
| 4 | 63 | our $VERSION = '0.004'; | |||||||||||||||||||
| 5 | 63 | ▶ | use v5.14.4; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 63 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 17 | ▶ | sub expected_sha256 { | ||||||||||||||||||
|
Subroutine
expected_sha256: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||
| 10 | 17 | my ( $self, $sums_text, $asset ) = @_; | |||||||||||||||||||
| 11 | 17 | ▶ | for my $line (split /\n/, $sums_text // '') { | ||||||||||||||||||
|
Condition100%2/2
$sums_text // ""
MC/DC100%1/1
$sums_text // ""
$sums_text
Truth table100%2/2
A
A= $sums_text
| |||||||||||||||||||||
| 12 | 25 | ▶ | return lc $1 if $line =~ /\A\s*([0-9a-fA-F]{64})\s+\*?\Q$asset\E\s*\z/; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 13 | } | ||||||||||||||||||||
| 14 | 6 | return; | |||||||||||||||||||
| 15 | } | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | 10 | ▶ | sub sha256_of { | ||||||||||||||||||
|
Subroutine
sha256_of: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||
| 19 | 10 | my ( $self, $out ) = @_; | |||||||||||||||||||
| 20 | 10 | ▶ | return lc $1 if ($out // '') =~ /\A\s*([0-9a-fA-F]{64})\b/; | ||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$out // ""
MC/DC0%0/1
$out // ""
$out
Truth table50%1/2
A
A= $out
| |||||||||||||||||||||
| 21 | 1 | return; | |||||||||||||||||||
| 22 | } | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 16 | ▶ | sub verify_sha256 { | ||||||||||||||||||
|
Subroutine
verify_sha256: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||
| 26 | 16 | my ( $self, $expected, $actual, $asset ) = @_; | |||||||||||||||||||
| 27 | 16 | ▶ | die "No checksum for $asset in the release's sha256sum file\n" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | unless defined $expected; | ||||||||||||||||||||
| 29 | 11 | ▶ | die "Could not compute sha256 of downloaded $asset\n" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | unless defined $actual; | ||||||||||||||||||||
| 31 | 10 | ▶ | die "Checksum mismatch for $asset: expected $expected, got $actual\n" | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | unless $expected eq $actual; | ||||||||||||||||||||
| 33 | 5 | return 1; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 63 | 1; | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | __END__ | ||||||||||||||||||||