mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-03 23:30:46 +00:00
Bug 1391277 - Investigative logging in CSP: log when 'upgrade-insecure-requests' CSP is added to the CSP context, r=bz
This commit is contained in:
parent
1696926795
commit
c3f3b8d161
@ -8086,3 +8086,6 @@ HTMLMediaElement::ReportCanPlayTelemetry()
|
|||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#undef LOG
|
||||||
|
#undef LOG_EVENT
|
||||||
|
@ -8,10 +8,15 @@
|
|||||||
#include "mozilla/dom/HTMLMetaElement.h"
|
#include "mozilla/dom/HTMLMetaElement.h"
|
||||||
#include "mozilla/dom/HTMLMetaElementBinding.h"
|
#include "mozilla/dom/HTMLMetaElementBinding.h"
|
||||||
#include "mozilla/dom/nsCSPService.h"
|
#include "mozilla/dom/nsCSPService.h"
|
||||||
|
#include "mozilla/Logging.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsStyleConsts.h"
|
#include "nsStyleConsts.h"
|
||||||
#include "nsIContentSecurityPolicy.h"
|
#include "nsIContentSecurityPolicy.h"
|
||||||
|
|
||||||
|
static mozilla::LazyLogModule gMetaElementLog("nsMetaElement");
|
||||||
|
#define LOG(msg) MOZ_LOG(gMetaElementLog, mozilla::LogLevel::Debug, msg)
|
||||||
|
#define LOG_ENABLED() MOZ_LOG_TEST(gMetaElementLog, mozilla::LogLevel::Debug)
|
||||||
|
|
||||||
NS_IMPL_NS_NEW_HTML_ELEMENT(Meta)
|
NS_IMPL_NS_NEW_HTML_ELEMENT(Meta)
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
@ -117,6 +122,17 @@ HTMLMetaElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|||||||
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(aDocument);
|
nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(aDocument);
|
||||||
principal->EnsureCSP(domDoc, getter_AddRefs(csp));
|
principal->EnsureCSP(domDoc, getter_AddRefs(csp));
|
||||||
if (csp) {
|
if (csp) {
|
||||||
|
if (LOG_ENABLED()) {
|
||||||
|
nsAutoCString documentURIspec;
|
||||||
|
nsIURI* documentURI = aDocument->GetDocumentURI();
|
||||||
|
if (documentURI) {
|
||||||
|
documentURI->GetAsciiSpec(documentURIspec);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(("HTMLMetaElement %p sets CSP '%s' on document=%p, document-uri=%s",
|
||||||
|
this, NS_ConvertUTF16toUTF8(content).get(), aDocument, documentURIspec.get()));
|
||||||
|
}
|
||||||
|
|
||||||
// Multiple CSPs (delivered through either header of meta tag) need to be
|
// Multiple CSPs (delivered through either header of meta tag) need to be
|
||||||
// joined together, see:
|
// joined together, see:
|
||||||
// https://w3c.github.io/webappsec/specs/content-security-policy/#delivery-html-meta-element
|
// https://w3c.github.io/webappsec/specs/content-security-policy/#delivery-html-meta-element
|
||||||
|
@ -426,6 +426,16 @@ nsCSPContext::AppendPolicy(const nsAString& aPolicyString,
|
|||||||
aReportOnly, this,
|
aReportOnly, this,
|
||||||
aDeliveredViaMetaTag);
|
aDeliveredViaMetaTag);
|
||||||
if (policy) {
|
if (policy) {
|
||||||
|
if (policy->hasDirective(nsIContentSecurityPolicy::UPGRADE_IF_INSECURE_DIRECTIVE)) {
|
||||||
|
nsAutoCString selfURIspec, referrer;
|
||||||
|
if (mSelfURI) {
|
||||||
|
mSelfURI->GetAsciiSpec(selfURIspec);
|
||||||
|
}
|
||||||
|
referrer = NS_ConvertUTF16toUTF8(mReferrer);
|
||||||
|
CSPCONTEXTLOG(("nsCSPContext::AppendPolicy added UPGRADE_IF_INSECURE_DIRECTIVE self-uri=%s referrer=%s",
|
||||||
|
selfURIspec.get(), referrer.get()));
|
||||||
|
}
|
||||||
|
|
||||||
mPolicies.AppendElement(policy);
|
mPolicies.AppendElement(policy);
|
||||||
// reset cache since effective policy changes
|
// reset cache since effective policy changes
|
||||||
mShouldLoadCache.Clear();
|
mShouldLoadCache.Clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user