bool CSPDirectiveList::allowInlineStyle(const String& contextURL, const WTF::OrdinalNumber& contextLine, ContentSecurityPolicy::ReportingStatus reportingStatus) const { DEFINE_STATIC_LOCAL(String, consoleMessage, ("Refused to apply inline style because it violates the following Content Security Policy directive: ")); return reportingStatus == ContentSecurityPolicy::SendReport ? checkInlineAndReportViolation(operativeDirective(m_styleSrc.get()), consoleMessage, contextURL, contextLine, false) : checkInline(operativeDirective(m_styleSrc.get())); }
bool CSPDirectiveList::allowInlineStyle(const String& contextURL, const WTF::OrdinalNumber& contextLine, ContentSecurityPolicy::ReportingStatus reportingStatus, const String& content) const { if (reportingStatus == ContentSecurityPolicy::SendReport) { return checkInlineAndReportViolation(operativeDirective(m_styleSrc.get()), "Refused to apply inline style because it violates the following Content Security Policy directive: ", contextURL, contextLine, false, getSha256String(content)); } return checkInline(operativeDirective(m_styleSrc.get())); }
bool CSPDirectiveList::allowInlineEventHandlers(const String& contextURL, const WTF::OrdinalNumber& contextLine, ContentSecurityPolicy::ReportingStatus reportingStatus) const { DEFINE_STATIC_LOCAL(String, consoleMessage, ("Refused to execute inline event handler because it violates the following Content Security Policy directive: ")); if (reportingStatus == ContentSecurityPolicy::SendReport) return checkInlineAndReportViolation(operativeDirective(m_scriptSrc.get()), consoleMessage, contextURL, contextLine, true); return checkInline(operativeDirective(m_scriptSrc.get())); }
bool CSPDirectiveList::allowEval(ScriptState* scriptState, ContentSecurityPolicy::ReportingStatus reportingStatus, ContentSecurityPolicy::ExceptionStatus exceptionStatus) const { if (reportingStatus == ContentSecurityPolicy::SendReport) { return checkEvalAndReportViolation(operativeDirective(m_scriptSrc.get()), "Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: ", scriptState, exceptionStatus); } return checkEval(operativeDirective(m_scriptSrc.get())); }
bool CSPDirectiveList::allowInlineEventHandlers(const String& contextURL, const WTF::OrdinalNumber& contextLine, ContentSecurityPolicy::ReportingStatus reportingStatus) const { if (reportingStatus == ContentSecurityPolicy::SendReport) { return checkInlineAndReportViolation(operativeDirective(m_scriptSrc.get()), "Refused to execute inline event handler because it violates the following Content Security Policy directive: ", contextURL, contextLine, true, "sha256-..."); } return checkInline(operativeDirective(m_scriptSrc.get())); }
bool CSPDirectiveList::allowObjectFromSource(const KURL& url, ContentSecurityPolicy::ReportingStatus reportingStatus) const { if (url.protocolIsAbout()) return true; return reportingStatus == ContentSecurityPolicy::SendReport ? checkSourceAndReportViolation(operativeDirective(m_objectSrc.get()), url, ContentSecurityPolicy::ObjectSrc) : checkSource(operativeDirective(m_objectSrc.get()), url); }
bool CSPDirectiveList::allowEval(ScriptState* scriptState, ContentSecurityPolicy::ReportingStatus reportingStatus) const { DEFINE_STATIC_LOCAL(String, consoleMessage, ("Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: ")); return reportingStatus == ContentSecurityPolicy::SendReport ? checkEvalAndReportViolation(operativeDirective(m_scriptSrc.get()), consoleMessage, scriptState) : checkEval(operativeDirective(m_scriptSrc.get())); }
bool CSPDirectiveList::allowChildFrameFromSource(const KURL& url, ContentSecurityPolicy::RedirectStatus redirectStatus, ContentSecurityPolicy::ReportingStatus reportingStatus) const { if (url.protocolIsAbout()) return true; // 'frame-src' is the only directive which overrides something other than the default sources. // It overrides 'child-src', which overrides the default sources. So, we do this nested set // of calls to 'operativeDirective()' to grab 'frame-src' if it exists, 'child-src' if it // doesn't, and 'defaut-src' if neither are available. SourceListDirective* whichDirective = operativeDirective(m_frameSrc.get(), operativeDirective(m_childSrc.get())); return reportingStatus == ContentSecurityPolicy::SendReport ? checkSourceAndReportViolation(whichDirective, url, ContentSecurityPolicy::FrameSrc, redirectStatus) : checkSource(whichDirective, url, redirectStatus); }
void ContentSecurityPolicy::didReceiveHeader(const String& header) { if (m_havePolicy) return; // The first policy wins. parse(header); m_havePolicy = true; if (!checkEval(operativeDirective(m_scriptSrc.get()))) { if (Frame* frame = m_document->frame()) frame->script()->disableEval(); } }
bool ContentSecurityPolicy::allowMediaFromSource(const KURL& url) const { DEFINE_STATIC_LOCAL(String, type, ("media")); return checkSourceAndReportViolation(operativeDirective(m_mediaSrc.get()), url, type); }
bool ContentSecurityPolicy::allowEval() const { DEFINE_STATIC_LOCAL(String, consoleMessage, ("Refused to evaluate script because of Content-Security-Policy.\n")); return checkEvalAndReportViolation(operativeDirective(m_scriptSrc.get()), consoleMessage); }
bool ContentSecurityPolicy::allowInlineStyle() const { DEFINE_STATIC_LOCAL(String, consoleMessage, ("Refused to apply inline style because of Content-Security-Policy.\n")); return checkInlineAndReportViolation(operativeDirective(m_styleSrc.get()), consoleMessage); }
bool ContentSecurityPolicy::allowInlineEventHandlers() const { DEFINE_STATIC_LOCAL(String, consoleMessage, ("Refused to execute inline event handler because of Content-Security-Policy.\n")); return checkInlineAndReportViolation(operativeDirective(m_scriptSrc.get()), consoleMessage); }
bool CSPDirectiveList::allowStyleHash(const CSPHashValue& hashValue) const { return checkHash(operativeDirective(m_styleSrc.get()), hashValue); }
bool CSPDirectiveList::allowStyleNonce(const String& nonce) const { return checkNonce(operativeDirective(m_styleSrc.get()), nonce); }
bool CSPDirectiveList::allowChildContextFromSource(const KURL& url, ContentSecurityPolicy::ReportingStatus reportingStatus) const { return reportingStatus == ContentSecurityPolicy::SendReport ? checkSourceAndReportViolation(operativeDirective(m_childSrc.get()), url, ContentSecurityPolicy::ChildSrc) : checkSource(operativeDirective(m_childSrc.get()), url); }
bool CSPDirectiveList::allowConnectToSource(const KURL& url, ContentSecurityPolicy::RedirectStatus redirectStatus, ContentSecurityPolicy::ReportingStatus reportingStatus) const { return reportingStatus == ContentSecurityPolicy::SendReport ? checkSourceAndReportViolation(operativeDirective(m_connectSrc.get()), url, ContentSecurityPolicy::ConnectSrc, redirectStatus) : checkSource(operativeDirective(m_connectSrc.get()), url, redirectStatus); }