DirectiveHashCollection

final class \TYPO3\CMS\Core\Security\ContentSecurityPolicy\DirectiveHashCollection

Implements
JsonSerializable

Per-request registry collecting CSP hash values for inline and static assets.

Hash values are preferred over nonce values as they allow response caching.

Attributes

#[Autoconfigure]
$public: true

Table of Contents

Interfaces

JsonSerializable

Methods

__construct()  : mixed
addGenericHashValue()  : void
Stores an already-computed HashValue (e.g. parsed from an `integrity` attribute).
addInlineHash()  : void
Computes a SHA-256 hash of the given inline content and stores it for the directive.
addResourceHash()  : void
Lazily computes a hash from a local file identified by an EXT: path or absolute path.
asMutationCollections()  : array<int, MutationCollection>
Converts all stored hashes into MutationCollection instances that can be applied to the CSP.
isEmpty()  : bool
jsonSerialize()  : array
updateFromJson()  : void
Restores hash values from a previously serialized (cached) state.

Methods

addGenericHashValue()

Stores an already-computed HashValue (e.g. parsed from an `integrity` attribute).

public addGenericHashValue(Directive $directive, HashValue|string $hashValue) : void

Parameters

$directive : Directive
$hashValue : HashValue|string

addInlineHash()

Computes a SHA-256 hash of the given inline content and stores it for the directive.

public addInlineHash(Directive $directive, string $content) : void

Parameters

$directive : Directive
$content : string

asMutationCollections()

Converts all stored hashes into MutationCollection instances that can be applied to the CSP.

public asMutationCollections() : array<int, MutationCollection>

Hash values from all types are merged per directive.

Return values

array<int, MutationCollection>

isEmpty()

public isEmpty() : bool

Return values

bool

jsonSerialize()

public jsonSerialize() : array

Return values

array

updateFromJson()

Restores hash values from a previously serialized (cached) state.

public updateFromJson(array $data) : void

Parameters

$data : array
On this page