diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:37 +0000 |
commit | a90a5cba08fdf6c0ceb95101c275108a152a3aed (patch) | |
tree | 532507288f3defd7f4dcf1af49698bcb76034855 /dom/security/nsCSPUtils.h | |
parent | Adding debian version 126.0.1-1. (diff) | |
download | firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/security/nsCSPUtils.h')
-rw-r--r-- | dom/security/nsCSPUtils.h | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/dom/security/nsCSPUtils.h b/dom/security/nsCSPUtils.h index eeccaf0c4a..b9ef52967e 100644 --- a/dom/security/nsCSPUtils.h +++ b/dom/security/nsCSPUtils.h @@ -93,24 +93,15 @@ static const char* CSPStrDirectives[] = { "script-src-attr", // SCRIPT_SRC_ATTR_DIRECTIVE "style-src-elem", // STYLE_SRC_ELEM_DIRECTIVE "style-src-attr", // STYLE_SRC_ATTR_DIRECTIVE + "require-trusted-types-for", // REQUIRE_TRUSTED_TYPES_FOR_DIRECTIVE + "trusted-types", // TRUSTED_TYPES_DIRECTIVE }; inline const char* CSP_CSPDirectiveToString(CSPDirective aDir) { return CSPStrDirectives[static_cast<uint32_t>(aDir)]; } -inline CSPDirective CSP_StringToCSPDirective(const nsAString& aDir) { - nsString lowerDir = PromiseFlatString(aDir); - ToLowerCase(lowerDir); - - uint32_t numDirs = (sizeof(CSPStrDirectives) / sizeof(CSPStrDirectives[0])); - for (uint32_t i = 1; i < numDirs; i++) { - if (lowerDir.EqualsASCII(CSPStrDirectives[i])) { - return static_cast<CSPDirective>(i); - } - } - return nsIContentSecurityPolicy::NO_DIRECTIVE; -} +CSPDirective CSP_StringToCSPDirective(const nsAString& aDir); #define FOR_EACH_CSP_KEYWORD(MACRO) \ MACRO(CSP_SELF, "'self'") \ @@ -396,6 +387,34 @@ class nsCSPSandboxFlags : public nsCSPBaseSrc { nsString mFlags; }; +/* =============== nsCSPRequireTrustedTypesForDirectiveValue =============== */ + +class nsCSPRequireTrustedTypesForDirectiveValue : public nsCSPBaseSrc { + public: + explicit nsCSPRequireTrustedTypesForDirectiveValue(const nsAString& aValue); + virtual ~nsCSPRequireTrustedTypesForDirectiveValue() = default; + + bool visit(nsCSPSrcVisitor* aVisitor) const override; + void toString(nsAString& aOutStr) const override; + + private: + const nsString mValue; +}; + +/* =============== nsCSPTrustedTypesDirectiveExpression =============== */ + +class nsCSPTrustedTypesDirectivePolicyName : public nsCSPBaseSrc { + public: + explicit nsCSPTrustedTypesDirectivePolicyName(const nsAString& aName); + virtual ~nsCSPTrustedTypesDirectivePolicyName() = default; + + bool visit(nsCSPSrcVisitor* aVisitor) const override; + void toString(nsAString& aOutStr) const override; + + private: + const nsString mName; +}; + /* =============== nsCSPSrcVisitor ================== */ class nsCSPSrcVisitor { @@ -431,6 +450,7 @@ class nsCSPDirective { virtual void toString(nsAString& outStr) const; void toDomCSPStruct(mozilla::dom::CSP& outCSP) const; + // Takes ownership of the passed sources. virtual void addSrcs(const nsTArray<nsCSPBaseSrc*>& aSrcs) { mSrcs = aSrcs.Clone(); } @@ -652,8 +672,8 @@ class nsCSPPolicy { void getReportURIs(nsTArray<nsString>& outReportURIs) const; void getViolatedDirectiveInformation(CSPDirective aDirective, - nsAString& outDirective, - nsAString& outDirectiveString, + nsAString& aDirectiveName, + nsAString& aDirectiveNameAndValue, bool* aReportSample) const; uint32_t getSandboxFlags() const; |