Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(445)

Side by Side Diff: Source/core/page/ContentSecurityPolicy.cpp

Issue 19787002: CSP: 'eval()' blocked in report-only mode should send a violation report. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/http/tests/security/contentSecurityPolicy/eval-allowed-in-report-only-mode-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 // RFC2616, section 4.2 specifies that headers appearing multiple times can 1457 // RFC2616, section 4.2 specifies that headers appearing multiple times can
1458 // be combined with a comma. Walk the header string, and parse each comma 1458 // be combined with a comma. Walk the header string, and parse each comma
1459 // separated chunk as a separate header. 1459 // separated chunk as a separate header.
1460 const UChar* position = begin; 1460 const UChar* position = begin;
1461 while (position < end) { 1461 while (position < end) {
1462 skipUntil(position, end, ','); 1462 skipUntil(position, end, ',');
1463 1463
1464 // header1,header2 OR header1 1464 // header1,header2 OR header1
1465 // ^ ^ 1465 // ^ ^
1466 OwnPtr<CSPDirectiveList> policy = CSPDirectiveList::create(this, begin, position, type); 1466 OwnPtr<CSPDirectiveList> policy = CSPDirectiveList::create(this, begin, position, type);
1467 if (!policy->isReportOnly() && !policy->allowEval(0, SuppressReport)) 1467
1468 // We disable 'eval()' even in the case of report-only policies, and rel y on the check in the V8Initializer::codeGenerationCheckCallbackInMainThread cal lback to determine whether the call should execute or not.
1469 if (!policy->allowEval(0, SuppressReport))
1468 m_scriptExecutionContext->disableEval(policy->evalDisabledErrorMessa ge()); 1470 m_scriptExecutionContext->disableEval(policy->evalDisabledErrorMessa ge());
1469 1471
1470 m_policies.append(policy.release()); 1472 m_policies.append(policy.release());
1471 1473
1472 // Skip the comma, and begin the next header from the current position. 1474 // Skip the comma, and begin the next header from the current position.
1473 ASSERT(position == end || *position == ','); 1475 ASSERT(position == end || *position == ',');
1474 skipExactly(position, end, ','); 1476 skipExactly(position, end, ',');
1475 begin = position; 1477 begin = position;
1476 } 1478 }
1477 } 1479 }
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1903 // Collisions have no security impact, so we can save space by storing only the string's hash rather than the whole report. 1905 // Collisions have no security impact, so we can save space by storing only the string's hash rather than the whole report.
1904 return !m_violationReportsSent.contains(report.impl()->hash()); 1906 return !m_violationReportsSent.contains(report.impl()->hash());
1905 } 1907 }
1906 1908
1907 void ContentSecurityPolicy::didSendViolationReport(const String& report) 1909 void ContentSecurityPolicy::didSendViolationReport(const String& report)
1908 { 1910 {
1909 m_violationReportsSent.add(report.impl()->hash()); 1911 m_violationReportsSent.add(report.impl()->hash());
1910 } 1912 }
1911 1913
1912 } // namespace WebCore 1914 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/security/contentSecurityPolicy/eval-allowed-in-report-only-mode-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698