Session/ID/SHA1.pm

filter: Statementstmt 95.0% 19 / 20 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 79.4% 27 / 34 CC 3 SCAR 7.2
CC
3
Cov
84%
generate_id
3.8
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Session/ID/MD5.pm ↑ Summary Session/Store/OnMemory.pm »
1 package HTTP::Session::ID::SHA1;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Digest::SHA ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Crypt::URandom ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 ▶sub generate_id {
Subroutine generate_id: called CC=3 SCAR=13.3
Pod undocumented
9 5 my ($class, $sid_length) = @_;
10 5 ▶ if ( !defined($sid_length) || $sid_length !~ /\A[1-9][0-9]*\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $sid_length and $sid_length =~ /\A[1-9][0-9]*\z/) 0 5 5
Condition33%1/3
defined $sid_length and $sid_length =~ /\A[1-9][0-9]*\z/
!ll&&!rl&&r
005
MC/DC0%0/2
defined $sid_length and $sid_length =~ /\A[1-9][0-9]*\z/
defined $sid_length $sid_length =~ /\A[1-9][0-9]*\z/
Truth table33%1/3
A and B
A= defined $sid_lengthB= $sid_length =~ /\A[1-9][0-9]*\z/
ABresult
0X0
100
111
11 0 Carp::croak "sid_length must be a positive integer";
12 }
13 # Hash cryptographically secure random bytes (CVE-2026-3256). sha1 output is
14 # 160 bits, so 20 random bytes fully seed it; preserves the legacy hex format.
15 5 return substr(Digest::SHA::sha1_hex(Crypt::URandom::urandom(20)), 0, $sid_length);
16 }
17  
18 2 1;
« Session/ID/MD5.pm ↑ Summary Session/Store/OnMemory.pm »