Skip to main content

browser_protocol/security/
mod.rs

1use serde::{Serialize, Deserialize};
2use serde_json::Value as JsonValue;
3use std::borrow::Cow;
4
5/// An internal certificate ID value.
6
7pub type CertificateId = i64;
8
9/// A description of mixed content (HTTP resources on HTTPS pages), as defined by
10/// <https://www.w3.org/TR/mixed-content/#categories>
11
12#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
13pub enum MixedContentType {
14    #[default]
15    #[serde(rename = "blockable")]
16    Blockable,
17    #[serde(rename = "optionally-blockable")]
18    OptionallyBlockable,
19    #[serde(rename = "none")]
20    None,
21}
22
23/// The security level of a page or resource.
24
25#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
26pub enum SecurityState {
27    #[default]
28    #[serde(rename = "unknown")]
29    Unknown,
30    #[serde(rename = "neutral")]
31    Neutral,
32    #[serde(rename = "insecure")]
33    Insecure,
34    #[serde(rename = "secure")]
35    Secure,
36    #[serde(rename = "info")]
37    Info,
38    #[serde(rename = "insecure-broken")]
39    InsecureBroken,
40}
41
42/// Details about the security state of the page certificate.
43
44#[derive(Debug, Clone, Serialize, Deserialize, Default)]
45#[serde(rename_all = "camelCase")]
46pub struct CertificateSecurityState<'a> {
47    /// Protocol name (e.g. "TLS 1.2" or "QUIC").
48    protocol: Cow<'a, str>,
49    /// Key Exchange used by the connection, or the empty string if not applicable.
50    #[serde(rename = "keyExchange")]
51    key_exchange: Cow<'a, str>,
52    /// (EC)DH group used by the connection, if applicable.
53    #[serde(skip_serializing_if = "Option::is_none", rename = "keyExchangeGroup")]
54    key_exchange_group: Option<Cow<'a, str>>,
55    /// Cipher name.
56    cipher: Cow<'a, str>,
57    /// TLS MAC. Note that AEAD ciphers do not have separate MACs.
58    #[serde(skip_serializing_if = "Option::is_none")]
59    mac: Option<Cow<'a, str>>,
60    /// Page certificate.
61    certificate: Vec<Cow<'a, str>>,
62    /// Certificate subject name.
63    #[serde(rename = "subjectName")]
64    subject_name: Cow<'a, str>,
65    /// Name of the issuing CA.
66    issuer: Cow<'a, str>,
67    /// Certificate valid from date.
68    #[serde(rename = "validFrom")]
69    valid_from: crate::network::TimeSinceEpoch,
70    /// Certificate valid to (expiration) date
71    #[serde(rename = "validTo")]
72    valid_to: crate::network::TimeSinceEpoch,
73    /// The highest priority network error code, if the certificate has an error.
74    #[serde(skip_serializing_if = "Option::is_none", rename = "certificateNetworkError")]
75    certificate_network_error: Option<Cow<'a, str>>,
76    /// True if the certificate uses a weak signature algorithm.
77    #[serde(rename = "certificateHasWeakSignature")]
78    certificate_has_weak_signature: bool,
79    /// True if the certificate has a SHA1 signature in the chain.
80    #[serde(rename = "certificateHasSha1Signature")]
81    certificate_has_sha1_signature: bool,
82    /// True if modern SSL
83    #[serde(rename = "modernSSL")]
84    modern_ssl: bool,
85    /// True if the connection is using an obsolete SSL protocol.
86    #[serde(rename = "obsoleteSslProtocol")]
87    obsolete_ssl_protocol: bool,
88    /// True if the connection is using an obsolete SSL key exchange.
89    #[serde(rename = "obsoleteSslKeyExchange")]
90    obsolete_ssl_key_exchange: bool,
91    /// True if the connection is using an obsolete SSL cipher.
92    #[serde(rename = "obsoleteSslCipher")]
93    obsolete_ssl_cipher: bool,
94    /// True if the connection is using an obsolete SSL signature.
95    #[serde(rename = "obsoleteSslSignature")]
96    obsolete_ssl_signature: bool,
97}
98
99impl<'a> CertificateSecurityState<'a> {
100    /// Creates a builder for this type with the required parameters:
101    /// * `protocol`: Protocol name (e.g. "TLS 1.2" or "QUIC").
102    /// * `key_exchange`: Key Exchange used by the connection, or the empty string if not applicable.
103    /// * `cipher`: Cipher name.
104    /// * `certificate`: Page certificate.
105    /// * `subject_name`: Certificate subject name.
106    /// * `issuer`: Name of the issuing CA.
107    /// * `valid_from`: Certificate valid from date.
108    /// * `valid_to`: Certificate valid to (expiration) date
109    /// * `certificate_has_weak_signature`: True if the certificate uses a weak signature algorithm.
110    /// * `certificate_has_sha1_signature`: True if the certificate has a SHA1 signature in the chain.
111    /// * `modern_ssl`: True if modern SSL
112    /// * `obsolete_ssl_protocol`: True if the connection is using an obsolete SSL protocol.
113    /// * `obsolete_ssl_key_exchange`: True if the connection is using an obsolete SSL key exchange.
114    /// * `obsolete_ssl_cipher`: True if the connection is using an obsolete SSL cipher.
115    /// * `obsolete_ssl_signature`: True if the connection is using an obsolete SSL signature.
116    pub fn builder(protocol: impl Into<Cow<'a, str>>, key_exchange: impl Into<Cow<'a, str>>, cipher: impl Into<Cow<'a, str>>, certificate: Vec<Cow<'a, str>>, subject_name: impl Into<Cow<'a, str>>, issuer: impl Into<Cow<'a, str>>, valid_from: crate::network::TimeSinceEpoch, valid_to: crate::network::TimeSinceEpoch, certificate_has_weak_signature: bool, certificate_has_sha1_signature: bool, modern_ssl: bool, obsolete_ssl_protocol: bool, obsolete_ssl_key_exchange: bool, obsolete_ssl_cipher: bool, obsolete_ssl_signature: bool) -> CertificateSecurityStateBuilder<'a> {
117        CertificateSecurityStateBuilder {
118            protocol: protocol.into(),
119            key_exchange: key_exchange.into(),
120            key_exchange_group: None,
121            cipher: cipher.into(),
122            mac: None,
123            certificate: certificate,
124            subject_name: subject_name.into(),
125            issuer: issuer.into(),
126            valid_from: valid_from,
127            valid_to: valid_to,
128            certificate_network_error: None,
129            certificate_has_weak_signature: certificate_has_weak_signature,
130            certificate_has_sha1_signature: certificate_has_sha1_signature,
131            modern_ssl: modern_ssl,
132            obsolete_ssl_protocol: obsolete_ssl_protocol,
133            obsolete_ssl_key_exchange: obsolete_ssl_key_exchange,
134            obsolete_ssl_cipher: obsolete_ssl_cipher,
135            obsolete_ssl_signature: obsolete_ssl_signature,
136        }
137    }
138    /// Protocol name (e.g. "TLS 1.2" or "QUIC").
139    pub fn protocol(&self) -> &str { self.protocol.as_ref() }
140    /// Key Exchange used by the connection, or the empty string if not applicable.
141    pub fn key_exchange(&self) -> &str { self.key_exchange.as_ref() }
142    /// (EC)DH group used by the connection, if applicable.
143    pub fn key_exchange_group(&self) -> Option<&str> { self.key_exchange_group.as_deref() }
144    /// Cipher name.
145    pub fn cipher(&self) -> &str { self.cipher.as_ref() }
146    /// TLS MAC. Note that AEAD ciphers do not have separate MACs.
147    pub fn mac(&self) -> Option<&str> { self.mac.as_deref() }
148    /// Page certificate.
149    pub fn certificate(&self) -> &[Cow<'a, str>] { &self.certificate }
150    /// Certificate subject name.
151    pub fn subject_name(&self) -> &str { self.subject_name.as_ref() }
152    /// Name of the issuing CA.
153    pub fn issuer(&self) -> &str { self.issuer.as_ref() }
154    /// Certificate valid from date.
155    pub fn valid_from(&self) -> &crate::network::TimeSinceEpoch { &self.valid_from }
156    /// Certificate valid to (expiration) date
157    pub fn valid_to(&self) -> &crate::network::TimeSinceEpoch { &self.valid_to }
158    /// The highest priority network error code, if the certificate has an error.
159    pub fn certificate_network_error(&self) -> Option<&str> { self.certificate_network_error.as_deref() }
160    /// True if the certificate uses a weak signature algorithm.
161    pub fn certificate_has_weak_signature(&self) -> bool { self.certificate_has_weak_signature }
162    /// True if the certificate has a SHA1 signature in the chain.
163    pub fn certificate_has_sha1_signature(&self) -> bool { self.certificate_has_sha1_signature }
164    /// True if modern SSL
165    pub fn modern_ssl(&self) -> bool { self.modern_ssl }
166    /// True if the connection is using an obsolete SSL protocol.
167    pub fn obsolete_ssl_protocol(&self) -> bool { self.obsolete_ssl_protocol }
168    /// True if the connection is using an obsolete SSL key exchange.
169    pub fn obsolete_ssl_key_exchange(&self) -> bool { self.obsolete_ssl_key_exchange }
170    /// True if the connection is using an obsolete SSL cipher.
171    pub fn obsolete_ssl_cipher(&self) -> bool { self.obsolete_ssl_cipher }
172    /// True if the connection is using an obsolete SSL signature.
173    pub fn obsolete_ssl_signature(&self) -> bool { self.obsolete_ssl_signature }
174}
175
176
177pub struct CertificateSecurityStateBuilder<'a> {
178    protocol: Cow<'a, str>,
179    key_exchange: Cow<'a, str>,
180    key_exchange_group: Option<Cow<'a, str>>,
181    cipher: Cow<'a, str>,
182    mac: Option<Cow<'a, str>>,
183    certificate: Vec<Cow<'a, str>>,
184    subject_name: Cow<'a, str>,
185    issuer: Cow<'a, str>,
186    valid_from: crate::network::TimeSinceEpoch,
187    valid_to: crate::network::TimeSinceEpoch,
188    certificate_network_error: Option<Cow<'a, str>>,
189    certificate_has_weak_signature: bool,
190    certificate_has_sha1_signature: bool,
191    modern_ssl: bool,
192    obsolete_ssl_protocol: bool,
193    obsolete_ssl_key_exchange: bool,
194    obsolete_ssl_cipher: bool,
195    obsolete_ssl_signature: bool,
196}
197
198impl<'a> CertificateSecurityStateBuilder<'a> {
199    /// (EC)DH group used by the connection, if applicable.
200    pub fn key_exchange_group(mut self, key_exchange_group: impl Into<Cow<'a, str>>) -> Self { self.key_exchange_group = Some(key_exchange_group.into()); self }
201    /// TLS MAC. Note that AEAD ciphers do not have separate MACs.
202    pub fn mac(mut self, mac: impl Into<Cow<'a, str>>) -> Self { self.mac = Some(mac.into()); self }
203    /// The highest priority network error code, if the certificate has an error.
204    pub fn certificate_network_error(mut self, certificate_network_error: impl Into<Cow<'a, str>>) -> Self { self.certificate_network_error = Some(certificate_network_error.into()); self }
205    pub fn build(self) -> CertificateSecurityState<'a> {
206        CertificateSecurityState {
207            protocol: self.protocol,
208            key_exchange: self.key_exchange,
209            key_exchange_group: self.key_exchange_group,
210            cipher: self.cipher,
211            mac: self.mac,
212            certificate: self.certificate,
213            subject_name: self.subject_name,
214            issuer: self.issuer,
215            valid_from: self.valid_from,
216            valid_to: self.valid_to,
217            certificate_network_error: self.certificate_network_error,
218            certificate_has_weak_signature: self.certificate_has_weak_signature,
219            certificate_has_sha1_signature: self.certificate_has_sha1_signature,
220            modern_ssl: self.modern_ssl,
221            obsolete_ssl_protocol: self.obsolete_ssl_protocol,
222            obsolete_ssl_key_exchange: self.obsolete_ssl_key_exchange,
223            obsolete_ssl_cipher: self.obsolete_ssl_cipher,
224            obsolete_ssl_signature: self.obsolete_ssl_signature,
225        }
226    }
227}
228
229
230#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
231pub enum SafetyTipStatus {
232    #[default]
233    #[serde(rename = "badReputation")]
234    BadReputation,
235    #[serde(rename = "lookalike")]
236    Lookalike,
237}
238
239
240#[derive(Debug, Clone, Serialize, Deserialize, Default)]
241#[serde(rename_all = "camelCase")]
242pub struct SafetyTipInfo<'a> {
243    /// Describes whether the page triggers any safety tips or reputation warnings. Default is unknown.
244    #[serde(rename = "safetyTipStatus")]
245    safety_tip_status: SafetyTipStatus,
246    /// The URL the safety tip suggested ("Did you mean?"). Only filled in for lookalike matches.
247    #[serde(skip_serializing_if = "Option::is_none", rename = "safeUrl")]
248    safe_url: Option<Cow<'a, str>>,
249}
250
251impl<'a> SafetyTipInfo<'a> {
252    /// Creates a builder for this type with the required parameters:
253    /// * `safety_tip_status`: Describes whether the page triggers any safety tips or reputation warnings. Default is unknown.
254    pub fn builder(safety_tip_status: impl Into<SafetyTipStatus>) -> SafetyTipInfoBuilder<'a> {
255        SafetyTipInfoBuilder {
256            safety_tip_status: safety_tip_status.into(),
257            safe_url: None,
258        }
259    }
260    /// Describes whether the page triggers any safety tips or reputation warnings. Default is unknown.
261    pub fn safety_tip_status(&self) -> &SafetyTipStatus { &self.safety_tip_status }
262    /// The URL the safety tip suggested ("Did you mean?"). Only filled in for lookalike matches.
263    pub fn safe_url(&self) -> Option<&str> { self.safe_url.as_deref() }
264}
265
266
267pub struct SafetyTipInfoBuilder<'a> {
268    safety_tip_status: SafetyTipStatus,
269    safe_url: Option<Cow<'a, str>>,
270}
271
272impl<'a> SafetyTipInfoBuilder<'a> {
273    /// The URL the safety tip suggested ("Did you mean?"). Only filled in for lookalike matches.
274    pub fn safe_url(mut self, safe_url: impl Into<Cow<'a, str>>) -> Self { self.safe_url = Some(safe_url.into()); self }
275    pub fn build(self) -> SafetyTipInfo<'a> {
276        SafetyTipInfo {
277            safety_tip_status: self.safety_tip_status,
278            safe_url: self.safe_url,
279        }
280    }
281}
282
283/// Security state information about the page.
284
285#[derive(Debug, Clone, Serialize, Deserialize, Default)]
286#[serde(rename_all = "camelCase")]
287pub struct VisibleSecurityState<'a> {
288    /// The security level of the page.
289    #[serde(rename = "securityState")]
290    security_state: SecurityState,
291    /// Security state details about the page certificate.
292    #[serde(skip_serializing_if = "Option::is_none", rename = "certificateSecurityState")]
293    certificate_security_state: Option<CertificateSecurityState<'a>>,
294    /// The type of Safety Tip triggered on the page. Note that this field will be set even if the Safety Tip UI was not actually shown.
295    #[serde(skip_serializing_if = "Option::is_none", rename = "safetyTipInfo")]
296    safety_tip_info: Option<SafetyTipInfo<'a>>,
297    /// Array of security state issues ids.
298    #[serde(rename = "securityStateIssueIds")]
299    security_state_issue_ids: Vec<Cow<'a, str>>,
300}
301
302impl<'a> VisibleSecurityState<'a> {
303    /// Creates a builder for this type with the required parameters:
304    /// * `security_state`: The security level of the page.
305    /// * `security_state_issue_ids`: Array of security state issues ids.
306    pub fn builder(security_state: impl Into<SecurityState>, security_state_issue_ids: Vec<Cow<'a, str>>) -> VisibleSecurityStateBuilder<'a> {
307        VisibleSecurityStateBuilder {
308            security_state: security_state.into(),
309            certificate_security_state: None,
310            safety_tip_info: None,
311            security_state_issue_ids: security_state_issue_ids,
312        }
313    }
314    /// The security level of the page.
315    pub fn security_state(&self) -> &SecurityState { &self.security_state }
316    /// Security state details about the page certificate.
317    pub fn certificate_security_state(&self) -> Option<&CertificateSecurityState<'a>> { self.certificate_security_state.as_ref() }
318    /// The type of Safety Tip triggered on the page. Note that this field will be set even if the Safety Tip UI was not actually shown.
319    pub fn safety_tip_info(&self) -> Option<&SafetyTipInfo<'a>> { self.safety_tip_info.as_ref() }
320    /// Array of security state issues ids.
321    pub fn security_state_issue_ids(&self) -> &[Cow<'a, str>] { &self.security_state_issue_ids }
322}
323
324
325pub struct VisibleSecurityStateBuilder<'a> {
326    security_state: SecurityState,
327    certificate_security_state: Option<CertificateSecurityState<'a>>,
328    safety_tip_info: Option<SafetyTipInfo<'a>>,
329    security_state_issue_ids: Vec<Cow<'a, str>>,
330}
331
332impl<'a> VisibleSecurityStateBuilder<'a> {
333    /// Security state details about the page certificate.
334    pub fn certificate_security_state(mut self, certificate_security_state: CertificateSecurityState<'a>) -> Self { self.certificate_security_state = Some(certificate_security_state); self }
335    /// The type of Safety Tip triggered on the page. Note that this field will be set even if the Safety Tip UI was not actually shown.
336    pub fn safety_tip_info(mut self, safety_tip_info: SafetyTipInfo<'a>) -> Self { self.safety_tip_info = Some(safety_tip_info); self }
337    pub fn build(self) -> VisibleSecurityState<'a> {
338        VisibleSecurityState {
339            security_state: self.security_state,
340            certificate_security_state: self.certificate_security_state,
341            safety_tip_info: self.safety_tip_info,
342            security_state_issue_ids: self.security_state_issue_ids,
343        }
344    }
345}
346
347/// An explanation of an factor contributing to the security state.
348
349#[derive(Debug, Clone, Serialize, Deserialize, Default)]
350#[serde(rename_all = "camelCase")]
351pub struct SecurityStateExplanation<'a> {
352    /// Security state representing the severity of the factor being explained.
353    #[serde(rename = "securityState")]
354    security_state: SecurityState,
355    /// Title describing the type of factor.
356    title: Cow<'a, str>,
357    /// Short phrase describing the type of factor.
358    summary: Cow<'a, str>,
359    /// Full text explanation of the factor.
360    description: Cow<'a, str>,
361    /// The type of mixed content described by the explanation.
362    #[serde(rename = "mixedContentType")]
363    mixed_content_type: MixedContentType,
364    /// Page certificate.
365    certificate: Vec<Cow<'a, str>>,
366    /// Recommendations to fix any issues.
367    #[serde(skip_serializing_if = "Option::is_none")]
368    recommendations: Option<Vec<Cow<'a, str>>>,
369}
370
371impl<'a> SecurityStateExplanation<'a> {
372    /// Creates a builder for this type with the required parameters:
373    /// * `security_state`: Security state representing the severity of the factor being explained.
374    /// * `title`: Title describing the type of factor.
375    /// * `summary`: Short phrase describing the type of factor.
376    /// * `description`: Full text explanation of the factor.
377    /// * `mixed_content_type`: The type of mixed content described by the explanation.
378    /// * `certificate`: Page certificate.
379    pub fn builder(security_state: impl Into<SecurityState>, title: impl Into<Cow<'a, str>>, summary: impl Into<Cow<'a, str>>, description: impl Into<Cow<'a, str>>, mixed_content_type: impl Into<MixedContentType>, certificate: Vec<Cow<'a, str>>) -> SecurityStateExplanationBuilder<'a> {
380        SecurityStateExplanationBuilder {
381            security_state: security_state.into(),
382            title: title.into(),
383            summary: summary.into(),
384            description: description.into(),
385            mixed_content_type: mixed_content_type.into(),
386            certificate: certificate,
387            recommendations: None,
388        }
389    }
390    /// Security state representing the severity of the factor being explained.
391    pub fn security_state(&self) -> &SecurityState { &self.security_state }
392    /// Title describing the type of factor.
393    pub fn title(&self) -> &str { self.title.as_ref() }
394    /// Short phrase describing the type of factor.
395    pub fn summary(&self) -> &str { self.summary.as_ref() }
396    /// Full text explanation of the factor.
397    pub fn description(&self) -> &str { self.description.as_ref() }
398    /// The type of mixed content described by the explanation.
399    pub fn mixed_content_type(&self) -> &MixedContentType { &self.mixed_content_type }
400    /// Page certificate.
401    pub fn certificate(&self) -> &[Cow<'a, str>] { &self.certificate }
402    /// Recommendations to fix any issues.
403    pub fn recommendations(&self) -> Option<&[Cow<'a, str>]> { self.recommendations.as_deref() }
404}
405
406
407pub struct SecurityStateExplanationBuilder<'a> {
408    security_state: SecurityState,
409    title: Cow<'a, str>,
410    summary: Cow<'a, str>,
411    description: Cow<'a, str>,
412    mixed_content_type: MixedContentType,
413    certificate: Vec<Cow<'a, str>>,
414    recommendations: Option<Vec<Cow<'a, str>>>,
415}
416
417impl<'a> SecurityStateExplanationBuilder<'a> {
418    /// Recommendations to fix any issues.
419    pub fn recommendations(mut self, recommendations: Vec<Cow<'a, str>>) -> Self { self.recommendations = Some(recommendations); self }
420    pub fn build(self) -> SecurityStateExplanation<'a> {
421        SecurityStateExplanation {
422            security_state: self.security_state,
423            title: self.title,
424            summary: self.summary,
425            description: self.description,
426            mixed_content_type: self.mixed_content_type,
427            certificate: self.certificate,
428            recommendations: self.recommendations,
429        }
430    }
431}
432
433/// Information about insecure content on the page.
434
435#[derive(Debug, Clone, Serialize, Deserialize, Default)]
436#[serde(rename_all = "camelCase")]
437pub struct InsecureContentStatus {
438    /// Always false.
439    #[serde(rename = "ranMixedContent")]
440    ran_mixed_content: bool,
441    /// Always false.
442    #[serde(rename = "displayedMixedContent")]
443    displayed_mixed_content: bool,
444    /// Always false.
445    #[serde(rename = "containedMixedForm")]
446    contained_mixed_form: bool,
447    /// Always false.
448    #[serde(rename = "ranContentWithCertErrors")]
449    ran_content_with_cert_errors: bool,
450    /// Always false.
451    #[serde(rename = "displayedContentWithCertErrors")]
452    displayed_content_with_cert_errors: bool,
453    /// Always set to unknown.
454    #[serde(rename = "ranInsecureContentStyle")]
455    ran_insecure_content_style: SecurityState,
456    /// Always set to unknown.
457    #[serde(rename = "displayedInsecureContentStyle")]
458    displayed_insecure_content_style: SecurityState,
459}
460
461impl InsecureContentStatus {
462    /// Creates a builder for this type with the required parameters:
463    /// * `ran_mixed_content`: Always false.
464    /// * `displayed_mixed_content`: Always false.
465    /// * `contained_mixed_form`: Always false.
466    /// * `ran_content_with_cert_errors`: Always false.
467    /// * `displayed_content_with_cert_errors`: Always false.
468    /// * `ran_insecure_content_style`: Always set to unknown.
469    /// * `displayed_insecure_content_style`: Always set to unknown.
470    pub fn builder(ran_mixed_content: bool, displayed_mixed_content: bool, contained_mixed_form: bool, ran_content_with_cert_errors: bool, displayed_content_with_cert_errors: bool, ran_insecure_content_style: impl Into<SecurityState>, displayed_insecure_content_style: impl Into<SecurityState>) -> InsecureContentStatusBuilder {
471        InsecureContentStatusBuilder {
472            ran_mixed_content: ran_mixed_content,
473            displayed_mixed_content: displayed_mixed_content,
474            contained_mixed_form: contained_mixed_form,
475            ran_content_with_cert_errors: ran_content_with_cert_errors,
476            displayed_content_with_cert_errors: displayed_content_with_cert_errors,
477            ran_insecure_content_style: ran_insecure_content_style.into(),
478            displayed_insecure_content_style: displayed_insecure_content_style.into(),
479        }
480    }
481    /// Always false.
482    pub fn ran_mixed_content(&self) -> bool { self.ran_mixed_content }
483    /// Always false.
484    pub fn displayed_mixed_content(&self) -> bool { self.displayed_mixed_content }
485    /// Always false.
486    pub fn contained_mixed_form(&self) -> bool { self.contained_mixed_form }
487    /// Always false.
488    pub fn ran_content_with_cert_errors(&self) -> bool { self.ran_content_with_cert_errors }
489    /// Always false.
490    pub fn displayed_content_with_cert_errors(&self) -> bool { self.displayed_content_with_cert_errors }
491    /// Always set to unknown.
492    pub fn ran_insecure_content_style(&self) -> &SecurityState { &self.ran_insecure_content_style }
493    /// Always set to unknown.
494    pub fn displayed_insecure_content_style(&self) -> &SecurityState { &self.displayed_insecure_content_style }
495}
496
497
498pub struct InsecureContentStatusBuilder {
499    ran_mixed_content: bool,
500    displayed_mixed_content: bool,
501    contained_mixed_form: bool,
502    ran_content_with_cert_errors: bool,
503    displayed_content_with_cert_errors: bool,
504    ran_insecure_content_style: SecurityState,
505    displayed_insecure_content_style: SecurityState,
506}
507
508impl InsecureContentStatusBuilder {
509    pub fn build(self) -> InsecureContentStatus {
510        InsecureContentStatus {
511            ran_mixed_content: self.ran_mixed_content,
512            displayed_mixed_content: self.displayed_mixed_content,
513            contained_mixed_form: self.contained_mixed_form,
514            ran_content_with_cert_errors: self.ran_content_with_cert_errors,
515            displayed_content_with_cert_errors: self.displayed_content_with_cert_errors,
516            ran_insecure_content_style: self.ran_insecure_content_style,
517            displayed_insecure_content_style: self.displayed_insecure_content_style,
518        }
519    }
520}
521
522/// The action to take when a certificate error occurs. continue will continue processing the
523/// request and cancel will cancel the request.
524
525#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
526pub enum CertificateErrorAction {
527    #[default]
528    #[serde(rename = "continue")]
529    Continue,
530    #[serde(rename = "cancel")]
531    Cancel,
532}
533
534#[derive(Debug, Clone, Serialize, Deserialize, Default)]
535pub struct DisableParams {}
536
537impl DisableParams { pub const METHOD: &'static str = "Security.disable"; }
538
539impl<'a> crate::CdpCommand<'a> for DisableParams {
540    const METHOD: &'static str = "Security.disable";
541    type Response = crate::EmptyReturns;
542}
543
544#[derive(Debug, Clone, Serialize, Deserialize, Default)]
545pub struct EnableParams {}
546
547impl EnableParams { pub const METHOD: &'static str = "Security.enable"; }
548
549impl<'a> crate::CdpCommand<'a> for EnableParams {
550    const METHOD: &'static str = "Security.enable";
551    type Response = crate::EmptyReturns;
552}
553
554/// Enable/disable whether all certificate errors should be ignored.
555
556#[derive(Debug, Clone, Serialize, Deserialize, Default)]
557#[serde(rename_all = "camelCase")]
558pub struct SetIgnoreCertificateErrorsParams {
559    /// If true, all certificate errors will be ignored.
560    ignore: bool,
561}
562
563impl SetIgnoreCertificateErrorsParams {
564    /// Creates a builder for this type with the required parameters:
565    /// * `ignore`: If true, all certificate errors will be ignored.
566    pub fn builder(ignore: bool) -> SetIgnoreCertificateErrorsParamsBuilder {
567        SetIgnoreCertificateErrorsParamsBuilder {
568            ignore: ignore,
569        }
570    }
571    /// If true, all certificate errors will be ignored.
572    pub fn ignore(&self) -> bool { self.ignore }
573}
574
575
576pub struct SetIgnoreCertificateErrorsParamsBuilder {
577    ignore: bool,
578}
579
580impl SetIgnoreCertificateErrorsParamsBuilder {
581    pub fn build(self) -> SetIgnoreCertificateErrorsParams {
582        SetIgnoreCertificateErrorsParams {
583            ignore: self.ignore,
584        }
585    }
586}
587
588impl SetIgnoreCertificateErrorsParams { pub const METHOD: &'static str = "Security.setIgnoreCertificateErrors"; }
589
590impl<'a> crate::CdpCommand<'a> for SetIgnoreCertificateErrorsParams {
591    const METHOD: &'static str = "Security.setIgnoreCertificateErrors";
592    type Response = crate::EmptyReturns;
593}
594
595/// Handles a certificate error that fired a certificateError event.
596
597#[derive(Debug, Clone, Serialize, Deserialize, Default)]
598#[serde(rename_all = "camelCase")]
599pub struct HandleCertificateErrorParams {
600    /// The ID of the event.
601    #[serde(rename = "eventId")]
602    event_id: u64,
603    /// The action to take on the certificate error.
604    action: CertificateErrorAction,
605}
606
607impl HandleCertificateErrorParams {
608    /// Creates a builder for this type with the required parameters:
609    /// * `event_id`: The ID of the event.
610    /// * `action`: The action to take on the certificate error.
611    pub fn builder(event_id: u64, action: impl Into<CertificateErrorAction>) -> HandleCertificateErrorParamsBuilder {
612        HandleCertificateErrorParamsBuilder {
613            event_id: event_id,
614            action: action.into(),
615        }
616    }
617    /// The ID of the event.
618    pub fn event_id(&self) -> u64 { self.event_id }
619    /// The action to take on the certificate error.
620    pub fn action(&self) -> &CertificateErrorAction { &self.action }
621}
622
623
624pub struct HandleCertificateErrorParamsBuilder {
625    event_id: u64,
626    action: CertificateErrorAction,
627}
628
629impl HandleCertificateErrorParamsBuilder {
630    pub fn build(self) -> HandleCertificateErrorParams {
631        HandleCertificateErrorParams {
632            event_id: self.event_id,
633            action: self.action,
634        }
635    }
636}
637
638impl HandleCertificateErrorParams { pub const METHOD: &'static str = "Security.handleCertificateError"; }
639
640impl<'a> crate::CdpCommand<'a> for HandleCertificateErrorParams {
641    const METHOD: &'static str = "Security.handleCertificateError";
642    type Response = crate::EmptyReturns;
643}
644
645/// Enable/disable overriding certificate errors. If enabled, all certificate error events need to
646/// be handled by the DevTools client and should be answered with 'handleCertificateError' commands.
647
648#[derive(Debug, Clone, Serialize, Deserialize, Default)]
649#[serde(rename_all = "camelCase")]
650pub struct SetOverrideCertificateErrorsParams {
651    /// If true, certificate errors will be overridden.
652    #[serde(rename = "override")]
653    override_: bool,
654}
655
656impl SetOverrideCertificateErrorsParams {
657    /// Creates a builder for this type with the required parameters:
658    /// * `override_`: If true, certificate errors will be overridden.
659    pub fn builder(override_: bool) -> SetOverrideCertificateErrorsParamsBuilder {
660        SetOverrideCertificateErrorsParamsBuilder {
661            override_: override_,
662        }
663    }
664    /// If true, certificate errors will be overridden.
665    pub fn override_(&self) -> bool { self.override_ }
666}
667
668
669pub struct SetOverrideCertificateErrorsParamsBuilder {
670    override_: bool,
671}
672
673impl SetOverrideCertificateErrorsParamsBuilder {
674    pub fn build(self) -> SetOverrideCertificateErrorsParams {
675        SetOverrideCertificateErrorsParams {
676            override_: self.override_,
677        }
678    }
679}
680
681impl SetOverrideCertificateErrorsParams { pub const METHOD: &'static str = "Security.setOverrideCertificateErrors"; }
682
683impl<'a> crate::CdpCommand<'a> for SetOverrideCertificateErrorsParams {
684    const METHOD: &'static str = "Security.setOverrideCertificateErrors";
685    type Response = crate::EmptyReturns;
686}