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

Side by Side Diff: content/common/content_security_policy/csp_source.h

Issue 2792013002: Stop CSP from matching independent scheme/port upgrades (content layer) (Closed)
Patch Set: Created 3 years, 8 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H_ 5 #ifndef CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H_
6 #define CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H_ 6 #define CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
11 #include "url/gurl.h" 11 #include "url/gurl.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 class CSPContext; 15 class CSPContext;
16 16
17 // A CSPSource represents an expression that matches a set of urls. 17 // A CSPSource represents an expression that matches a set of urls.
18 // Examples of CSPSource: 18 // Examples of CSPSource:
19 // - domain.example.com 19 // - domain.example.com
20 // - *.example.com 20 // - *.example.com
21 // - https://cdn.com 21 // - https://cdn.com
22 // - data: 22 // - data:
23 // - 'none' 23 // - 'none'
24 // - 'self' 24 // - 'self'
25 // - * 25 // - *
26 struct CONTENT_EXPORT CSPSource { 26 struct CONTENT_EXPORT CSPSource {
27 // NotMatching is the only negative member, the rest are different types of
28 // matches. NotMatching should always be 0 to let if statements work nicely
29 enum class PortMatchingResult {
30 NotMatching,
31 MatchingWildcard,
32 MatchingUpgrade,
33 MatchingExact
34 };
35 enum class SchemeMatchingResult {
36 NotMatching,
37 MatchingUpgrade,
38 MatchingExact
39 };
40
arthursonzogni 2017/04/07 09:20:27 Can you please put these enums inside the implemen
andypaicu 2017/04/07 11:34:24 Done
27 CSPSource(); 41 CSPSource();
28 CSPSource(const std::string& scheme, 42 CSPSource(const std::string& scheme,
29 const std::string& host, 43 const std::string& host,
30 bool is_host_wildcard, 44 bool is_host_wildcard,
31 int port, 45 int port,
32 bool is_port_wildcard, 46 bool is_port_wildcard,
33 const std::string& path); 47 const std::string& path);
34 CSPSource(const CSPSource& source); 48 CSPSource(const CSPSource& source);
35 ~CSPSource(); 49 ~CSPSource();
36 50
(...skipping 20 matching lines...) Expand all
57 71
58 // Returns true if the |source| matches the |url| for a given |context|. 72 // Returns true if the |source| matches the |url| for a given |context|.
59 static bool Allow(const CSPSource& source, 73 static bool Allow(const CSPSource& source,
60 const GURL& url, 74 const GURL& url,
61 CSPContext* context, 75 CSPContext* context,
62 bool is_redirect = false); 76 bool is_redirect = false);
63 }; 77 };
64 78
65 } // namespace content 79 } // namespace content
66 #endif // CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H_ 80 #endif // CONTENT_COMMON_CONTENT_SECURITY_POLICY_CSP_SOURCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698