Session/ID/MD5.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/Store/File.pm ↑ Summary Session/ID/SHA1.pm »
1 package HTTP::Session::ID::MD5;
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::MD5 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Crypt::URandom ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 # Digest::MD5 was first released with perl 5.007003
9  
10 5 ▶sub generate_id {
Subroutine generate_id: called CC=3 SCAR=13.3
Pod undocumented
11 5 my ($class, $sid_length) = @_;
12 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
13 0 Carp::croak "sid_length must be a positive integer";
14 }
15 # Hash cryptographically secure random bytes (CVE-2026-3256). md5 output is
16 # 128 bits, so 16 random bytes fully seed it; preserves the legacy hex format.
17 5 return substr(Digest::MD5::md5_hex(Crypt::URandom::urandom(16)), 0, $sid_length);
18 }
19  
20 2 1;
« Session/Store/File.pm ↑ Summary Session/ID/SHA1.pm »