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

Side by Side Diff: extensions/common/csp_validator.h

Issue 760513003: Only allow insecure object-src directives for whitelisted mime types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@extensions-csp3
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | extensions/common/csp_validator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef EXTENSIONS_COMMON_CSP_VALIDATOR_H_ 5 #ifndef EXTENSIONS_COMMON_CSP_VALIDATOR_H_
6 #define EXTENSIONS_COMMON_CSP_VALIDATOR_H_ 6 #define EXTENSIONS_COMMON_CSP_VALIDATOR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "extensions/common/manifest.h" 10 #include "extensions/common/manifest.h"
11 11
12 namespace extensions { 12 namespace extensions {
13 13
14 namespace csp_validator { 14 namespace csp_validator {
15 15
16 // Checks whether the given |policy| is legal for use in the extension system. 16 // Checks whether the given |policy| is legal for use in the extension system.
17 // This check just ensures that the policy doesn't contain any characters that 17 // This check just ensures that the policy doesn't contain any characters that
18 // will cause problems when we transmit the policy in an HTTP header. 18 // will cause problems when we transmit the policy in an HTTP header.
19 bool ContentSecurityPolicyIsLegal(const std::string& policy); 19 bool ContentSecurityPolicyIsLegal(const std::string& policy);
20 20
21 // This specifies options for configuring which CSP directives are permitted in 21 // This specifies options for configuring which CSP directives are permitted in
22 // extensions. 22 // extensions.
23 enum Options { 23 enum Options {
24 OPTIONS_NONE = 0, 24 OPTIONS_NONE = 0,
25 // Allows 'unsafe-eval' to be specified as a source in a directive. 25 // Allows 'unsafe-eval' to be specified as a source in a directive.
26 OPTIONS_ALLOW_UNSAFE_EVAL = 1 << 0, 26 OPTIONS_ALLOW_UNSAFE_EVAL = 1 << 0,
27 // Allow an object-src to be specified with any sources (i.e. it may contain 27 // Allow an object-src to be specified with any sources (i.e. it may contain
28 // wildcards or http sources). 28 // wildcards or http sources). Specifying this requires the CSP to contain
29 // a plugin-types directive which restricts the plugins that can be loaded
30 // to those which are fully sandboxed.
29 OPTIONS_ALLOW_INSECURE_OBJECT_SRC = 1 << 1, 31 OPTIONS_ALLOW_INSECURE_OBJECT_SRC = 1 << 1,
30 }; 32 };
31 33
32 // Checks whether the given |policy| meets the minimum security requirements 34 // Checks whether the given |policy| meets the minimum security requirements
33 // for use in the extension system. 35 // for use in the extension system.
34 // 36 //
35 // Ideally, we would like to say that an XSS vulnerability in the extension 37 // Ideally, we would like to say that an XSS vulnerability in the extension
36 // should not be able to execute script, even in the precense of an active 38 // should not be able to execute script, even in the precense of an active
37 // network attacker. 39 // network attacker.
38 // 40 //
(...skipping 12 matching lines...) Expand all
51 // "allow-same-origin". Additional restrictions may be imposed depending on 53 // "allow-same-origin". Additional restrictions may be imposed depending on
52 // |type|. 54 // |type|.
53 bool ContentSecurityPolicyIsSandboxed( 55 bool ContentSecurityPolicyIsSandboxed(
54 const std::string& policy, Manifest::Type type); 56 const std::string& policy, Manifest::Type type);
55 57
56 } // namespace csp_validator 58 } // namespace csp_validator
57 59
58 } // namespace extensions 60 } // namespace extensions
59 61
60 #endif // EXTENSIONS_COMMON_CSP_VALIDATOR_H_ 62 #endif // EXTENSIONS_COMMON_CSP_VALIDATOR_H_
OLDNEW
« no previous file with comments | « no previous file | extensions/common/csp_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698