OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_SECURITY_STATE_SECURITY_STATE_MODEL_H_ | |
6 #define COMPONENTS_SECURITY_STATE_SECURITY_STATE_MODEL_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include "base/macros.h" | |
11 #include "net/cert/cert_status_flags.h" | |
12 #include "net/cert/sct_status_flags.h" | |
13 #include "net/cert/x509_certificate.h" | |
14 #include "url/gurl.h" | |
15 | |
16 namespace security_state { | |
17 | |
18 class SecurityStateModelClient; | |
19 | |
20 // SecurityStateModel provides high-level security information about a | |
21 // page or request. | |
22 // | |
23 // SecurityStateModel::SecurityInfo is the main data structure computed | |
24 // by a SecurityStateModel. SecurityInfo contains a SecurityLevel (which | |
25 // is a single value describing the overall security state) along with | |
26 // information that a consumer might want to display in UI to explain or | |
27 // elaborate on the SecurityLevel. | |
28 class SecurityStateModel { | |
29 public: | |
30 // Describes the overall security state of the page. | |
31 // | |
32 // If you reorder, add, or delete values from this enum, you must also | |
33 // update the UI icons in ToolbarModelImpl::GetIconForSecurityLevel. | |
34 // | |
35 // A Java counterpart will be generated for this enum. | |
36 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.components.security_state | |
37 // GENERATED_JAVA_CLASS_NAME_OVERRIDE: ConnectionSecurityLevel | |
38 enum SecurityLevel { | |
39 // HTTP/no URL/HTTPS but with insecure passive content on the page. | |
40 NONE, | |
41 | |
42 // HTTP, in a case where we want to show a visible warning about the page's | |
43 // lack of security. | |
44 // | |
45 // The criteria used to classify pages as NONE vs. HTTP_SHOW_WARNING will | |
46 // change over time. Eventually, NONE will be eliminated. | |
47 // See https://crbug.com/647754. | |
48 HTTP_SHOW_WARNING, | |
49 | |
50 // HTTPS with valid EV cert. | |
51 EV_SECURE, | |
52 | |
53 // HTTPS (non-EV) with valid cert. | |
54 SECURE, | |
55 | |
56 // HTTPS, but with an outdated protocol version. | |
57 SECURITY_WARNING, | |
58 | |
59 // HTTPS, but the certificate verification chain is anchored on a | |
60 // certificate that was installed by the system administrator. | |
61 SECURE_WITH_POLICY_INSTALLED_CERT, | |
62 | |
63 // Attempted HTTPS and failed, page not authenticated, HTTPS with | |
64 // insecure active content on the page, malware, phishing, or any other | |
65 // serious security issue that could be dangerous. | |
66 DANGEROUS, | |
67 }; | |
68 | |
69 // Describes how the SHA1 deprecation policy applies to an HTTPS | |
70 // connection. | |
71 enum SHA1DeprecationStatus { | |
72 UNKNOWN_SHA1, | |
73 // No SHA1 deprecation policy applies. | |
74 NO_DEPRECATED_SHA1, | |
75 // The connection used a certificate with a SHA1 signature in the | |
76 // chain, and policy says that the connection should be treated with a | |
77 // warning. | |
78 DEPRECATED_SHA1_MINOR, | |
79 // The connection used a certificate with a SHA1 signature in the | |
80 // chain, and policy says that the connection should be treated as | |
81 // broken HTTPS. | |
82 DEPRECATED_SHA1_MAJOR, | |
83 }; | |
84 | |
85 // The ContentStatus enum is used to describe content on the page that | |
86 // has significantly different security properties than the main page | |
87 // load. Content can be passive content that is displayed (such as | |
88 // images) or active content that is run (such as scripts or iframes). | |
89 enum ContentStatus { | |
90 CONTENT_STATUS_UNKNOWN, | |
91 CONTENT_STATUS_NONE, | |
92 CONTENT_STATUS_DISPLAYED, | |
93 CONTENT_STATUS_RAN, | |
94 CONTENT_STATUS_DISPLAYED_AND_RAN, | |
95 }; | |
96 | |
97 // Describes whether the page contains malicious resources such as | |
98 // malware or phishing attacks. | |
99 enum MaliciousContentStatus { | |
100 MALICIOUS_CONTENT_STATUS_NONE, | |
101 MALICIOUS_CONTENT_STATUS_MALWARE, | |
102 MALICIOUS_CONTENT_STATUS_UNWANTED_SOFTWARE, | |
103 MALICIOUS_CONTENT_STATUS_SOCIAL_ENGINEERING, | |
104 }; | |
105 | |
106 // Describes the security status of a page or request. This is the | |
107 // main data structure provided by this class. | |
108 struct SecurityInfo { | |
109 SecurityInfo(); | |
110 ~SecurityInfo(); | |
111 SecurityLevel security_level; | |
112 // Describes the nature of the page's malicious content, if any. | |
113 MaliciousContentStatus malicious_content_status; | |
114 SHA1DeprecationStatus sha1_deprecation_status; | |
115 // |mixed_content_status| describes the presence of content that was | |
116 // loaded over a nonsecure (HTTP) connection. | |
117 ContentStatus mixed_content_status; | |
118 // |content_with_cert_errors_status| describes the presence of | |
119 // content that was loaded over an HTTPS connection with | |
120 // certificate errors. | |
121 ContentStatus content_with_cert_errors_status; | |
122 // The verification statuses of the signed certificate timestamps | |
123 // for the connection. | |
124 std::vector<net::ct::SCTVerifyStatus> sct_verify_statuses; | |
125 bool scheme_is_cryptographic; | |
126 net::CertStatus cert_status; | |
127 scoped_refptr<net::X509Certificate> certificate; | |
128 // The security strength, in bits, of the SSL cipher suite. In late | |
129 // 2015, 128 is considered the minimum. | |
130 // | |
131 // 0 means the connection uses HTTPS but is not encrypted. -1 means | |
132 // the security strength is unknown or the connection does not use | |
133 // HTTPS. | |
134 int security_bits; | |
135 // Information about the SSL connection, such as protocol and | |
136 // ciphersuite. See ssl_connection_flags.h in net. | |
137 int connection_status; | |
138 // The ID of the (EC)DH group used by the key exchange. The value is zero if | |
139 // unknown (older cache entries may not store the value) or not applicable. | |
140 uint16_t key_exchange_group; | |
141 // A mask that indicates which of the protocol version, | |
142 // key exchange, or cipher for the connection is considered | |
143 // obsolete. See net::ObsoleteSSLMask for specific mask values. | |
144 int obsolete_ssl_status; | |
145 | |
146 // True if pinning was bypassed due to a local trust anchor. | |
147 bool pkp_bypassed; | |
148 | |
149 // True if the page displayed password field on an HTTP page. | |
150 bool displayed_password_field_on_http; | |
151 | |
152 // True if the page displayed credit card field on an HTTP page. | |
153 bool displayed_credit_card_field_on_http; | |
154 }; | |
155 | |
156 // Contains the security state relevant to computing the SecurityInfo | |
157 // for a page. This is the input to GetSecurityInfo() provided by the | |
158 // model's client. | |
159 struct VisibleSecurityState { | |
160 VisibleSecurityState(); | |
161 ~VisibleSecurityState(); | |
162 bool operator==(const VisibleSecurityState& other) const; | |
163 GURL url; | |
164 | |
165 MaliciousContentStatus malicious_content_status; | |
166 | |
167 // CONNECTION SECURITY FIELDS | |
168 // Whether the connection security fields are initialized. | |
169 bool connection_info_initialized; | |
170 // The following fields contain information about the connection | |
171 // used to load the page or request. | |
172 scoped_refptr<net::X509Certificate> certificate; | |
173 net::CertStatus cert_status; | |
174 int connection_status; | |
175 // The ID of the (EC)DH group used by the key exchange. The value is zero if | |
176 // unknown (older cache entries may not store the value) or not applicable. | |
177 uint16_t key_exchange_group; | |
178 int security_bits; | |
179 // The verification statuses of the Signed Certificate | |
180 // Timestamps (if any) that the server provided. | |
181 std::vector<net::ct::SCTVerifyStatus> sct_verify_statuses; | |
182 // True if the page displayed passive mixed content. | |
183 bool displayed_mixed_content; | |
184 // True if the page ran active mixed content. | |
185 bool ran_mixed_content; | |
186 // True if the page displayed passive subresources with certificate errors. | |
187 bool displayed_content_with_cert_errors; | |
188 // True if the page ran active subresources with certificate errors. | |
189 bool ran_content_with_cert_errors; | |
190 // True if PKP was bypassed due to a local trust anchor. | |
191 bool pkp_bypassed; | |
192 // True if the page was an HTTP page that displayed a password field. | |
193 bool displayed_password_field_on_http; | |
194 // True if the page was an HTTP page that displayed a credit card field. | |
195 bool displayed_credit_card_field_on_http; | |
196 }; | |
197 | |
198 // These security levels describe the treatment given to pages that | |
199 // display and run mixed content. They are used to coordinate the | |
200 // treatment of mixed content with other security UI elements. | |
201 static const SecurityLevel kDisplayedInsecureContentLevel; | |
202 static const SecurityLevel kRanInsecureContentLevel; | |
203 | |
204 SecurityStateModel(); | |
205 virtual ~SecurityStateModel(); | |
206 | |
207 // Populates |result| to describe the current page. | |
208 void GetSecurityInfo(SecurityInfo* result) const; | |
209 | |
210 void SetClient(SecurityStateModelClient* client); | |
211 | |
212 private: | |
213 SecurityStateModelClient* client_; | |
214 | |
215 DISALLOW_COPY_AND_ASSIGN(SecurityStateModel); | |
216 }; | |
217 | |
218 } // namespace security_state | |
219 | |
220 #endif // COMPONENTS_SECURITY_STATE_SECURITY_STATE_MODEL_H_ | |
OLD | NEW |