View | Details | Raw Unified | Return to bug 38365
Collapse All | Expand All

(-)a/Koha/ContentSecurityPolicy.pm (-1 / +1 lines)
Lines 197-203 sub nonce { Link Here
197
    }
197
    }
198
198
199
    unless ( $self->{nonce} ) {
199
    unless ( $self->{nonce} ) {
200
        $nonce = Koha::Token->new()->generate( { pattern => '\w{10}' } );
200
        $nonce = Koha::Token->new()->generate( { pattern => '\w{22}' } );
201
        $self->{nonce} = $nonce;
201
        $self->{nonce} = $nonce;
202
    }
202
    }
203
203
(-)a/t/Koha/ContentSecurityPolicy.t (-2 / +1 lines)
Lines 168-174 subtest 'nonce tests' => sub { Link Here
168
168
169
    $csp = Koha::ContentSecurityPolicy->new();
169
    $csp = Koha::ContentSecurityPolicy->new();
170
    my $nonce = $csp->nonce;
170
    my $nonce = $csp->nonce;
171
    like( $nonce, qr/\w{10}/, 'nonce is a random string of 10 characters' );
171
    like( $nonce, qr/\w{22}/, 'nonce is a random string of 22 characters (128+ bits entropy)' );
172
    is( $nonce, $csp->nonce, 're-calling nonce() returns the same randomly generated cached value' );
172
    is( $nonce, $csp->nonce, 're-calling nonce() returns the same randomly generated cached value' );
173
173
174
    $cache->set_in_cache( 'CSP-NONCE', 'cached value' );
174
    $cache->set_in_cache( 'CSP-NONCE', 'cached value' );
175
- 

Return to bug 38365