| 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
Condition33%1/3
defined $sid_length and $sid_length =~ /\A[1-9][0-9]*\z/
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/
| |||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||