Skip to main content

cdp_driver/protocol/
security.rs

1// @generated by `just generate-methods` from protocol/*.json.
2// Do not edit by hand; edit xtask/ and regenerate.
3
4//! The `Security` domain.
5//!
6//! Types, command parameters and event payloads for the `Security`
7//! domain. The method-name constants for the same domain are in
8//! [`crate::methods`].
9
10use serde::{Deserialize, Serialize};
11
12/// An internal certificate ID value.
13pub type CertificateId = i64;
14
15/// A description of mixed content (HTTP resources on HTTPS pages), as defined
16/// by <https://www.w3.org/TR/mixed-content/#categories>
17#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
18pub enum MixedContentType {
19    /// `blockable`
20    #[serde(rename = "blockable")]
21    Blockable,
22    /// `optionally-blockable`
23    #[serde(rename = "optionally-blockable")]
24    OptionallyBlockable,
25    /// `none`
26    #[serde(rename = "none")]
27    None,
28    /// A value this vendored schema does not list. Chrome adds values ahead of
29    /// the published protocol, so an unrecognised one is kept as it arrived
30    /// rather than failing the payload it came in.
31    #[serde(untagged)]
32    Unrecognized(String),
33}
34
35/// The security level of a page or resource.
36#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
37pub enum SecurityState {
38    /// `unknown`
39    #[serde(rename = "unknown")]
40    Unknown,
41    /// `neutral`
42    #[serde(rename = "neutral")]
43    Neutral,
44    /// `insecure`
45    #[serde(rename = "insecure")]
46    Insecure,
47    /// `secure`
48    #[serde(rename = "secure")]
49    Secure,
50    /// `info`
51    #[serde(rename = "info")]
52    Info,
53    /// `insecure-broken`
54    #[serde(rename = "insecure-broken")]
55    InsecureBroken,
56    /// A value this vendored schema does not list. Chrome adds values ahead of
57    /// the published protocol, so an unrecognised one is kept as it arrived
58    /// rather than failing the payload it came in.
59    #[serde(untagged)]
60    Unrecognized(String),
61}
62
63/// Details about the security state of the page certificate.
64///
65/// Experimental: may change without notice.
66#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
67pub struct CertificateSecurityState {
68    /// Protocol name (e.g. "TLS 1.2" or "QUIC").
69    pub protocol: String,
70    /// Key Exchange used by the connection, or the empty string if not
71    /// applicable.
72    #[serde(rename = "keyExchange")]
73    pub key_exchange: String,
74    /// (EC)DH group used by the connection, if applicable.
75    #[serde(
76        rename = "keyExchangeGroup",
77        default,
78        skip_serializing_if = "Option::is_none"
79    )]
80    pub key_exchange_group: Option<String>,
81    /// Cipher name.
82    pub cipher: String,
83    /// TLS MAC. Note that AEAD ciphers do not have separate MACs.
84    #[serde(default, skip_serializing_if = "Option::is_none")]
85    pub mac: Option<String>,
86    /// Page certificate.
87    pub certificate: Vec<String>,
88    /// Certificate subject name.
89    #[serde(rename = "subjectName")]
90    pub subject_name: String,
91    /// Name of the issuing CA.
92    pub issuer: String,
93    /// Certificate valid from date.
94    #[serde(rename = "validFrom")]
95    pub valid_from: crate::protocol::network::TimeSinceEpoch,
96    /// Certificate valid to (expiration) date
97    #[serde(rename = "validTo")]
98    pub valid_to: crate::protocol::network::TimeSinceEpoch,
99    /// The highest priority network error code, if the certificate has an error.
100    #[serde(
101        rename = "certificateNetworkError",
102        default,
103        skip_serializing_if = "Option::is_none"
104    )]
105    pub certificate_network_error: Option<String>,
106    /// True if the certificate uses a weak signature algorithm.
107    #[serde(rename = "certificateHasWeakSignature")]
108    pub certificate_has_weak_signature: bool,
109    /// True if the certificate has a SHA1 signature in the chain.
110    #[serde(rename = "certificateHasSha1Signature")]
111    pub certificate_has_sha1_signature: bool,
112    /// True if modern SSL
113    #[serde(rename = "modernSSL")]
114    pub modern_ssl: bool,
115    /// True if the connection is using an obsolete SSL protocol.
116    #[serde(rename = "obsoleteSslProtocol")]
117    pub obsolete_ssl_protocol: bool,
118    /// True if the connection is using an obsolete SSL key exchange.
119    #[serde(rename = "obsoleteSslKeyExchange")]
120    pub obsolete_ssl_key_exchange: bool,
121    /// True if the connection is using an obsolete SSL cipher.
122    #[serde(rename = "obsoleteSslCipher")]
123    pub obsolete_ssl_cipher: bool,
124    /// True if the connection is using an obsolete SSL signature.
125    #[serde(rename = "obsoleteSslSignature")]
126    pub obsolete_ssl_signature: bool,
127}
128
129/// Experimental: may change without notice.
130#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
131pub enum SafetyTipStatus {
132    /// `badReputation`
133    #[serde(rename = "badReputation")]
134    BadReputation,
135    /// `lookalike`
136    #[serde(rename = "lookalike")]
137    Lookalike,
138    /// A value this vendored schema does not list. Chrome adds values ahead of
139    /// the published protocol, so an unrecognised one is kept as it arrived
140    /// rather than failing the payload it came in.
141    #[serde(untagged)]
142    Unrecognized(String),
143}
144
145/// Experimental: may change without notice.
146#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
147pub struct SafetyTipInfo {
148    /// Describes whether the page triggers any safety tips or reputation
149    /// warnings. Default is unknown.
150    #[serde(rename = "safetyTipStatus")]
151    pub safety_tip_status: SafetyTipStatus,
152    /// The URL the safety tip suggested ("Did you mean?"). Only filled in for
153    /// lookalike matches.
154    #[serde(rename = "safeUrl", default, skip_serializing_if = "Option::is_none")]
155    pub safe_url: Option<String>,
156}
157
158/// Security state information about the page.
159///
160/// Experimental: may change without notice.
161#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
162pub struct VisibleSecurityState {
163    /// The security level of the page.
164    #[serde(rename = "securityState")]
165    pub security_state: SecurityState,
166    /// Security state details about the page certificate.
167    #[serde(
168        rename = "certificateSecurityState",
169        default,
170        skip_serializing_if = "Option::is_none"
171    )]
172    pub certificate_security_state: Option<CertificateSecurityState>,
173    /// The type of Safety Tip triggered on the page. Note that this field will be
174    /// set even if the Safety Tip UI was not actually shown.
175    #[serde(
176        rename = "safetyTipInfo",
177        default,
178        skip_serializing_if = "Option::is_none"
179    )]
180    pub safety_tip_info: Option<SafetyTipInfo>,
181    /// Array of security state issues ids.
182    #[serde(rename = "securityStateIssueIds")]
183    pub security_state_issue_ids: Vec<String>,
184}
185
186/// An explanation of an factor contributing to the security state.
187#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
188pub struct SecurityStateExplanation {
189    /// Security state representing the severity of the factor being explained.
190    #[serde(rename = "securityState")]
191    pub security_state: SecurityState,
192    /// Title describing the type of factor.
193    pub title: String,
194    /// Short phrase describing the type of factor.
195    pub summary: String,
196    /// Full text explanation of the factor.
197    pub description: String,
198    /// The type of mixed content described by the explanation.
199    #[serde(rename = "mixedContentType")]
200    pub mixed_content_type: MixedContentType,
201    /// Page certificate.
202    pub certificate: Vec<String>,
203    /// Recommendations to fix any issues.
204    #[serde(default, skip_serializing_if = "Option::is_none")]
205    pub recommendations: Option<Vec<String>>,
206}
207
208/// Information about insecure content on the page.
209///
210/// Deprecated in the protocol.
211#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
212pub struct InsecureContentStatus {
213    /// Always false.
214    #[serde(rename = "ranMixedContent")]
215    pub ran_mixed_content: bool,
216    /// Always false.
217    #[serde(rename = "displayedMixedContent")]
218    pub displayed_mixed_content: bool,
219    /// Always false.
220    #[serde(rename = "containedMixedForm")]
221    pub contained_mixed_form: bool,
222    /// Always false.
223    #[serde(rename = "ranContentWithCertErrors")]
224    pub ran_content_with_cert_errors: bool,
225    /// Always false.
226    #[serde(rename = "displayedContentWithCertErrors")]
227    pub displayed_content_with_cert_errors: bool,
228    /// Always set to unknown.
229    #[serde(rename = "ranInsecureContentStyle")]
230    pub ran_insecure_content_style: SecurityState,
231    /// Always set to unknown.
232    #[serde(rename = "displayedInsecureContentStyle")]
233    pub displayed_insecure_content_style: SecurityState,
234}
235
236/// The action to take when a certificate error occurs. continue will continue
237/// processing the request and cancel will cancel the request.
238#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
239pub enum CertificateErrorAction {
240    /// `continue`
241    #[serde(rename = "continue")]
242    Continue,
243    /// `cancel`
244    #[serde(rename = "cancel")]
245    Cancel,
246    /// A value this vendored schema does not list. Chrome adds values ahead of
247    /// the published protocol, so an unrecognised one is kept as it arrived
248    /// rather than failing the payload it came in.
249    #[serde(untagged)]
250    Unrecognized(String),
251}
252
253/// Disables tracking security state changes.
254///
255/// Parameters of `Security.disable`.
256#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
257pub struct DisableParams {}
258
259impl crate::typed::Command for DisableParams {
260    const METHOD: &'static str = "Security.disable";
261    type Returns = crate::typed::NoReturns;
262}
263
264/// Enables tracking security state changes.
265///
266/// Parameters of `Security.enable`.
267#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
268pub struct EnableParams {}
269
270impl crate::typed::Command for EnableParams {
271    const METHOD: &'static str = "Security.enable";
272    type Returns = crate::typed::NoReturns;
273}
274
275/// Enable/disable whether all certificate errors should be ignored.
276///
277/// Parameters of `Security.setIgnoreCertificateErrors`.
278#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
279pub struct SetIgnoreCertificateErrorsParams {
280    /// If true, all certificate errors will be ignored.
281    pub ignore: bool,
282}
283
284impl crate::typed::Command for SetIgnoreCertificateErrorsParams {
285    const METHOD: &'static str = "Security.setIgnoreCertificateErrors";
286    type Returns = crate::typed::NoReturns;
287}
288
289/// Handles a certificate error that fired a certificateError event.
290///
291/// Deprecated in the protocol.
292///
293/// Parameters of `Security.handleCertificateError`.
294#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
295pub struct HandleCertificateErrorParams {
296    /// The ID of the event.
297    #[serde(rename = "eventId")]
298    pub event_id: i64,
299    /// The action to take on the certificate error.
300    pub action: CertificateErrorAction,
301}
302
303impl crate::typed::Command for HandleCertificateErrorParams {
304    const METHOD: &'static str = "Security.handleCertificateError";
305    type Returns = crate::typed::NoReturns;
306}
307
308/// Enable/disable overriding certificate errors. If enabled, all certificate
309/// error events need to be handled by the DevTools client and should be
310/// answered with `handleCertificateError` commands.
311///
312/// Deprecated in the protocol.
313///
314/// Parameters of `Security.setOverrideCertificateErrors`.
315#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
316pub struct SetOverrideCertificateErrorsParams {
317    /// If true, certificate errors will be overridden.
318    pub r#override: bool,
319}
320
321impl crate::typed::Command for SetOverrideCertificateErrorsParams {
322    const METHOD: &'static str = "Security.setOverrideCertificateErrors";
323    type Returns = crate::typed::NoReturns;
324}
325
326/// There is a certificate error. If overriding certificate errors is enabled,
327/// then it should be handled with the `handleCertificateError` command. Note:
328/// this event does not fire if the certificate error has been allowed
329/// internally. Only one client per target should override certificate errors
330/// at the same time.
331///
332/// Deprecated in the protocol.
333///
334/// Payload of the `Security.certificateError` event.
335#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
336pub struct CertificateErrorEvent {
337    /// The ID of the event.
338    #[serde(rename = "eventId")]
339    pub event_id: i64,
340    /// The type of the error.
341    #[serde(rename = "errorType")]
342    pub error_type: String,
343    /// The url that was requested.
344    #[serde(rename = "requestURL")]
345    pub request_url: String,
346}
347
348impl crate::typed::Event for CertificateErrorEvent {
349    const METHOD: &'static str = "Security.certificateError";
350}
351
352/// The security state of the page changed.
353///
354/// Experimental: may change without notice.
355///
356/// Payload of the `Security.visibleSecurityStateChanged` event.
357#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
358pub struct VisibleSecurityStateChangedEvent {
359    /// Security state information about the page.
360    #[serde(rename = "visibleSecurityState")]
361    pub visible_security_state: VisibleSecurityState,
362}
363
364impl crate::typed::Event for VisibleSecurityStateChangedEvent {
365    const METHOD: &'static str = "Security.visibleSecurityStateChanged";
366}
367
368/// The security state of the page changed. No longer being sent.
369///
370/// Deprecated in the protocol.
371///
372/// Payload of the `Security.securityStateChanged` event.
373#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
374pub struct SecurityStateChangedEvent {
375    /// Security state.
376    #[serde(rename = "securityState")]
377    pub security_state: SecurityState,
378    /// True if the page was loaded over cryptographic transport such as HTTPS.
379    ///
380    /// Deprecated in the protocol.
381    #[serde(rename = "schemeIsCryptographic")]
382    pub scheme_is_cryptographic: bool,
383    /// Previously a list of explanations for the security state. Now always
384    /// empty.
385    ///
386    /// Deprecated in the protocol.
387    pub explanations: Vec<SecurityStateExplanation>,
388    /// Information about insecure content on the page.
389    ///
390    /// Deprecated in the protocol.
391    #[serde(rename = "insecureContentStatus")]
392    pub insecure_content_status: InsecureContentStatus,
393    /// Overrides user-visible description of the state. Always omitted.
394    ///
395    /// Deprecated in the protocol.
396    #[serde(default, skip_serializing_if = "Option::is_none")]
397    pub summary: Option<String>,
398}
399
400impl crate::typed::Event for SecurityStateChangedEvent {
401    const METHOD: &'static str = "Security.securityStateChanged";
402}