mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 16:28:38 +09:00
Add support for CSP v3 "worker-src" directive
This commit is contained in:
parent
7acf20ade3
commit
0665a343a5
23 changed files with 469 additions and 47 deletions
|
|
@ -230,7 +230,7 @@ CSP_ContentTypeToDirective(nsContentPolicyType aType)
|
|||
case nsIContentPolicy::TYPE_INTERNAL_WORKER:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER:
|
||||
case nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER:
|
||||
return nsIContentSecurityPolicy::CHILD_SRC_DIRECTIVE;
|
||||
return nsIContentSecurityPolicy::WORKER_SRC_DIRECTIVE;
|
||||
|
||||
case nsIContentPolicy::TYPE_SUBDOCUMENT:
|
||||
return nsIContentSecurityPolicy::FRAME_SRC_DIRECTIVE;
|
||||
|
|
@ -1184,6 +1184,11 @@ nsCSPDirective::toDomCSPStruct(mozilla::dom::CSP& outCSP) const
|
|||
outCSP.mSandbox.Value() = mozilla::Move(srcs);
|
||||
return;
|
||||
|
||||
case nsIContentSecurityPolicy::WORKER_SRC_DIRECTIVE:
|
||||
outCSP.mWorker_src.Construct();
|
||||
outCSP.mWorker_src.Value() = mozilla::Move(srcs);
|
||||
return;
|
||||
|
||||
// REFERRER_DIRECTIVE and REQUIRE_SRI_FOR are handled in nsCSPPolicy::toDomCSPStruct()
|
||||
|
||||
default:
|
||||
|
|
@ -1236,7 +1241,8 @@ bool nsCSPDirective::equals(CSPDirective aDirective) const
|
|||
|
||||
nsCSPChildSrcDirective::nsCSPChildSrcDirective(CSPDirective aDirective)
|
||||
: nsCSPDirective(aDirective)
|
||||
, mHandleFrameSrc(false)
|
||||
, mRestrictFrames(false)
|
||||
, mRestrictWorkers(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -1244,30 +1250,58 @@ nsCSPChildSrcDirective::~nsCSPChildSrcDirective()
|
|||
{
|
||||
}
|
||||
|
||||
void nsCSPChildSrcDirective::setHandleFrameSrc()
|
||||
{
|
||||
mHandleFrameSrc = true;
|
||||
}
|
||||
|
||||
bool nsCSPChildSrcDirective::restrictsContentType(nsContentPolicyType aContentType) const
|
||||
{
|
||||
if (aContentType == nsIContentPolicy::TYPE_SUBDOCUMENT) {
|
||||
return mHandleFrameSrc;
|
||||
return mRestrictFrames;
|
||||
}
|
||||
|
||||
return (aContentType == nsIContentPolicy::TYPE_INTERNAL_WORKER
|
||||
|| aContentType == nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER
|
||||
|| aContentType == nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER
|
||||
);
|
||||
if (aContentType == nsIContentPolicy::TYPE_INTERNAL_WORKER ||
|
||||
aContentType == nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER ||
|
||||
aContentType == nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER) {
|
||||
return mRestrictWorkers;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool nsCSPChildSrcDirective::equals(CSPDirective aDirective) const
|
||||
{
|
||||
if (aDirective == nsIContentSecurityPolicy::FRAME_SRC_DIRECTIVE) {
|
||||
return mHandleFrameSrc;
|
||||
return mRestrictFrames;
|
||||
}
|
||||
if (aDirective == nsIContentSecurityPolicy::WORKER_SRC_DIRECTIVE) {
|
||||
return mRestrictWorkers;
|
||||
}
|
||||
return (mDirective == aDirective);
|
||||
}
|
||||
|
||||
return (aDirective == nsIContentSecurityPolicy::CHILD_SRC_DIRECTIVE);
|
||||
/* =============== nsCSPScriptSrcDirective ============= */
|
||||
|
||||
nsCSPScriptSrcDirective::nsCSPScriptSrcDirective(CSPDirective aDirective)
|
||||
: nsCSPDirective(aDirective)
|
||||
, mRestrictWorkers(false)
|
||||
{
|
||||
}
|
||||
|
||||
nsCSPScriptSrcDirective::~nsCSPScriptSrcDirective()
|
||||
{
|
||||
}
|
||||
|
||||
bool nsCSPScriptSrcDirective::restrictsContentType(nsContentPolicyType aContentType) const
|
||||
{
|
||||
if (aContentType == nsIContentPolicy::TYPE_INTERNAL_WORKER ||
|
||||
aContentType == nsIContentPolicy::TYPE_INTERNAL_SHARED_WORKER ||
|
||||
aContentType == nsIContentPolicy::TYPE_INTERNAL_SERVICE_WORKER) {
|
||||
return mRestrictWorkers;
|
||||
}
|
||||
return mDirective == CSP_ContentTypeToDirective(aContentType);
|
||||
}
|
||||
|
||||
bool nsCSPScriptSrcDirective::equals(CSPDirective aDirective) const
|
||||
{
|
||||
if (aDirective == nsIContentSecurityPolicy::WORKER_SRC_DIRECTIVE) {
|
||||
return mRestrictWorkers;
|
||||
}
|
||||
return (mDirective == aDirective);
|
||||
}
|
||||
|
||||
/* =============== nsBlockAllMixedContentDirective ============= */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue