2014-07-10 10:56:37 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2015-02-13 22:36:47 +03:00
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-07-10 10:56:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#include "mozilla/LoadInfo.h"
|
|
|
|
|
|
|
|
#include "mozilla/Assertions.h"
|
2015-07-20 05:11:03 +03:00
|
|
|
#include "mozilla/dom/ToJSValue.h"
|
2015-12-01 00:25:29 +03:00
|
|
|
#include "mozIThirdPartyUtil.h"
|
2015-05-08 22:52:49 +03:00
|
|
|
#include "nsFrameLoader.h"
|
2016-05-31 12:14:00 +03:00
|
|
|
#include "nsIContentSecurityPolicy.h"
|
2015-05-08 22:52:49 +03:00
|
|
|
#include "nsIDocShell.h"
|
2014-07-17 00:16:12 +04:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
2015-05-08 22:52:49 +03:00
|
|
|
#include "nsIFrameLoader.h"
|
2016-01-09 04:20:50 +03:00
|
|
|
#include "nsIInterfaceRequestorUtils.h"
|
2014-07-10 10:56:37 +04:00
|
|
|
#include "nsISupportsImpl.h"
|
|
|
|
#include "nsISupportsUtils.h"
|
2015-06-17 07:18:16 +03:00
|
|
|
#include "nsContentUtils.h"
|
2016-04-14 02:30:16 +03:00
|
|
|
#include "nsDocShell.h"
|
2015-12-01 00:25:29 +03:00
|
|
|
#include "nsGlobalWindow.h"
|
2017-03-22 13:38:40 +03:00
|
|
|
#include "NullPrincipal.h"
|
2017-05-25 20:42:00 +03:00
|
|
|
#include "nsRedirectHistoryEntry.h"
|
2014-07-10 10:56:37 +04:00
|
|
|
|
2016-01-09 04:20:50 +03:00
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
2014-07-10 10:56:37 +04:00
|
|
|
namespace mozilla {
|
2016-05-19 05:02:57 +03:00
|
|
|
namespace net {
|
2014-07-10 10:56:37 +04:00
|
|
|
|
2014-11-14 19:55:59 +03:00
|
|
|
LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
|
|
|
nsIPrincipal* aTriggeringPrincipal,
|
2014-07-17 00:16:12 +04:00
|
|
|
nsINode* aLoadingContext,
|
|
|
|
nsSecurityFlags aSecurityFlags,
|
2015-08-19 20:43:30 +03:00
|
|
|
nsContentPolicyType aContentPolicyType)
|
2014-12-11 02:36:03 +03:00
|
|
|
: mLoadingPrincipal(aLoadingContext ?
|
|
|
|
aLoadingContext->NodePrincipal() : aLoadingPrincipal)
|
2014-11-14 19:55:59 +03:00
|
|
|
, mTriggeringPrincipal(aTriggeringPrincipal ?
|
2014-12-11 02:36:03 +03:00
|
|
|
aTriggeringPrincipal : mLoadingPrincipal.get())
|
2016-11-08 09:23:12 +03:00
|
|
|
, mPrincipalToInherit(nullptr)
|
2014-07-17 00:16:12 +04:00
|
|
|
, mLoadingContext(do_GetWeakReference(aLoadingContext))
|
2017-09-05 19:01:07 +03:00
|
|
|
, mContextForTopLevelLoad(nullptr)
|
2014-07-17 00:16:12 +04:00
|
|
|
, mSecurityFlags(aSecurityFlags)
|
2015-10-19 21:14:54 +03:00
|
|
|
, mInternalContentPolicyType(aContentPolicyType)
|
2015-10-22 21:07:32 +03:00
|
|
|
, mTainting(LoadTainting::Basic)
|
2015-07-10 23:57:55 +03:00
|
|
|
, mUpgradeInsecureRequests(false)
|
2016-03-14 13:56:52 +03:00
|
|
|
, mVerifySignedContent(false)
|
2016-03-16 06:13:26 +03:00
|
|
|
, mEnforceSRI(false)
|
2016-07-18 09:35:13 +03:00
|
|
|
, mForceInheritPrincipalDropped(false)
|
2015-05-08 22:52:49 +03:00
|
|
|
, mInnerWindowID(0)
|
|
|
|
, mOuterWindowID(0)
|
|
|
|
, mParentOuterWindowID(0)
|
2016-06-27 03:42:00 +03:00
|
|
|
, mFrameOuterWindowID(0)
|
2015-07-20 05:11:57 +03:00
|
|
|
, mEnforceSecurity(false)
|
|
|
|
, mInitialSecurityCheckDone(false)
|
2016-03-26 00:47:31 +03:00
|
|
|
, mIsThirdPartyContext(false)
|
2015-12-07 02:33:14 +03:00
|
|
|
, mForcePreflight(false)
|
|
|
|
, mIsPreflight(false)
|
Bug 1246540 - HSTS Priming Proof of Concept. r=ckerschb, r=mayhemer, r=jld, r=smaug, r=dkeeler, r=jmaher, p=ally
HSTS priming changes the order of mixed-content blocking and HSTS
upgrades, and adds a priming request to check if a mixed-content load is
accesible over HTTPS and the server supports upgrading via the
Strict-Transport-Security header.
Every call site that uses AsyncOpen2 passes through the mixed-content
blocker, and has a LoadInfo. If the mixed-content blocker marks the load as
needing HSTS priming, nsHttpChannel will build and send an HSTS priming
request on the same URI with the scheme upgraded to HTTPS. If the server
allows the upgrade, then channel performs an internal redirect to the HTTPS URI,
otherwise use the result of mixed-content blocker to allow or block the
load.
nsISiteSecurityService adds an optional boolean out parameter to
determine if the HSTS state is already cached for negative assertions.
If the host has been probed within the previous 24 hours, no HSTS
priming check will be sent.
MozReview-Commit-ID: ES1JruCtDdX
--HG--
extra : rebase_source : 2ac6c93c49f2862fc0b9e595eb0598cd1ea4bedf
2016-09-27 18:27:00 +03:00
|
|
|
, mForceHSTSPriming(false)
|
|
|
|
, mMixedContentWouldBlock(false)
|
2017-05-10 01:36:07 +03:00
|
|
|
, mIsHSTSPriming(false)
|
|
|
|
, mIsHSTSPrimingUpgrade(false)
|
2014-07-10 10:56:37 +04:00
|
|
|
{
|
2014-12-11 02:36:03 +03:00
|
|
|
MOZ_ASSERT(mLoadingPrincipal);
|
2014-11-14 19:55:59 +03:00
|
|
|
MOZ_ASSERT(mTriggeringPrincipal);
|
2016-04-14 02:30:36 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
// TYPE_DOCUMENT loads initiated by javascript tests will go through
|
|
|
|
// nsIOService and use the wrong constructor. Don't enforce the
|
|
|
|
// !TYPE_DOCUMENT check in those cases
|
|
|
|
bool skipContentTypeCheck = false;
|
|
|
|
skipContentTypeCheck = Preferences::GetBool("network.loadinfo.skip_type_assertion");
|
|
|
|
#endif
|
|
|
|
|
2016-04-14 02:30:16 +03:00
|
|
|
// This constructor shouldn't be used for TYPE_DOCUMENT loads that don't
|
|
|
|
// have a loadingPrincipal
|
2016-04-14 02:30:36 +03:00
|
|
|
MOZ_ASSERT(skipContentTypeCheck ||
|
|
|
|
mInternalContentPolicyType != nsIContentPolicy::TYPE_DOCUMENT);
|
2014-12-11 02:36:03 +03:00
|
|
|
|
2016-03-26 00:47:31 +03:00
|
|
|
// TODO(bug 1259873): Above, we initialize mIsThirdPartyContext to false meaning
|
|
|
|
// that consumers of LoadInfo that don't pass a context or pass a context from
|
|
|
|
// which we can't find a window will default to assuming that they're 1st
|
|
|
|
// party. It would be nice if we could default "safe" and assume that we are
|
|
|
|
// 3rd party until proven otherwise.
|
|
|
|
|
2014-12-11 02:36:03 +03:00
|
|
|
// if consumers pass both, aLoadingContext and aLoadingPrincipal
|
|
|
|
// then the loadingPrincipal must be the same as the node's principal
|
|
|
|
MOZ_ASSERT(!aLoadingContext || !aLoadingPrincipal ||
|
|
|
|
aLoadingContext->NodePrincipal() == aLoadingPrincipal);
|
|
|
|
|
2014-07-17 00:16:12 +04:00
|
|
|
// if the load is sandboxed, we can not also inherit the principal
|
|
|
|
if (mSecurityFlags & nsILoadInfo::SEC_SANDBOXED) {
|
2017-01-10 22:46:30 +03:00
|
|
|
mForceInheritPrincipalDropped =
|
|
|
|
(mSecurityFlags & nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL);
|
|
|
|
mSecurityFlags &= ~nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
|
2014-07-17 00:16:12 +04:00
|
|
|
}
|
2015-05-08 22:52:49 +03:00
|
|
|
|
|
|
|
if (aLoadingContext) {
|
2016-03-12 07:28:00 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> contextOuter = aLoadingContext->OwnerDoc()->GetWindow();
|
|
|
|
if (contextOuter) {
|
|
|
|
ComputeIsThirdPartyContext(contextOuter);
|
2016-06-27 03:42:00 +03:00
|
|
|
mOuterWindowID = contextOuter->WindowID();
|
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> parent = contextOuter->GetScriptableParent();
|
|
|
|
mParentOuterWindowID = parent ? parent->WindowID() : mOuterWindowID;
|
2016-03-12 07:28:00 +03:00
|
|
|
}
|
|
|
|
|
2016-06-27 03:42:00 +03:00
|
|
|
mInnerWindowID = aLoadingContext->OwnerDoc()->InnerWindowID();
|
2015-05-08 22:52:49 +03:00
|
|
|
|
|
|
|
// When the element being loaded is a frame, we choose the frame's window
|
|
|
|
// for the window ID and the frame element's window as the parent
|
|
|
|
// window. This is the behavior that Chrome exposes to add-ons.
|
2016-03-12 07:28:00 +03:00
|
|
|
// NB: If the frameLoaderOwner doesn't have a frame loader, then the load
|
|
|
|
// must be coming from an object (such as a plugin) that's loaded into it
|
|
|
|
// instead of a document being loaded. In that case, treat this object like
|
|
|
|
// any other non-document-loading element.
|
|
|
|
nsCOMPtr<nsIFrameLoaderOwner> frameLoaderOwner =
|
|
|
|
do_QueryInterface(aLoadingContext);
|
|
|
|
nsCOMPtr<nsIFrameLoader> fl = frameLoaderOwner ?
|
|
|
|
frameLoaderOwner->GetFrameLoader() : nullptr;
|
|
|
|
if (fl) {
|
2015-05-08 22:52:49 +03:00
|
|
|
nsCOMPtr<nsIDocShell> docShell;
|
2016-03-12 07:28:00 +03:00
|
|
|
if (NS_SUCCEEDED(fl->GetDocShell(getter_AddRefs(docShell))) && docShell) {
|
2016-06-27 03:42:00 +03:00
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> outerWindow = do_GetInterface(docShell);
|
|
|
|
if (outerWindow) {
|
|
|
|
mFrameOuterWindowID = outerWindow->WindowID();
|
|
|
|
}
|
2015-05-08 22:52:49 +03:00
|
|
|
}
|
|
|
|
}
|
2015-07-10 23:57:55 +03:00
|
|
|
|
2016-01-14 23:38:15 +03:00
|
|
|
// if the document forces all requests to be upgraded from http to https, then
|
|
|
|
// we should do that for all requests. If it only forces preloads to be upgraded
|
|
|
|
// then we should enforce upgrade insecure requests only for preloads.
|
|
|
|
mUpgradeInsecureRequests =
|
|
|
|
aLoadingContext->OwnerDoc()->GetUpgradeInsecureRequests(false) ||
|
|
|
|
(nsContentUtils::IsPreloadType(mInternalContentPolicyType) &&
|
|
|
|
aLoadingContext->OwnerDoc()->GetUpgradeInsecureRequests(true));
|
2016-03-16 06:13:26 +03:00
|
|
|
|
|
|
|
// if owner doc has content signature, we enforce SRI
|
|
|
|
nsCOMPtr<nsIChannel> channel = aLoadingContext->OwnerDoc()->GetChannel();
|
|
|
|
if (channel) {
|
|
|
|
nsCOMPtr<nsILoadInfo> loadInfo = channel->GetLoadInfo();
|
|
|
|
if (loadInfo) {
|
2016-08-12 08:19:29 +03:00
|
|
|
mEnforceSRI = loadInfo->GetVerifySignedContent();
|
2016-03-16 06:13:26 +03:00
|
|
|
}
|
|
|
|
}
|
2015-05-08 22:52:49 +03:00
|
|
|
}
|
2015-10-22 00:47:00 +03:00
|
|
|
|
2017-03-08 09:41:20 +03:00
|
|
|
// If CSP requires SRI (require-sri-for), then store that information
|
|
|
|
// in the loadInfo so we can enforce SRI before loading the subresource.
|
|
|
|
if (!mEnforceSRI) {
|
|
|
|
// do not look into the CSP if already true:
|
|
|
|
// a CSP saying that SRI isn't needed should not
|
|
|
|
// overrule GetVerifySignedContent
|
|
|
|
if (aLoadingPrincipal) {
|
|
|
|
nsCOMPtr<nsIContentSecurityPolicy> csp;
|
|
|
|
aLoadingPrincipal->GetCsp(getter_AddRefs(csp));
|
|
|
|
uint32_t externalType =
|
|
|
|
nsContentUtils::InternalContentPolicyTypeToExternal(aContentPolicyType);
|
|
|
|
// csp could be null if loading principal is system principal
|
|
|
|
if (csp) {
|
|
|
|
csp->RequireSRIForType(externalType, &mEnforceSRI);
|
|
|
|
}
|
|
|
|
// if CSP is delivered via a meta tag, it's speculatively available
|
|
|
|
// as 'preloadCSP'. If we are preloading a script or style, we have
|
|
|
|
// to apply that speculative 'preloadCSP' for such loads.
|
|
|
|
if (!mEnforceSRI && nsContentUtils::IsPreloadType(aContentPolicyType)) {
|
|
|
|
nsCOMPtr<nsIContentSecurityPolicy> preloadCSP;
|
|
|
|
aLoadingPrincipal->GetPreloadCsp(getter_AddRefs(preloadCSP));
|
|
|
|
if (preloadCSP) {
|
|
|
|
preloadCSP->RequireSRIForType(externalType, &mEnforceSRI);
|
2016-05-31 12:14:00 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-03-08 09:41:20 +03:00
|
|
|
}
|
2016-05-31 12:14:00 +03:00
|
|
|
|
2017-03-08 09:41:51 +03:00
|
|
|
mOriginAttributes = mLoadingPrincipal->OriginAttributesRef();
|
2016-08-31 00:54:58 +03:00
|
|
|
|
|
|
|
// We need to do this after inheriting the document's origin attributes
|
|
|
|
// above, in case the loading principal ends up being the system principal.
|
|
|
|
if (aLoadingContext) {
|
|
|
|
nsCOMPtr<nsILoadContext> loadContext =
|
|
|
|
aLoadingContext->OwnerDoc()->GetLoadContext();
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = aLoadingContext->OwnerDoc()->GetDocShell();
|
|
|
|
if (loadContext && docShell &&
|
|
|
|
docShell->ItemType() == nsIDocShellTreeItem::typeContent) {
|
|
|
|
bool usePrivateBrowsing;
|
|
|
|
nsresult rv = loadContext->GetUsePrivateBrowsing(&usePrivateBrowsing);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
mOriginAttributes.SyncAttributesWithPrivateBrowsing(usePrivateBrowsing);
|
2016-04-13 11:22:49 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-04 09:05:38 +03:00
|
|
|
// For chrome docshell, the mPrivateBrowsingId remains 0 even its
|
|
|
|
// UsePrivateBrowsing() is true, so we only update the mPrivateBrowsingId in
|
|
|
|
// origin attributes if the type of the docshell is content.
|
|
|
|
if (aLoadingContext) {
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = aLoadingContext->OwnerDoc()->GetDocShell();
|
|
|
|
if (docShell) {
|
2016-08-31 00:54:58 +03:00
|
|
|
if (docShell->ItemType() == nsIDocShellTreeItem::typeChrome) {
|
2016-08-04 09:05:38 +03:00
|
|
|
MOZ_ASSERT(mOriginAttributes.mPrivateBrowsingId == 0,
|
|
|
|
"chrome docshell shouldn't have mPrivateBrowsingId set.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-03-04 19:54:07 +03:00
|
|
|
}
|
|
|
|
|
2016-04-14 02:30:16 +03:00
|
|
|
/* Constructor takes an outer window, but no loadingNode or loadingPrincipal.
|
|
|
|
* This constructor should only be used for TYPE_DOCUMENT loads, since they
|
|
|
|
* have a null loadingNode and loadingPrincipal.
|
|
|
|
*/
|
2016-03-04 19:54:07 +03:00
|
|
|
LoadInfo::LoadInfo(nsPIDOMWindowOuter* aOuterWindow,
|
|
|
|
nsIPrincipal* aTriggeringPrincipal,
|
2017-09-05 19:01:07 +03:00
|
|
|
nsISupports* aContextForTopLevelLoad,
|
2016-03-04 19:54:07 +03:00
|
|
|
nsSecurityFlags aSecurityFlags)
|
2016-04-14 02:30:16 +03:00
|
|
|
: mLoadingPrincipal(nullptr)
|
2016-03-04 19:54:07 +03:00
|
|
|
, mTriggeringPrincipal(aTriggeringPrincipal)
|
2016-11-08 09:23:12 +03:00
|
|
|
, mPrincipalToInherit(nullptr)
|
2017-09-05 19:01:07 +03:00
|
|
|
, mContextForTopLevelLoad(do_GetWeakReference(aContextForTopLevelLoad))
|
2016-03-04 19:54:07 +03:00
|
|
|
, mSecurityFlags(aSecurityFlags)
|
|
|
|
, mInternalContentPolicyType(nsIContentPolicy::TYPE_DOCUMENT)
|
|
|
|
, mTainting(LoadTainting::Basic)
|
|
|
|
, mUpgradeInsecureRequests(false)
|
2016-03-14 13:56:52 +03:00
|
|
|
, mVerifySignedContent(false)
|
2016-03-16 06:13:26 +03:00
|
|
|
, mEnforceSRI(false)
|
2016-07-18 09:35:13 +03:00
|
|
|
, mForceInheritPrincipalDropped(false)
|
2016-03-04 19:54:07 +03:00
|
|
|
, mInnerWindowID(0)
|
|
|
|
, mOuterWindowID(0)
|
|
|
|
, mParentOuterWindowID(0)
|
2016-06-27 03:42:00 +03:00
|
|
|
, mFrameOuterWindowID(0)
|
2016-03-04 19:54:07 +03:00
|
|
|
, mEnforceSecurity(false)
|
|
|
|
, mInitialSecurityCheckDone(false)
|
|
|
|
, mIsThirdPartyContext(false) // NB: TYPE_DOCUMENT implies not third-party.
|
|
|
|
, mForcePreflight(false)
|
|
|
|
, mIsPreflight(false)
|
Bug 1246540 - HSTS Priming Proof of Concept. r=ckerschb, r=mayhemer, r=jld, r=smaug, r=dkeeler, r=jmaher, p=ally
HSTS priming changes the order of mixed-content blocking and HSTS
upgrades, and adds a priming request to check if a mixed-content load is
accesible over HTTPS and the server supports upgrading via the
Strict-Transport-Security header.
Every call site that uses AsyncOpen2 passes through the mixed-content
blocker, and has a LoadInfo. If the mixed-content blocker marks the load as
needing HSTS priming, nsHttpChannel will build and send an HSTS priming
request on the same URI with the scheme upgraded to HTTPS. If the server
allows the upgrade, then channel performs an internal redirect to the HTTPS URI,
otherwise use the result of mixed-content blocker to allow or block the
load.
nsISiteSecurityService adds an optional boolean out parameter to
determine if the HSTS state is already cached for negative assertions.
If the host has been probed within the previous 24 hours, no HSTS
priming check will be sent.
MozReview-Commit-ID: ES1JruCtDdX
--HG--
extra : rebase_source : 2ac6c93c49f2862fc0b9e595eb0598cd1ea4bedf
2016-09-27 18:27:00 +03:00
|
|
|
, mForceHSTSPriming(false)
|
|
|
|
, mMixedContentWouldBlock(false)
|
2017-05-10 01:36:07 +03:00
|
|
|
, mIsHSTSPriming(false)
|
|
|
|
, mIsHSTSPrimingUpgrade(false)
|
2016-03-04 19:54:07 +03:00
|
|
|
{
|
|
|
|
// Top-level loads are never third-party
|
|
|
|
// Grab the information we can out of the window.
|
|
|
|
MOZ_ASSERT(aOuterWindow);
|
2016-04-14 02:30:16 +03:00
|
|
|
MOZ_ASSERT(mTriggeringPrincipal);
|
2016-03-04 19:54:07 +03:00
|
|
|
|
|
|
|
// if the load is sandboxed, we can not also inherit the principal
|
|
|
|
if (mSecurityFlags & nsILoadInfo::SEC_SANDBOXED) {
|
2017-01-10 22:46:30 +03:00
|
|
|
mForceInheritPrincipalDropped =
|
|
|
|
(mSecurityFlags & nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL);
|
|
|
|
mSecurityFlags &= ~nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL;
|
2016-03-04 19:54:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// NB: Ignore the current inner window since we're navigating away from it.
|
|
|
|
mOuterWindowID = aOuterWindow->WindowID();
|
|
|
|
|
|
|
|
// TODO We can have a parent without a frame element in some cases dealing
|
|
|
|
// with the hidden window.
|
|
|
|
nsCOMPtr<nsPIDOMWindowOuter> parent = aOuterWindow->GetScriptableParent();
|
|
|
|
mParentOuterWindowID = parent ? parent->WindowID() : 0;
|
|
|
|
|
2016-04-14 02:30:16 +03:00
|
|
|
// get the docshell from the outerwindow, and then get the originattributes
|
|
|
|
nsCOMPtr<nsIDocShell> docShell = aOuterWindow->GetDocShell();
|
|
|
|
MOZ_ASSERT(docShell);
|
2017-03-08 09:41:51 +03:00
|
|
|
mOriginAttributes = nsDocShell::Cast(docShell)->GetOriginAttributes();
|
2016-08-04 09:05:38 +03:00
|
|
|
|
2017-03-08 09:41:51 +03:00
|
|
|
#ifdef DEBUG
|
2016-08-31 00:54:58 +03:00
|
|
|
if (docShell->ItemType() == nsIDocShellTreeItem::typeChrome) {
|
2017-03-08 09:41:51 +03:00
|
|
|
MOZ_ASSERT(mOriginAttributes.mPrivateBrowsingId == 0,
|
2016-08-04 09:05:38 +03:00
|
|
|
"chrome docshell shouldn't have mPrivateBrowsingId set.");
|
|
|
|
}
|
2017-03-08 09:41:51 +03:00
|
|
|
#endif
|
2014-07-10 10:56:37 +04:00
|
|
|
}
|
|
|
|
|
2015-09-24 23:42:02 +03:00
|
|
|
LoadInfo::LoadInfo(const LoadInfo& rhs)
|
|
|
|
: mLoadingPrincipal(rhs.mLoadingPrincipal)
|
|
|
|
, mTriggeringPrincipal(rhs.mTriggeringPrincipal)
|
2016-09-20 09:35:45 +03:00
|
|
|
, mPrincipalToInherit(rhs.mPrincipalToInherit)
|
2017-02-01 01:56:15 +03:00
|
|
|
, mSandboxedLoadingPrincipal(rhs.mSandboxedLoadingPrincipal)
|
2017-05-30 19:07:59 +03:00
|
|
|
, mResultPrincipalURI(rhs.mResultPrincipalURI)
|
2015-09-24 23:42:02 +03:00
|
|
|
, mLoadingContext(rhs.mLoadingContext)
|
2017-09-05 19:01:07 +03:00
|
|
|
, mContextForTopLevelLoad(rhs.mContextForTopLevelLoad)
|
2015-09-24 23:42:02 +03:00
|
|
|
, mSecurityFlags(rhs.mSecurityFlags)
|
2015-10-19 21:14:54 +03:00
|
|
|
, mInternalContentPolicyType(rhs.mInternalContentPolicyType)
|
2015-11-01 01:20:48 +03:00
|
|
|
, mTainting(rhs.mTainting)
|
2015-09-24 23:42:02 +03:00
|
|
|
, mUpgradeInsecureRequests(rhs.mUpgradeInsecureRequests)
|
2016-03-14 13:56:52 +03:00
|
|
|
, mVerifySignedContent(rhs.mVerifySignedContent)
|
2016-03-16 06:13:26 +03:00
|
|
|
, mEnforceSRI(rhs.mEnforceSRI)
|
2016-07-18 09:35:13 +03:00
|
|
|
, mForceInheritPrincipalDropped(rhs.mForceInheritPrincipalDropped)
|
2015-09-24 23:42:02 +03:00
|
|
|
, mInnerWindowID(rhs.mInnerWindowID)
|
|
|
|
, mOuterWindowID(rhs.mOuterWindowID)
|
|
|
|
, mParentOuterWindowID(rhs.mParentOuterWindowID)
|
2016-06-27 03:42:00 +03:00
|
|
|
, mFrameOuterWindowID(rhs.mFrameOuterWindowID)
|
2015-11-01 01:20:48 +03:00
|
|
|
, mEnforceSecurity(rhs.mEnforceSecurity)
|
|
|
|
, mInitialSecurityCheckDone(rhs.mInitialSecurityCheckDone)
|
2015-12-01 00:25:29 +03:00
|
|
|
, mIsThirdPartyContext(rhs.mIsThirdPartyContext)
|
2015-11-01 01:20:48 +03:00
|
|
|
, mOriginAttributes(rhs.mOriginAttributes)
|
|
|
|
, mRedirectChainIncludingInternalRedirects(
|
|
|
|
rhs.mRedirectChainIncludingInternalRedirects)
|
|
|
|
, mRedirectChain(rhs.mRedirectChain)
|
2015-12-07 02:33:14 +03:00
|
|
|
, mCorsUnsafeHeaders(rhs.mCorsUnsafeHeaders)
|
|
|
|
, mForcePreflight(rhs.mForcePreflight)
|
|
|
|
, mIsPreflight(rhs.mIsPreflight)
|
Bug 1246540 - HSTS Priming Proof of Concept. r=ckerschb, r=mayhemer, r=jld, r=smaug, r=dkeeler, r=jmaher, p=ally
HSTS priming changes the order of mixed-content blocking and HSTS
upgrades, and adds a priming request to check if a mixed-content load is
accesible over HTTPS and the server supports upgrading via the
Strict-Transport-Security header.
Every call site that uses AsyncOpen2 passes through the mixed-content
blocker, and has a LoadInfo. If the mixed-content blocker marks the load as
needing HSTS priming, nsHttpChannel will build and send an HSTS priming
request on the same URI with the scheme upgraded to HTTPS. If the server
allows the upgrade, then channel performs an internal redirect to the HTTPS URI,
otherwise use the result of mixed-content blocker to allow or block the
load.
nsISiteSecurityService adds an optional boolean out parameter to
determine if the HSTS state is already cached for negative assertions.
If the host has been probed within the previous 24 hours, no HSTS
priming check will be sent.
MozReview-Commit-ID: ES1JruCtDdX
--HG--
extra : rebase_source : 2ac6c93c49f2862fc0b9e595eb0598cd1ea4bedf
2016-09-27 18:27:00 +03:00
|
|
|
, mForceHSTSPriming(rhs.mForceHSTSPriming)
|
|
|
|
, mMixedContentWouldBlock(rhs.mMixedContentWouldBlock)
|
2017-05-10 01:36:07 +03:00
|
|
|
, mIsHSTSPriming(rhs.mIsHSTSPriming)
|
|
|
|
, mIsHSTSPrimingUpgrade(rhs.mIsHSTSPrimingUpgrade)
|
2015-09-24 23:42:02 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-01-08 02:51:20 +03:00
|
|
|
LoadInfo::LoadInfo(nsIPrincipal* aLoadingPrincipal,
|
|
|
|
nsIPrincipal* aTriggeringPrincipal,
|
2016-09-20 09:35:45 +03:00
|
|
|
nsIPrincipal* aPrincipalToInherit,
|
2017-02-01 01:56:15 +03:00
|
|
|
nsIPrincipal* aSandboxedLoadingPrincipal,
|
2017-05-30 19:07:59 +03:00
|
|
|
nsIURI* aResultPrincipalURI,
|
2015-01-08 02:51:20 +03:00
|
|
|
nsSecurityFlags aSecurityFlags,
|
|
|
|
nsContentPolicyType aContentPolicyType,
|
2015-12-07 02:33:15 +03:00
|
|
|
LoadTainting aTainting,
|
2015-07-10 23:57:55 +03:00
|
|
|
bool aUpgradeInsecureRequests,
|
2016-03-14 13:56:52 +03:00
|
|
|
bool aVerifySignedContent,
|
2016-03-16 06:13:26 +03:00
|
|
|
bool aEnforceSRI,
|
2016-07-18 09:35:13 +03:00
|
|
|
bool aForceInheritPrincipalDropped,
|
2015-05-08 22:52:49 +03:00
|
|
|
uint64_t aInnerWindowID,
|
|
|
|
uint64_t aOuterWindowID,
|
2015-07-20 05:11:03 +03:00
|
|
|
uint64_t aParentOuterWindowID,
|
2016-06-27 03:42:00 +03:00
|
|
|
uint64_t aFrameOuterWindowID,
|
2015-07-20 05:11:57 +03:00
|
|
|
bool aEnforceSecurity,
|
|
|
|
bool aInitialSecurityCheckDone,
|
2015-12-01 00:25:29 +03:00
|
|
|
bool aIsThirdPartyContext,
|
2017-01-12 19:38:48 +03:00
|
|
|
const OriginAttributes& aOriginAttributes,
|
2017-05-25 20:42:00 +03:00
|
|
|
RedirectHistoryArray& aRedirectChainIncludingInternalRedirects,
|
|
|
|
RedirectHistoryArray& aRedirectChain,
|
2015-12-07 02:33:14 +03:00
|
|
|
const nsTArray<nsCString>& aCorsUnsafeHeaders,
|
|
|
|
bool aForcePreflight,
|
Bug 1246540 - HSTS Priming Proof of Concept. r=ckerschb, r=mayhemer, r=jld, r=smaug, r=dkeeler, r=jmaher, p=ally
HSTS priming changes the order of mixed-content blocking and HSTS
upgrades, and adds a priming request to check if a mixed-content load is
accesible over HTTPS and the server supports upgrading via the
Strict-Transport-Security header.
Every call site that uses AsyncOpen2 passes through the mixed-content
blocker, and has a LoadInfo. If the mixed-content blocker marks the load as
needing HSTS priming, nsHttpChannel will build and send an HSTS priming
request on the same URI with the scheme upgraded to HTTPS. If the server
allows the upgrade, then channel performs an internal redirect to the HTTPS URI,
otherwise use the result of mixed-content blocker to allow or block the
load.
nsISiteSecurityService adds an optional boolean out parameter to
determine if the HSTS state is already cached for negative assertions.
If the host has been probed within the previous 24 hours, no HSTS
priming check will be sent.
MozReview-Commit-ID: ES1JruCtDdX
--HG--
extra : rebase_source : 2ac6c93c49f2862fc0b9e595eb0598cd1ea4bedf
2016-09-27 18:27:00 +03:00
|
|
|
bool aIsPreflight,
|
|
|
|
bool aForceHSTSPriming,
|
2017-05-10 01:36:07 +03:00
|
|
|
bool aMixedContentWouldBlock,
|
|
|
|
bool aIsHSTSPriming,
|
|
|
|
bool aIsHSTSPrimingUpgrade)
|
2015-01-08 02:51:20 +03:00
|
|
|
: mLoadingPrincipal(aLoadingPrincipal)
|
|
|
|
, mTriggeringPrincipal(aTriggeringPrincipal)
|
2016-09-20 09:35:45 +03:00
|
|
|
, mPrincipalToInherit(aPrincipalToInherit)
|
2017-05-30 19:07:59 +03:00
|
|
|
, mResultPrincipalURI(aResultPrincipalURI)
|
2015-01-08 02:51:20 +03:00
|
|
|
, mSecurityFlags(aSecurityFlags)
|
2015-10-19 21:14:54 +03:00
|
|
|
, mInternalContentPolicyType(aContentPolicyType)
|
2015-12-07 02:33:15 +03:00
|
|
|
, mTainting(aTainting)
|
2015-07-10 23:57:55 +03:00
|
|
|
, mUpgradeInsecureRequests(aUpgradeInsecureRequests)
|
2016-03-14 13:56:52 +03:00
|
|
|
, mVerifySignedContent(aVerifySignedContent)
|
2016-03-16 06:13:26 +03:00
|
|
|
, mEnforceSRI(aEnforceSRI)
|
2016-07-18 09:35:13 +03:00
|
|
|
, mForceInheritPrincipalDropped(aForceInheritPrincipalDropped)
|
2015-01-08 02:51:20 +03:00
|
|
|
, mInnerWindowID(aInnerWindowID)
|
2015-05-08 22:52:49 +03:00
|
|
|
, mOuterWindowID(aOuterWindowID)
|
|
|
|
, mParentOuterWindowID(aParentOuterWindowID)
|
2016-06-27 03:42:00 +03:00
|
|
|
, mFrameOuterWindowID(aFrameOuterWindowID)
|
2015-07-20 05:11:57 +03:00
|
|
|
, mEnforceSecurity(aEnforceSecurity)
|
|
|
|
, mInitialSecurityCheckDone(aInitialSecurityCheckDone)
|
2015-12-01 00:25:29 +03:00
|
|
|
, mIsThirdPartyContext(aIsThirdPartyContext)
|
2015-10-22 00:47:00 +03:00
|
|
|
, mOriginAttributes(aOriginAttributes)
|
2015-12-07 02:33:14 +03:00
|
|
|
, mCorsUnsafeHeaders(aCorsUnsafeHeaders)
|
|
|
|
, mForcePreflight(aForcePreflight)
|
|
|
|
, mIsPreflight(aIsPreflight)
|
Bug 1246540 - HSTS Priming Proof of Concept. r=ckerschb, r=mayhemer, r=jld, r=smaug, r=dkeeler, r=jmaher, p=ally
HSTS priming changes the order of mixed-content blocking and HSTS
upgrades, and adds a priming request to check if a mixed-content load is
accesible over HTTPS and the server supports upgrading via the
Strict-Transport-Security header.
Every call site that uses AsyncOpen2 passes through the mixed-content
blocker, and has a LoadInfo. If the mixed-content blocker marks the load as
needing HSTS priming, nsHttpChannel will build and send an HSTS priming
request on the same URI with the scheme upgraded to HTTPS. If the server
allows the upgrade, then channel performs an internal redirect to the HTTPS URI,
otherwise use the result of mixed-content blocker to allow or block the
load.
nsISiteSecurityService adds an optional boolean out parameter to
determine if the HSTS state is already cached for negative assertions.
If the host has been probed within the previous 24 hours, no HSTS
priming check will be sent.
MozReview-Commit-ID: ES1JruCtDdX
--HG--
extra : rebase_source : 2ac6c93c49f2862fc0b9e595eb0598cd1ea4bedf
2016-09-27 18:27:00 +03:00
|
|
|
, mForceHSTSPriming (aForceHSTSPriming)
|
|
|
|
, mMixedContentWouldBlock(aMixedContentWouldBlock)
|
2017-05-10 01:36:07 +03:00
|
|
|
, mIsHSTSPriming(aIsHSTSPriming)
|
|
|
|
, mIsHSTSPrimingUpgrade(aIsHSTSPrimingUpgrade)
|
2015-01-08 02:51:20 +03:00
|
|
|
{
|
2016-04-14 02:30:16 +03:00
|
|
|
// Only top level TYPE_DOCUMENT loads can have a null loadingPrincipal
|
|
|
|
MOZ_ASSERT(mLoadingPrincipal || aContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT);
|
2015-01-08 02:51:20 +03:00
|
|
|
MOZ_ASSERT(mTriggeringPrincipal);
|
2015-07-20 05:11:03 +03:00
|
|
|
|
2015-11-01 01:18:59 +03:00
|
|
|
mRedirectChainIncludingInternalRedirects.SwapElements(
|
|
|
|
aRedirectChainIncludingInternalRedirects);
|
|
|
|
|
2015-07-20 05:11:03 +03:00
|
|
|
mRedirectChain.SwapElements(aRedirectChain);
|
2015-01-08 02:51:20 +03:00
|
|
|
}
|
|
|
|
|
2014-07-10 10:56:37 +04:00
|
|
|
LoadInfo::~LoadInfo()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-12-01 00:25:29 +03:00
|
|
|
void
|
2016-01-30 20:05:36 +03:00
|
|
|
LoadInfo::ComputeIsThirdPartyContext(nsPIDOMWindowOuter* aOuterWindow)
|
2015-12-01 00:25:29 +03:00
|
|
|
{
|
|
|
|
nsContentPolicyType type =
|
|
|
|
nsContentUtils::InternalContentPolicyTypeToExternal(mInternalContentPolicyType);
|
|
|
|
if (type == nsIContentPolicy::TYPE_DOCUMENT) {
|
|
|
|
// Top-level loads are never third-party.
|
|
|
|
mIsThirdPartyContext = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<mozIThirdPartyUtil> util(do_GetService(THIRDPARTYUTIL_CONTRACTID));
|
|
|
|
if (NS_WARN_IF(!util)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-03-12 07:28:00 +03:00
|
|
|
util->IsThirdPartyWindow(aOuterWindow, nullptr, &mIsThirdPartyContext);
|
2015-12-01 00:25:29 +03:00
|
|
|
}
|
|
|
|
|
2014-07-10 10:56:37 +04:00
|
|
|
NS_IMPL_ISUPPORTS(LoadInfo, nsILoadInfo)
|
|
|
|
|
2015-09-24 23:42:02 +03:00
|
|
|
already_AddRefed<nsILoadInfo>
|
|
|
|
LoadInfo::Clone() const
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<LoadInfo> copy(new LoadInfo(*this));
|
2015-09-24 23:42:02 +03:00
|
|
|
return copy.forget();
|
|
|
|
}
|
|
|
|
|
2016-06-22 18:15:06 +03:00
|
|
|
already_AddRefed<nsILoadInfo>
|
|
|
|
LoadInfo::CloneWithNewSecFlags(nsSecurityFlags aSecurityFlags) const
|
|
|
|
{
|
|
|
|
RefPtr<LoadInfo> copy(new LoadInfo(*this));
|
|
|
|
copy->mSecurityFlags = aSecurityFlags;
|
|
|
|
return copy.forget();
|
|
|
|
}
|
|
|
|
|
2015-11-01 01:20:48 +03:00
|
|
|
already_AddRefed<nsILoadInfo>
|
|
|
|
LoadInfo::CloneForNewRequest() const
|
|
|
|
{
|
|
|
|
RefPtr<LoadInfo> copy(new LoadInfo(*this));
|
|
|
|
copy->mEnforceSecurity = false;
|
|
|
|
copy->mInitialSecurityCheckDone = false;
|
|
|
|
copy->mRedirectChainIncludingInternalRedirects.Clear();
|
|
|
|
copy->mRedirectChain.Clear();
|
2017-07-06 12:10:00 +03:00
|
|
|
copy->mResultPrincipalURI = nullptr;
|
2015-11-01 01:20:48 +03:00
|
|
|
return copy.forget();
|
|
|
|
}
|
|
|
|
|
2014-07-10 10:56:37 +04:00
|
|
|
NS_IMETHODIMP
|
2014-11-14 19:55:59 +03:00
|
|
|
LoadInfo::GetLoadingPrincipal(nsIPrincipal** aLoadingPrincipal)
|
2014-07-10 10:56:37 +04:00
|
|
|
{
|
2016-04-14 02:30:33 +03:00
|
|
|
NS_IF_ADDREF(*aLoadingPrincipal = mLoadingPrincipal);
|
2014-07-10 10:56:37 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIPrincipal*
|
|
|
|
LoadInfo::LoadingPrincipal()
|
|
|
|
{
|
2014-11-14 19:55:59 +03:00
|
|
|
return mLoadingPrincipal;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetTriggeringPrincipal(nsIPrincipal** aTriggeringPrincipal)
|
|
|
|
{
|
|
|
|
NS_ADDREF(*aTriggeringPrincipal = mTriggeringPrincipal);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIPrincipal*
|
|
|
|
LoadInfo::TriggeringPrincipal()
|
|
|
|
{
|
|
|
|
return mTriggeringPrincipal;
|
2014-07-10 10:56:37 +04:00
|
|
|
}
|
|
|
|
|
2016-09-20 09:35:45 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetPrincipalToInherit(nsIPrincipal** aPrincipalToInherit)
|
|
|
|
{
|
2016-11-08 09:23:12 +03:00
|
|
|
NS_IF_ADDREF(*aPrincipalToInherit = mPrincipalToInherit);
|
2016-09-20 09:35:45 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::SetPrincipalToInherit(nsIPrincipal* aPrincipalToInherit)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aPrincipalToInherit, "must be a valid principal to inherit");
|
|
|
|
mPrincipalToInherit = aPrincipalToInherit;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIPrincipal*
|
|
|
|
LoadInfo::PrincipalToInherit()
|
|
|
|
{
|
|
|
|
return mPrincipalToInherit;
|
|
|
|
}
|
|
|
|
|
2017-02-01 01:56:15 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetSandboxedLoadingPrincipal(nsIPrincipal** aPrincipal)
|
|
|
|
{
|
|
|
|
if (!(mSecurityFlags & nsILoadInfo::SEC_SANDBOXED)) {
|
|
|
|
*aPrincipal = nullptr;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mSandboxedLoadingPrincipal) {
|
|
|
|
if (mLoadingPrincipal) {
|
|
|
|
mSandboxedLoadingPrincipal =
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipal::CreateWithInheritedAttributes(mLoadingPrincipal);
|
2017-02-01 01:56:15 +03:00
|
|
|
} else {
|
|
|
|
OriginAttributes attrs(mOriginAttributes);
|
2017-03-22 13:38:40 +03:00
|
|
|
mSandboxedLoadingPrincipal = NullPrincipal::Create(attrs);
|
2017-02-01 01:56:15 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(mSandboxedLoadingPrincipal);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPrincipal> copy(mSandboxedLoadingPrincipal);
|
|
|
|
copy.forget(aPrincipal);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-07-17 00:16:12 +04:00
|
|
|
NS_IMETHODIMP
|
2015-02-13 22:36:37 +03:00
|
|
|
LoadInfo::GetLoadingDocument(nsIDOMDocument** aResult)
|
2014-07-17 00:16:12 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsINode> node = do_QueryReferent(mLoadingContext);
|
|
|
|
if (node) {
|
|
|
|
nsCOMPtr<nsIDOMDocument> context = do_QueryInterface(node->OwnerDoc());
|
2015-02-13 22:36:37 +03:00
|
|
|
context.forget(aResult);
|
2014-07-17 00:16:12 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsINode*
|
|
|
|
LoadInfo::LoadingNode()
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsINode> node = do_QueryReferent(mLoadingContext);
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2017-09-05 19:01:07 +03:00
|
|
|
nsISupports*
|
|
|
|
LoadInfo::ContextForTopLevelLoad()
|
|
|
|
{
|
|
|
|
// Most likely you want to query LoadingNode() instead of
|
|
|
|
// ContextForTopLevelLoad() if this assertion fires.
|
|
|
|
MOZ_ASSERT(mInternalContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT,
|
|
|
|
"should only query this context for top level document loads");
|
|
|
|
nsCOMPtr<nsISupports> context = do_QueryReferent(mContextForTopLevelLoad);
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
2014-07-17 00:16:12 +04:00
|
|
|
NS_IMETHODIMP
|
2015-02-13 22:36:37 +03:00
|
|
|
LoadInfo::GetSecurityFlags(nsSecurityFlags* aResult)
|
2014-07-17 00:16:12 +04:00
|
|
|
{
|
2015-02-13 22:36:37 +03:00
|
|
|
*aResult = mSecurityFlags;
|
2014-07-17 00:16:12 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-07-20 05:11:57 +03:00
|
|
|
NS_IMETHODIMP
|
2015-12-01 00:25:29 +03:00
|
|
|
LoadInfo::GetSecurityMode(uint32_t* aFlags)
|
2015-07-20 05:11:57 +03:00
|
|
|
{
|
|
|
|
*aFlags = (mSecurityFlags &
|
|
|
|
(nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_INHERITS |
|
|
|
|
nsILoadInfo::SEC_REQUIRE_SAME_ORIGIN_DATA_IS_BLOCKED |
|
|
|
|
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS |
|
|
|
|
nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL |
|
|
|
|
nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-12-01 00:25:29 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetIsInThirdPartyContext(bool* aIsInThirdPartyContext)
|
|
|
|
{
|
|
|
|
*aIsInThirdPartyContext = mIsThirdPartyContext;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-12-07 02:33:15 +03:00
|
|
|
static const uint32_t sCookiePolicyMask =
|
|
|
|
nsILoadInfo::SEC_COOKIES_DEFAULT |
|
|
|
|
nsILoadInfo::SEC_COOKIES_INCLUDE |
|
|
|
|
nsILoadInfo::SEC_COOKIES_SAME_ORIGIN |
|
|
|
|
nsILoadInfo::SEC_COOKIES_OMIT;
|
|
|
|
|
2015-07-20 05:11:57 +03:00
|
|
|
NS_IMETHODIMP
|
2015-12-07 02:33:15 +03:00
|
|
|
LoadInfo::GetCookiePolicy(uint32_t *aResult)
|
2015-07-20 05:11:57 +03:00
|
|
|
{
|
2015-12-07 02:33:15 +03:00
|
|
|
uint32_t policy = mSecurityFlags & sCookiePolicyMask;
|
|
|
|
if (policy == nsILoadInfo::SEC_COOKIES_DEFAULT) {
|
|
|
|
policy = (mSecurityFlags & SEC_REQUIRE_CORS_DATA_INHERITS) ?
|
|
|
|
nsILoadInfo::SEC_COOKIES_SAME_ORIGIN : nsILoadInfo::SEC_COOKIES_INCLUDE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*aResult = policy;
|
2015-07-20 05:11:57 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-12-07 02:33:15 +03:00
|
|
|
void
|
|
|
|
LoadInfo::SetIncludeCookiesSecFlag()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mEnforceSecurity,
|
|
|
|
"Request should not have been opened yet");
|
|
|
|
MOZ_ASSERT((mSecurityFlags & sCookiePolicyMask) ==
|
|
|
|
nsILoadInfo::SEC_COOKIES_DEFAULT);
|
|
|
|
mSecurityFlags = (mSecurityFlags & ~sCookiePolicyMask) |
|
|
|
|
nsILoadInfo::SEC_COOKIES_INCLUDE;
|
|
|
|
}
|
|
|
|
|
2014-07-10 10:56:37 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetForceInheritPrincipal(bool* aInheritPrincipal)
|
|
|
|
{
|
2015-02-13 22:36:37 +03:00
|
|
|
*aInheritPrincipal =
|
|
|
|
(mSecurityFlags & nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL);
|
2014-07-10 10:56:37 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-10-05 22:19:51 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetForceInheritPrincipalOverruleOwner(bool* aInheritPrincipal)
|
|
|
|
{
|
|
|
|
*aInheritPrincipal =
|
|
|
|
(mSecurityFlags & nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL_OVERRULE_OWNER);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-07-10 10:56:37 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetLoadingSandboxed(bool* aLoadingSandboxed)
|
|
|
|
{
|
2014-07-17 00:16:12 +04:00
|
|
|
*aLoadingSandboxed = (mSecurityFlags & nsILoadInfo::SEC_SANDBOXED);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-07-20 05:11:57 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetAboutBlankInherits(bool* aResult)
|
|
|
|
{
|
|
|
|
*aResult =
|
|
|
|
(mSecurityFlags & nsILoadInfo::SEC_ABOUT_BLANK_INHERITS);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-15 04:59:35 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetAllowChrome(bool* aResult)
|
|
|
|
{
|
|
|
|
*aResult =
|
|
|
|
(mSecurityFlags & nsILoadInfo::SEC_ALLOW_CHROME);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2016-05-24 00:57:31 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetDisallowScript(bool* aResult)
|
|
|
|
{
|
|
|
|
*aResult =
|
|
|
|
(mSecurityFlags & nsILoadInfo::SEC_DISALLOW_SCRIPT);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-09-15 04:59:35 +03:00
|
|
|
|
2015-11-24 05:47:10 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetDontFollowRedirects(bool* aResult)
|
|
|
|
{
|
|
|
|
*aResult =
|
|
|
|
(mSecurityFlags & nsILoadInfo::SEC_DONT_FOLLOW_REDIRECTS);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-08-16 04:47:14 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetLoadErrorPage(bool* aResult)
|
|
|
|
{
|
|
|
|
*aResult =
|
|
|
|
(mSecurityFlags & nsILoadInfo::SEC_LOAD_ERROR_PAGE);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-07-17 00:16:12 +04:00
|
|
|
NS_IMETHODIMP
|
2015-10-19 21:14:54 +03:00
|
|
|
LoadInfo::GetExternalContentPolicyType(nsContentPolicyType* aResult)
|
2014-07-17 00:16:12 +04:00
|
|
|
{
|
2015-10-19 21:14:54 +03:00
|
|
|
*aResult = nsContentUtils::InternalContentPolicyTypeToExternal(mInternalContentPolicyType);
|
2014-07-10 10:56:37 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-06-17 07:18:16 +03:00
|
|
|
nsContentPolicyType
|
|
|
|
LoadInfo::InternalContentPolicyType()
|
|
|
|
{
|
2015-10-19 21:14:54 +03:00
|
|
|
return mInternalContentPolicyType;
|
2015-06-17 07:18:16 +03:00
|
|
|
}
|
|
|
|
|
2015-07-10 23:57:55 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetUpgradeInsecureRequests(bool* aResult)
|
|
|
|
{
|
|
|
|
*aResult = mUpgradeInsecureRequests;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-03-14 13:56:52 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::SetVerifySignedContent(bool aVerifySignedContent)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(mInternalContentPolicyType == nsIContentPolicy::TYPE_DOCUMENT,
|
|
|
|
"can only verify content for TYPE_DOCUMENT");
|
|
|
|
mVerifySignedContent = aVerifySignedContent;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetVerifySignedContent(bool* aResult)
|
|
|
|
{
|
|
|
|
*aResult = mVerifySignedContent;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-03-16 06:13:26 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::SetEnforceSRI(bool aEnforceSRI)
|
|
|
|
{
|
|
|
|
mEnforceSRI = aEnforceSRI;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetEnforceSRI(bool* aResult)
|
|
|
|
{
|
|
|
|
*aResult = mEnforceSRI;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-07-18 09:35:13 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetForceInheritPrincipalDropped(bool* aResult)
|
|
|
|
{
|
|
|
|
*aResult = mForceInheritPrincipalDropped;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-01-08 02:51:20 +03:00
|
|
|
NS_IMETHODIMP
|
2015-05-08 22:52:49 +03:00
|
|
|
LoadInfo::GetInnerWindowID(uint64_t* aResult)
|
2015-01-08 02:51:20 +03:00
|
|
|
{
|
2015-02-13 22:36:37 +03:00
|
|
|
*aResult = mInnerWindowID;
|
2015-01-08 02:51:20 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-08 22:52:49 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetOuterWindowID(uint64_t* aResult)
|
|
|
|
{
|
|
|
|
*aResult = mOuterWindowID;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetParentOuterWindowID(uint64_t* aResult)
|
|
|
|
{
|
|
|
|
*aResult = mParentOuterWindowID;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-06-27 03:42:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetFrameOuterWindowID(uint64_t* aResult)
|
|
|
|
{
|
|
|
|
*aResult = mFrameOuterWindowID;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:47:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetScriptableOriginAttributes(JSContext* aCx,
|
|
|
|
JS::MutableHandle<JS::Value> aOriginAttributes)
|
|
|
|
{
|
|
|
|
if (NS_WARN_IF(!ToJSValue(aCx, mOriginAttributes, aOriginAttributes))) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-10-05 22:19:51 +03:00
|
|
|
NS_IMETHODIMP
|
2017-04-03 21:06:53 +03:00
|
|
|
LoadInfo::ResetPrincipalToInheritToNullPrincipal()
|
2016-10-05 22:19:51 +03:00
|
|
|
{
|
|
|
|
// take the originAttributes from the LoadInfo and create
|
|
|
|
// a new NullPrincipal using those origin attributes.
|
2017-03-08 09:41:51 +03:00
|
|
|
nsCOMPtr<nsIPrincipal> newNullPrincipal =
|
2017-03-22 13:38:40 +03:00
|
|
|
NullPrincipal::Create(mOriginAttributes);
|
2016-10-05 22:19:51 +03:00
|
|
|
|
|
|
|
mPrincipalToInherit = newNullPrincipal;
|
|
|
|
|
|
|
|
// setting SEC_FORCE_INHERIT_PRINCIPAL_OVERRULE_OWNER will overrule
|
|
|
|
// any non null owner set on the channel and will return the principal
|
|
|
|
// form the loadinfo instead.
|
|
|
|
mSecurityFlags |= SEC_FORCE_INHERIT_PRINCIPAL_OVERRULE_OWNER;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-10-22 00:47:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::SetScriptableOriginAttributes(JSContext* aCx,
|
|
|
|
JS::Handle<JS::Value> aOriginAttributes)
|
|
|
|
{
|
2017-01-12 19:38:48 +03:00
|
|
|
OriginAttributes attrs;
|
2015-10-22 00:47:00 +03:00
|
|
|
if (!aOriginAttributes.isObject() || !attrs.Init(aCx, aOriginAttributes)) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
mOriginAttributes = attrs;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2017-01-12 19:38:48 +03:00
|
|
|
LoadInfo::GetOriginAttributes(mozilla::OriginAttributes* aOriginAttributes)
|
2015-10-22 00:47:00 +03:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG(aOriginAttributes);
|
|
|
|
*aOriginAttributes = mOriginAttributes;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2017-01-12 19:38:48 +03:00
|
|
|
LoadInfo::SetOriginAttributes(const mozilla::OriginAttributes& aOriginAttributes)
|
2015-10-22 00:47:00 +03:00
|
|
|
{
|
|
|
|
mOriginAttributes = aOriginAttributes;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-07-20 05:11:57 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::SetEnforceSecurity(bool aEnforceSecurity)
|
|
|
|
{
|
|
|
|
// Indicates whether the channel was openend using AsyncOpen2. Once set
|
|
|
|
// to true, it must remain true throughout the lifetime of the channel.
|
|
|
|
// Setting it to anything else than true will be discarded.
|
|
|
|
MOZ_ASSERT(aEnforceSecurity, "aEnforceSecurity must be true");
|
|
|
|
mEnforceSecurity = mEnforceSecurity || aEnforceSecurity;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetEnforceSecurity(bool* aResult)
|
|
|
|
{
|
|
|
|
*aResult = mEnforceSecurity;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::SetInitialSecurityCheckDone(bool aInitialSecurityCheckDone)
|
|
|
|
{
|
|
|
|
// Indicates whether the channel was ever evaluated by the
|
|
|
|
// ContentSecurityManager. Once set to true, this flag must
|
|
|
|
// remain true throughout the lifetime of the channel.
|
|
|
|
// Setting it to anything else than true will be discarded.
|
|
|
|
MOZ_ASSERT(aInitialSecurityCheckDone, "aInitialSecurityCheckDone must be true");
|
|
|
|
mInitialSecurityCheckDone = mInitialSecurityCheckDone || aInitialSecurityCheckDone;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetInitialSecurityCheckDone(bool* aResult)
|
|
|
|
{
|
|
|
|
*aResult = mInitialSecurityCheckDone;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-07-20 05:11:03 +03:00
|
|
|
NS_IMETHODIMP
|
2017-05-25 20:42:00 +03:00
|
|
|
LoadInfo::AppendRedirectHistoryEntry(nsIRedirectHistoryEntry* aEntry,
|
|
|
|
bool aIsInternalRedirect)
|
2015-07-20 05:11:03 +03:00
|
|
|
{
|
2017-05-25 20:42:00 +03:00
|
|
|
NS_ENSURE_ARG(aEntry);
|
2015-11-01 01:22:01 +03:00
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
|
2017-05-25 20:42:00 +03:00
|
|
|
mRedirectChainIncludingInternalRedirects.AppendElement(aEntry);
|
2015-11-01 01:18:59 +03:00
|
|
|
if (!aIsInternalRedirect) {
|
2017-05-25 20:42:00 +03:00
|
|
|
mRedirectChain.AppendElement(aEntry);
|
2015-11-01 01:18:59 +03:00
|
|
|
}
|
2015-07-20 05:11:03 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-11-01 01:18:59 +03:00
|
|
|
NS_IMETHODIMP
|
2017-05-25 20:42:00 +03:00
|
|
|
LoadInfo::GetRedirects(JSContext* aCx, JS::MutableHandle<JS::Value> aRedirects,
|
|
|
|
const RedirectHistoryArray& aArray)
|
2015-11-01 01:18:59 +03:00
|
|
|
{
|
2017-05-25 20:42:00 +03:00
|
|
|
JS::Rooted<JSObject*> redirects(aCx, JS_NewArrayObject(aCx, aArray.Length()));
|
|
|
|
NS_ENSURE_TRUE(redirects, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
JS::Rooted<JSObject*> global(aCx, JS::CurrentGlobalOrNull(aCx));
|
|
|
|
NS_ENSURE_TRUE(global, NS_ERROR_UNEXPECTED);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIXPConnect> xpc = mozilla::services::GetXPConnect();
|
|
|
|
|
|
|
|
for (size_t idx = 0; idx < aArray.Length(); idx++) {
|
|
|
|
JS::RootedObject jsobj(aCx);
|
|
|
|
nsresult rv = xpc->WrapNative(aCx, global, aArray[idx],
|
|
|
|
NS_GET_IID(nsIRedirectHistoryEntry),
|
|
|
|
jsobj.address());
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
NS_ENSURE_STATE(jsobj);
|
|
|
|
|
|
|
|
bool rc = JS_DefineElement(aCx, redirects, idx, jsobj, JSPROP_ENUMERATE);
|
|
|
|
NS_ENSURE_TRUE(rc, NS_ERROR_UNEXPECTED);
|
2015-11-01 01:18:59 +03:00
|
|
|
}
|
2017-05-25 20:42:00 +03:00
|
|
|
|
|
|
|
aRedirects.setObject(*redirects);
|
2015-11-01 01:18:59 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-05-25 20:42:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetRedirectChainIncludingInternalRedirects(JSContext* aCx, JS::MutableHandle<JS::Value> aChain)
|
|
|
|
{
|
|
|
|
return GetRedirects(aCx, aChain, mRedirectChainIncludingInternalRedirects);
|
|
|
|
}
|
|
|
|
|
|
|
|
const RedirectHistoryArray&
|
2015-11-01 01:18:59 +03:00
|
|
|
LoadInfo::RedirectChainIncludingInternalRedirects()
|
|
|
|
{
|
|
|
|
return mRedirectChainIncludingInternalRedirects;
|
|
|
|
}
|
|
|
|
|
2015-07-20 05:11:03 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetRedirectChain(JSContext* aCx, JS::MutableHandle<JS::Value> aChain)
|
|
|
|
{
|
2017-05-25 20:42:00 +03:00
|
|
|
return GetRedirects(aCx, aChain, mRedirectChain);
|
2015-07-20 05:11:03 +03:00
|
|
|
}
|
|
|
|
|
2017-05-25 20:42:00 +03:00
|
|
|
const RedirectHistoryArray&
|
2015-07-20 05:11:03 +03:00
|
|
|
LoadInfo::RedirectChain()
|
|
|
|
{
|
|
|
|
return mRedirectChain;
|
|
|
|
}
|
|
|
|
|
2015-12-07 02:33:14 +03:00
|
|
|
void
|
|
|
|
LoadInfo::SetCorsPreflightInfo(const nsTArray<nsCString>& aHeaders,
|
|
|
|
bool aForcePreflight)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(GetSecurityMode() == nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS);
|
|
|
|
MOZ_ASSERT(!mInitialSecurityCheckDone);
|
|
|
|
mCorsUnsafeHeaders = aHeaders;
|
|
|
|
mForcePreflight = aForcePreflight;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsTArray<nsCString>&
|
|
|
|
LoadInfo::CorsUnsafeHeaders()
|
|
|
|
{
|
|
|
|
return mCorsUnsafeHeaders;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetForcePreflight(bool* aForcePreflight)
|
|
|
|
{
|
|
|
|
*aForcePreflight = mForcePreflight;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LoadInfo::SetIsPreflight()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(GetSecurityMode() == nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS);
|
|
|
|
MOZ_ASSERT(!mInitialSecurityCheckDone);
|
|
|
|
mIsPreflight = true;
|
|
|
|
}
|
|
|
|
|
2017-01-23 17:29:44 +03:00
|
|
|
void
|
|
|
|
LoadInfo::SetUpgradeInsecureRequests()
|
|
|
|
{
|
|
|
|
mUpgradeInsecureRequests = true;
|
|
|
|
}
|
|
|
|
|
2015-12-07 02:33:14 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetIsPreflight(bool* aIsPreflight)
|
|
|
|
{
|
|
|
|
*aIsPreflight = mIsPreflight;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
Bug 1246540 - HSTS Priming Proof of Concept. r=ckerschb, r=mayhemer, r=jld, r=smaug, r=dkeeler, r=jmaher, p=ally
HSTS priming changes the order of mixed-content blocking and HSTS
upgrades, and adds a priming request to check if a mixed-content load is
accesible over HTTPS and the server supports upgrading via the
Strict-Transport-Security header.
Every call site that uses AsyncOpen2 passes through the mixed-content
blocker, and has a LoadInfo. If the mixed-content blocker marks the load as
needing HSTS priming, nsHttpChannel will build and send an HSTS priming
request on the same URI with the scheme upgraded to HTTPS. If the server
allows the upgrade, then channel performs an internal redirect to the HTTPS URI,
otherwise use the result of mixed-content blocker to allow or block the
load.
nsISiteSecurityService adds an optional boolean out parameter to
determine if the HSTS state is already cached for negative assertions.
If the host has been probed within the previous 24 hours, no HSTS
priming check will be sent.
MozReview-Commit-ID: ES1JruCtDdX
--HG--
extra : rebase_source : 2ac6c93c49f2862fc0b9e595eb0598cd1ea4bedf
2016-09-27 18:27:00 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetForceHSTSPriming(bool* aForceHSTSPriming)
|
|
|
|
{
|
|
|
|
*aForceHSTSPriming = mForceHSTSPriming;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetMixedContentWouldBlock(bool *aMixedContentWouldBlock)
|
|
|
|
{
|
|
|
|
*aMixedContentWouldBlock = mMixedContentWouldBlock;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LoadInfo::SetHSTSPriming(bool aMixedContentWouldBlock)
|
|
|
|
{
|
|
|
|
mForceHSTSPriming = true;
|
|
|
|
mMixedContentWouldBlock = aMixedContentWouldBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LoadInfo::ClearHSTSPriming()
|
|
|
|
{
|
|
|
|
mForceHSTSPriming = false;
|
|
|
|
mMixedContentWouldBlock = false;
|
|
|
|
}
|
|
|
|
|
2017-05-10 01:36:07 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::SetIsHSTSPriming(bool aIsHSTSPriming)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aIsHSTSPriming);
|
|
|
|
mIsHSTSPriming = aIsHSTSPriming;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetIsHSTSPriming(bool* aIsHSTSPriming)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aIsHSTSPriming);
|
|
|
|
*aIsHSTSPriming = mIsHSTSPriming;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::SetIsHSTSPrimingUpgrade(bool aIsHSTSPrimingUpgrade)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aIsHSTSPrimingUpgrade);
|
|
|
|
mIsHSTSPrimingUpgrade = aIsHSTSPrimingUpgrade;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetIsHSTSPrimingUpgrade(bool* aIsHSTSPrimingUpgrade)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aIsHSTSPrimingUpgrade);
|
|
|
|
*aIsHSTSPrimingUpgrade = mIsHSTSPrimingUpgrade;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-10-22 21:07:32 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetTainting(uint32_t* aTaintingOut)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aTaintingOut);
|
|
|
|
*aTaintingOut = static_cast<uint32_t>(mTainting);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::MaybeIncreaseTainting(uint32_t aTainting)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG(aTainting <= TAINTING_OPAQUE);
|
|
|
|
LoadTainting tainting = static_cast<LoadTainting>(aTainting);
|
|
|
|
if (tainting > mTainting) {
|
|
|
|
mTainting = tainting;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-06-07 18:34:51 +03:00
|
|
|
void
|
|
|
|
LoadInfo::SynthesizeServiceWorkerTainting(LoadTainting aTainting)
|
|
|
|
{
|
|
|
|
MOZ_DIAGNOSTIC_ASSERT(aTainting <= LoadTainting::Opaque);
|
|
|
|
mTainting = aTainting;
|
|
|
|
}
|
|
|
|
|
2016-08-22 04:46:09 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetIsTopLevelLoad(bool *aResult)
|
|
|
|
{
|
|
|
|
*aResult = mFrameOuterWindowID ? mFrameOuterWindowID == mOuterWindowID
|
|
|
|
: mParentOuterWindowID == mOuterWindowID;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-05-30 19:07:59 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::GetResultPrincipalURI(nsIURI **aURI)
|
|
|
|
{
|
|
|
|
NS_IF_ADDREF(*aURI = mResultPrincipalURI);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
LoadInfo::SetResultPrincipalURI(nsIURI *aURI)
|
|
|
|
{
|
|
|
|
mResultPrincipalURI = aURI;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-05-19 05:02:57 +03:00
|
|
|
} // namespace net
|
2014-07-10 10:56:37 +04:00
|
|
|
} // namespace mozilla
|