Bug 1409200 - Add integrityMetadata to nsILoadInfo. r=freddyb,necko-reviewers,kershaw

Differential Revision: https://phabricator.services.mozilla.com/D179822
This commit is contained in:
Tom Schuster
2023-06-09 18:39:59 +00:00
parent 95185daa71
commit e23d4b4e78
7 changed files with 57 additions and 8 deletions

View File

@@ -407,6 +407,12 @@ nsresult ScriptLoader::CheckContentPolicy(Document* aDocument,
requestingNode, nsILoadInfo::SEC_ONLY_FOR_EXPLICIT_CONTENTSEC_CHECK,
contentPolicyType);
if (aRequest->mIntegrity.IsValid()) {
MOZ_ASSERT(!aRequest->mIntegrity.IsEmpty());
secCheckLoadInfo->SetIntegrityMetadata(
aRequest->mIntegrity.GetIntegrityString());
}
// snapshot the nonce at load start time for performing CSP checks
if (contentPolicyType == nsIContentPolicy::TYPE_INTERNAL_SCRIPT ||
contentPolicyType == nsIContentPolicy::TYPE_INTERNAL_MODULE) {
@@ -623,6 +629,12 @@ nsresult ScriptLoader::StartLoadInternal(
NS_ENSURE_SUCCESS(rv, rv);
}
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
if (aRequest->mIntegrity.IsValid()) {
MOZ_ASSERT(!aRequest->mIntegrity.IsEmpty());
loadInfo->SetIntegrityMetadata(aRequest->mIntegrity.GetIntegrityString());
}
// snapshot the nonce at load start time for performing CSP checks
if (contentPolicyType == nsIContentPolicy::TYPE_INTERNAL_SCRIPT ||
contentPolicyType == nsIContentPolicy::TYPE_INTERNAL_MODULE) {
@@ -630,7 +642,6 @@ nsresult ScriptLoader::StartLoadInternal(
nsString* cspNonce =
static_cast<nsString*>(context->GetProperty(nsGkAtoms::nonce));
if (cspNonce) {
nsCOMPtr<nsILoadInfo> loadInfo = channel->LoadInfo();
loadInfo->SetCspNonce(*cspNonce);
}
}