OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google, Inc. All rights reserved. | 2 * Copyright (C) 2011 Google, Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 | 1090 |
1091 bool CSPDirectiveList::checkInlineAndReportViolation(SourceListDirective* direct
ive, const String& consoleMessage, const String& contextURL, const WTF::OrdinalN
umber& contextLine, bool isScript) const | 1091 bool CSPDirectiveList::checkInlineAndReportViolation(SourceListDirective* direct
ive, const String& consoleMessage, const String& contextURL, const WTF::OrdinalN
umber& contextLine, bool isScript) const |
1092 { | 1092 { |
1093 if (checkInline(directive)) | 1093 if (checkInline(directive)) |
1094 return true; | 1094 return true; |
1095 | 1095 |
1096 String suffix = String(); | 1096 String suffix = String(); |
1097 if (directive->allowInline() && directive->isHashOrNoncePresent()) { | 1097 if (directive->allowInline() && directive->isHashOrNoncePresent()) { |
1098 // If inline is allowed, but a hash or nonce is present, we ignore 'unsa
fe-inline'. Throw a reasonable error. | 1098 // If inline is allowed, but a hash or nonce is present, we ignore 'unsa
fe-inline'. Throw a reasonable error. |
1099 suffix = " Note that 'unsafe-inline' is ignored if either a hash or nonc
e value is present in the source list."; | 1099 suffix = " Note that 'unsafe-inline' is ignored if either a hash or nonc
e value is present in the source list."; |
1100 } else if (directive == m_defaultSrc) { | 1100 } else { |
1101 suffix = " Note that '" + String(isScript ? "script" : "style") + "-src'
was not explicitly set, so 'default-src' is used as a fallback."; | 1101 suffix = " Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or
a nonce ('nonce-...') is required to enable inline execution."; |
| 1102 if (directive == m_defaultSrc) |
| 1103 suffix = suffix + " Note also that '" + String(isScript ? "script" :
"style") + "-src' was not explicitly set, so 'default-src' is used as a fallbac
k."; |
1102 } | 1104 } |
1103 | 1105 |
1104 reportViolationWithLocation(directive->text(), isScript ? scriptSrc : styleS
rc, consoleMessage + "\"" + directive->text() + "\"." + suffix + "\n", KURL(), c
ontextURL, contextLine); | 1106 reportViolationWithLocation(directive->text(), isScript ? scriptSrc : styleS
rc, consoleMessage + "\"" + directive->text() + "\"." + suffix + "\n", KURL(), c
ontextURL, contextLine); |
1105 | 1107 |
1106 if (!m_reportOnly) { | 1108 if (!m_reportOnly) { |
1107 if (isScript) | 1109 if (isScript) |
1108 m_policy->reportBlockedScriptExecutionToInspector(directive->text())
; | 1110 m_policy->reportBlockedScriptExecutionToInspector(directive->text())
; |
1109 return false; | 1111 return false; |
1110 } | 1112 } |
1111 return true; | 1113 return true; |
(...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2160 // Collisions have no security impact, so we can save space by storing only
the string's hash rather than the whole report. | 2162 // Collisions have no security impact, so we can save space by storing only
the string's hash rather than the whole report. |
2161 return !m_violationReportsSent.contains(report.impl()->hash()); | 2163 return !m_violationReportsSent.contains(report.impl()->hash()); |
2162 } | 2164 } |
2163 | 2165 |
2164 void ContentSecurityPolicy::didSendViolationReport(const String& report) | 2166 void ContentSecurityPolicy::didSendViolationReport(const String& report) |
2165 { | 2167 { |
2166 m_violationReportsSent.add(report.impl()->hash()); | 2168 m_violationReportsSent.add(report.impl()->hash()); |
2167 } | 2169 } |
2168 | 2170 |
2169 } // namespace WebCore | 2171 } // namespace WebCore |
OLD | NEW |