OLD | NEW |
---|---|
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 enum Options { | |
Sam McNally
2014/11/24 04:40:15
Comments?
not at google - send to devlin
2014/11/24 18:18:02
when you do: please add a comment to ALLOW_INSECUR
raymes
2014/11/25 13:34:10
Done.
raymes
2014/11/25 13:34:10
Done.
| |
22 NO_OPTIONS = 0x00, | |
Sam McNally
2014/11/24 04:40:15
Prefix values with OPTIONS_.
raymes
2014/11/25 13:34:10
Done.
| |
23 ALLOW_UNSAFE_EVAL = 0x01, | |
24 ALLOW_INSECURE_OBJECT_SRC = 0x02, | |
not at google - send to devlin
2014/11/24 18:18:02
Let's keep discussing this enum: More typical styl
raymes
2014/11/25 13:34:10
Done.
| |
25 }; | |
26 | |
21 // Checks whether the given |policy| meets the minimum security requirements | 27 // Checks whether the given |policy| meets the minimum security requirements |
22 // for use in the extension system. | 28 // for use in the extension system. |
23 // | 29 // |
24 // Ideally, we would like to say that an XSS vulnerability in the extension | 30 // Ideally, we would like to say that an XSS vulnerability in the extension |
25 // should not be able to execute script, even in the precense of an active | 31 // should not be able to execute script, even in the precense of an active |
26 // network attacker. | 32 // network attacker. |
27 // | 33 // |
28 // However, we found that it broke too many deployed extensions to limit | 34 // However, we found that it broke too many deployed extensions to limit |
29 // 'unsafe-eval' in the script-src directive, so that is allowed as a special | 35 // 'unsafe-eval' in the script-src directive, so that is allowed as a special |
30 // case for extensions. Platform apps disallow it. | 36 // case for extensions. Platform apps disallow it. |
31 bool ContentSecurityPolicyIsSecure( | 37 bool ContentSecurityPolicyIsSecure( |
32 const std::string& policy, Manifest::Type type); | 38 const std::string& policy, int options); |
not at google - send to devlin
2014/11/24 18:18:03
Mention that this is a bitmask.
raymes
2014/11/25 13:34:10
Done.
| |
33 | 39 |
34 // Checks whether the given |policy| enforces a unique origin sandbox as | 40 // Checks whether the given |policy| enforces a unique origin sandbox as |
35 // defined by http://www.whatwg.org/specs/web-apps/current-work/multipage/ | 41 // defined by http://www.whatwg.org/specs/web-apps/current-work/multipage/ |
36 // the-iframe-element.html#attr-iframe-sandbox. The policy must have the | 42 // the-iframe-element.html#attr-iframe-sandbox. The policy must have the |
37 // "sandbox" directive, and the sandbox tokens must not include | 43 // "sandbox" directive, and the sandbox tokens must not include |
38 // "allow-same-origin". Additional restrictions may be imposed depending on | 44 // "allow-same-origin". Additional restrictions may be imposed depending on |
39 // |type|. | 45 // |type|. |
40 bool ContentSecurityPolicyIsSandboxed( | 46 bool ContentSecurityPolicyIsSandboxed( |
41 const std::string& policy, Manifest::Type type); | 47 const std::string& policy, Manifest::Type type); |
42 | 48 |
43 } // namespace csp_validator | 49 } // namespace csp_validator |
44 | 50 |
45 } // namespace extensions | 51 } // namespace extensions |
46 | 52 |
47 #endif // EXTENSIONS_COMMON_CSP_VALIDATOR_H_ | 53 #endif // EXTENSIONS_COMMON_CSP_VALIDATOR_H_ |
OLD | NEW |