1use serde::{Serialize, Deserialize};
2use serde_json::Value as JsonValue;
3use std::borrow::Cow;
4
5pub type CertificateId = i64;
8
9#[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#[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#[derive(Debug, Clone, Serialize, Deserialize, Default)]
45#[serde(rename_all = "camelCase")]
46pub struct CertificateSecurityState<'a> {
47 protocol: Cow<'a, str>,
49 keyExchange: Cow<'a, str>,
51 #[serde(skip_serializing_if = "Option::is_none")]
53 keyExchangeGroup: Option<Cow<'a, str>>,
54 cipher: Cow<'a, str>,
56 #[serde(skip_serializing_if = "Option::is_none")]
58 mac: Option<Cow<'a, str>>,
59 certificate: Vec<Cow<'a, str>>,
61 subjectName: Cow<'a, str>,
63 issuer: Cow<'a, str>,
65 validFrom: crate::network::TimeSinceEpoch,
67 validTo: crate::network::TimeSinceEpoch,
69 #[serde(skip_serializing_if = "Option::is_none")]
71 certificateNetworkError: Option<Cow<'a, str>>,
72 certificateHasWeakSignature: bool,
74 certificateHasSha1Signature: bool,
76 modernSSL: bool,
78 obsoleteSslProtocol: bool,
80 obsoleteSslKeyExchange: bool,
82 obsoleteSslCipher: bool,
84 obsoleteSslSignature: bool,
86}
87
88impl<'a> CertificateSecurityState<'a> {
89 pub fn builder(protocol: impl Into<Cow<'a, str>>, keyExchange: impl Into<Cow<'a, str>>, cipher: impl Into<Cow<'a, str>>, certificate: Vec<Cow<'a, str>>, subjectName: impl Into<Cow<'a, str>>, issuer: impl Into<Cow<'a, str>>, validFrom: crate::network::TimeSinceEpoch, validTo: crate::network::TimeSinceEpoch, certificateHasWeakSignature: bool, certificateHasSha1Signature: bool, modernSSL: bool, obsoleteSslProtocol: bool, obsoleteSslKeyExchange: bool, obsoleteSslCipher: bool, obsoleteSslSignature: bool) -> CertificateSecurityStateBuilder<'a> {
90 CertificateSecurityStateBuilder {
91 protocol: protocol.into(),
92 keyExchange: keyExchange.into(),
93 keyExchangeGroup: None,
94 cipher: cipher.into(),
95 mac: None,
96 certificate: certificate,
97 subjectName: subjectName.into(),
98 issuer: issuer.into(),
99 validFrom: validFrom,
100 validTo: validTo,
101 certificateNetworkError: None,
102 certificateHasWeakSignature: certificateHasWeakSignature,
103 certificateHasSha1Signature: certificateHasSha1Signature,
104 modernSSL: modernSSL,
105 obsoleteSslProtocol: obsoleteSslProtocol,
106 obsoleteSslKeyExchange: obsoleteSslKeyExchange,
107 obsoleteSslCipher: obsoleteSslCipher,
108 obsoleteSslSignature: obsoleteSslSignature,
109 }
110 }
111 pub fn protocol(&self) -> &str { self.protocol.as_ref() }
112 pub fn keyExchange(&self) -> &str { self.keyExchange.as_ref() }
113 pub fn keyExchangeGroup(&self) -> Option<&str> { self.keyExchangeGroup.as_deref() }
114 pub fn cipher(&self) -> &str { self.cipher.as_ref() }
115 pub fn mac(&self) -> Option<&str> { self.mac.as_deref() }
116 pub fn certificate(&self) -> &[Cow<'a, str>] { &self.certificate }
117 pub fn subjectName(&self) -> &str { self.subjectName.as_ref() }
118 pub fn issuer(&self) -> &str { self.issuer.as_ref() }
119 pub fn validFrom(&self) -> &crate::network::TimeSinceEpoch { &self.validFrom }
120 pub fn validTo(&self) -> &crate::network::TimeSinceEpoch { &self.validTo }
121 pub fn certificateNetworkError(&self) -> Option<&str> { self.certificateNetworkError.as_deref() }
122 pub fn certificateHasWeakSignature(&self) -> bool { self.certificateHasWeakSignature }
123 pub fn certificateHasSha1Signature(&self) -> bool { self.certificateHasSha1Signature }
124 pub fn modernSSL(&self) -> bool { self.modernSSL }
125 pub fn obsoleteSslProtocol(&self) -> bool { self.obsoleteSslProtocol }
126 pub fn obsoleteSslKeyExchange(&self) -> bool { self.obsoleteSslKeyExchange }
127 pub fn obsoleteSslCipher(&self) -> bool { self.obsoleteSslCipher }
128 pub fn obsoleteSslSignature(&self) -> bool { self.obsoleteSslSignature }
129}
130
131
132pub struct CertificateSecurityStateBuilder<'a> {
133 protocol: Cow<'a, str>,
134 keyExchange: Cow<'a, str>,
135 keyExchangeGroup: Option<Cow<'a, str>>,
136 cipher: Cow<'a, str>,
137 mac: Option<Cow<'a, str>>,
138 certificate: Vec<Cow<'a, str>>,
139 subjectName: Cow<'a, str>,
140 issuer: Cow<'a, str>,
141 validFrom: crate::network::TimeSinceEpoch,
142 validTo: crate::network::TimeSinceEpoch,
143 certificateNetworkError: Option<Cow<'a, str>>,
144 certificateHasWeakSignature: bool,
145 certificateHasSha1Signature: bool,
146 modernSSL: bool,
147 obsoleteSslProtocol: bool,
148 obsoleteSslKeyExchange: bool,
149 obsoleteSslCipher: bool,
150 obsoleteSslSignature: bool,
151}
152
153impl<'a> CertificateSecurityStateBuilder<'a> {
154 pub fn keyExchangeGroup(mut self, keyExchangeGroup: impl Into<Cow<'a, str>>) -> Self { self.keyExchangeGroup = Some(keyExchangeGroup.into()); self }
156 pub fn mac(mut self, mac: impl Into<Cow<'a, str>>) -> Self { self.mac = Some(mac.into()); self }
158 pub fn certificateNetworkError(mut self, certificateNetworkError: impl Into<Cow<'a, str>>) -> Self { self.certificateNetworkError = Some(certificateNetworkError.into()); self }
160 pub fn build(self) -> CertificateSecurityState<'a> {
161 CertificateSecurityState {
162 protocol: self.protocol,
163 keyExchange: self.keyExchange,
164 keyExchangeGroup: self.keyExchangeGroup,
165 cipher: self.cipher,
166 mac: self.mac,
167 certificate: self.certificate,
168 subjectName: self.subjectName,
169 issuer: self.issuer,
170 validFrom: self.validFrom,
171 validTo: self.validTo,
172 certificateNetworkError: self.certificateNetworkError,
173 certificateHasWeakSignature: self.certificateHasWeakSignature,
174 certificateHasSha1Signature: self.certificateHasSha1Signature,
175 modernSSL: self.modernSSL,
176 obsoleteSslProtocol: self.obsoleteSslProtocol,
177 obsoleteSslKeyExchange: self.obsoleteSslKeyExchange,
178 obsoleteSslCipher: self.obsoleteSslCipher,
179 obsoleteSslSignature: self.obsoleteSslSignature,
180 }
181 }
182}
183
184
185#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
186pub enum SafetyTipStatus {
187 #[default]
188 #[serde(rename = "badReputation")]
189 BadReputation,
190 #[serde(rename = "lookalike")]
191 Lookalike,
192}
193
194
195#[derive(Debug, Clone, Serialize, Deserialize, Default)]
196#[serde(rename_all = "camelCase")]
197pub struct SafetyTipInfo<'a> {
198 safetyTipStatus: SafetyTipStatus,
200 #[serde(skip_serializing_if = "Option::is_none")]
202 safeUrl: Option<Cow<'a, str>>,
203}
204
205impl<'a> SafetyTipInfo<'a> {
206 pub fn builder(safetyTipStatus: SafetyTipStatus) -> SafetyTipInfoBuilder<'a> {
207 SafetyTipInfoBuilder {
208 safetyTipStatus: safetyTipStatus,
209 safeUrl: None,
210 }
211 }
212 pub fn safetyTipStatus(&self) -> &SafetyTipStatus { &self.safetyTipStatus }
213 pub fn safeUrl(&self) -> Option<&str> { self.safeUrl.as_deref() }
214}
215
216
217pub struct SafetyTipInfoBuilder<'a> {
218 safetyTipStatus: SafetyTipStatus,
219 safeUrl: Option<Cow<'a, str>>,
220}
221
222impl<'a> SafetyTipInfoBuilder<'a> {
223 pub fn safeUrl(mut self, safeUrl: impl Into<Cow<'a, str>>) -> Self { self.safeUrl = Some(safeUrl.into()); self }
225 pub fn build(self) -> SafetyTipInfo<'a> {
226 SafetyTipInfo {
227 safetyTipStatus: self.safetyTipStatus,
228 safeUrl: self.safeUrl,
229 }
230 }
231}
232
233#[derive(Debug, Clone, Serialize, Deserialize, Default)]
236#[serde(rename_all = "camelCase")]
237pub struct VisibleSecurityState<'a> {
238 securityState: SecurityState,
240 #[serde(skip_serializing_if = "Option::is_none")]
242 certificateSecurityState: Option<CertificateSecurityState<'a>>,
243 #[serde(skip_serializing_if = "Option::is_none")]
245 safetyTipInfo: Option<SafetyTipInfo<'a>>,
246 securityStateIssueIds: Vec<Cow<'a, str>>,
248}
249
250impl<'a> VisibleSecurityState<'a> {
251 pub fn builder(securityState: SecurityState, securityStateIssueIds: Vec<Cow<'a, str>>) -> VisibleSecurityStateBuilder<'a> {
252 VisibleSecurityStateBuilder {
253 securityState: securityState,
254 certificateSecurityState: None,
255 safetyTipInfo: None,
256 securityStateIssueIds: securityStateIssueIds,
257 }
258 }
259 pub fn securityState(&self) -> &SecurityState { &self.securityState }
260 pub fn certificateSecurityState(&self) -> Option<&CertificateSecurityState<'a>> { self.certificateSecurityState.as_ref() }
261 pub fn safetyTipInfo(&self) -> Option<&SafetyTipInfo<'a>> { self.safetyTipInfo.as_ref() }
262 pub fn securityStateIssueIds(&self) -> &[Cow<'a, str>] { &self.securityStateIssueIds }
263}
264
265
266pub struct VisibleSecurityStateBuilder<'a> {
267 securityState: SecurityState,
268 certificateSecurityState: Option<CertificateSecurityState<'a>>,
269 safetyTipInfo: Option<SafetyTipInfo<'a>>,
270 securityStateIssueIds: Vec<Cow<'a, str>>,
271}
272
273impl<'a> VisibleSecurityStateBuilder<'a> {
274 pub fn certificateSecurityState(mut self, certificateSecurityState: CertificateSecurityState<'a>) -> Self { self.certificateSecurityState = Some(certificateSecurityState); self }
276 pub fn safetyTipInfo(mut self, safetyTipInfo: SafetyTipInfo<'a>) -> Self { self.safetyTipInfo = Some(safetyTipInfo); self }
278 pub fn build(self) -> VisibleSecurityState<'a> {
279 VisibleSecurityState {
280 securityState: self.securityState,
281 certificateSecurityState: self.certificateSecurityState,
282 safetyTipInfo: self.safetyTipInfo,
283 securityStateIssueIds: self.securityStateIssueIds,
284 }
285 }
286}
287
288#[derive(Debug, Clone, Serialize, Deserialize, Default)]
291#[serde(rename_all = "camelCase")]
292pub struct SecurityStateExplanation<'a> {
293 securityState: SecurityState,
295 title: Cow<'a, str>,
297 summary: Cow<'a, str>,
299 description: Cow<'a, str>,
301 mixedContentType: MixedContentType,
303 certificate: Vec<Cow<'a, str>>,
305 #[serde(skip_serializing_if = "Option::is_none")]
307 recommendations: Option<Vec<Cow<'a, str>>>,
308}
309
310impl<'a> SecurityStateExplanation<'a> {
311 pub fn builder(securityState: SecurityState, title: impl Into<Cow<'a, str>>, summary: impl Into<Cow<'a, str>>, description: impl Into<Cow<'a, str>>, mixedContentType: MixedContentType, certificate: Vec<Cow<'a, str>>) -> SecurityStateExplanationBuilder<'a> {
312 SecurityStateExplanationBuilder {
313 securityState: securityState,
314 title: title.into(),
315 summary: summary.into(),
316 description: description.into(),
317 mixedContentType: mixedContentType,
318 certificate: certificate,
319 recommendations: None,
320 }
321 }
322 pub fn securityState(&self) -> &SecurityState { &self.securityState }
323 pub fn title(&self) -> &str { self.title.as_ref() }
324 pub fn summary(&self) -> &str { self.summary.as_ref() }
325 pub fn description(&self) -> &str { self.description.as_ref() }
326 pub fn mixedContentType(&self) -> &MixedContentType { &self.mixedContentType }
327 pub fn certificate(&self) -> &[Cow<'a, str>] { &self.certificate }
328 pub fn recommendations(&self) -> Option<&[Cow<'a, str>]> { self.recommendations.as_deref() }
329}
330
331
332pub struct SecurityStateExplanationBuilder<'a> {
333 securityState: SecurityState,
334 title: Cow<'a, str>,
335 summary: Cow<'a, str>,
336 description: Cow<'a, str>,
337 mixedContentType: MixedContentType,
338 certificate: Vec<Cow<'a, str>>,
339 recommendations: Option<Vec<Cow<'a, str>>>,
340}
341
342impl<'a> SecurityStateExplanationBuilder<'a> {
343 pub fn recommendations(mut self, recommendations: Vec<Cow<'a, str>>) -> Self { self.recommendations = Some(recommendations); self }
345 pub fn build(self) -> SecurityStateExplanation<'a> {
346 SecurityStateExplanation {
347 securityState: self.securityState,
348 title: self.title,
349 summary: self.summary,
350 description: self.description,
351 mixedContentType: self.mixedContentType,
352 certificate: self.certificate,
353 recommendations: self.recommendations,
354 }
355 }
356}
357
358#[derive(Debug, Clone, Serialize, Deserialize, Default)]
361#[serde(rename_all = "camelCase")]
362pub struct InsecureContentStatus {
363 ranMixedContent: bool,
365 displayedMixedContent: bool,
367 containedMixedForm: bool,
369 ranContentWithCertErrors: bool,
371 displayedContentWithCertErrors: bool,
373 ranInsecureContentStyle: SecurityState,
375 displayedInsecureContentStyle: SecurityState,
377}
378
379impl InsecureContentStatus {
380 pub fn builder(ranMixedContent: bool, displayedMixedContent: bool, containedMixedForm: bool, ranContentWithCertErrors: bool, displayedContentWithCertErrors: bool, ranInsecureContentStyle: SecurityState, displayedInsecureContentStyle: SecurityState) -> InsecureContentStatusBuilder {
381 InsecureContentStatusBuilder {
382 ranMixedContent: ranMixedContent,
383 displayedMixedContent: displayedMixedContent,
384 containedMixedForm: containedMixedForm,
385 ranContentWithCertErrors: ranContentWithCertErrors,
386 displayedContentWithCertErrors: displayedContentWithCertErrors,
387 ranInsecureContentStyle: ranInsecureContentStyle,
388 displayedInsecureContentStyle: displayedInsecureContentStyle,
389 }
390 }
391 pub fn ranMixedContent(&self) -> bool { self.ranMixedContent }
392 pub fn displayedMixedContent(&self) -> bool { self.displayedMixedContent }
393 pub fn containedMixedForm(&self) -> bool { self.containedMixedForm }
394 pub fn ranContentWithCertErrors(&self) -> bool { self.ranContentWithCertErrors }
395 pub fn displayedContentWithCertErrors(&self) -> bool { self.displayedContentWithCertErrors }
396 pub fn ranInsecureContentStyle(&self) -> &SecurityState { &self.ranInsecureContentStyle }
397 pub fn displayedInsecureContentStyle(&self) -> &SecurityState { &self.displayedInsecureContentStyle }
398}
399
400
401pub struct InsecureContentStatusBuilder {
402 ranMixedContent: bool,
403 displayedMixedContent: bool,
404 containedMixedForm: bool,
405 ranContentWithCertErrors: bool,
406 displayedContentWithCertErrors: bool,
407 ranInsecureContentStyle: SecurityState,
408 displayedInsecureContentStyle: SecurityState,
409}
410
411impl InsecureContentStatusBuilder {
412 pub fn build(self) -> InsecureContentStatus {
413 InsecureContentStatus {
414 ranMixedContent: self.ranMixedContent,
415 displayedMixedContent: self.displayedMixedContent,
416 containedMixedForm: self.containedMixedForm,
417 ranContentWithCertErrors: self.ranContentWithCertErrors,
418 displayedContentWithCertErrors: self.displayedContentWithCertErrors,
419 ranInsecureContentStyle: self.ranInsecureContentStyle,
420 displayedInsecureContentStyle: self.displayedInsecureContentStyle,
421 }
422 }
423}
424
425#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
429pub enum CertificateErrorAction {
430 #[default]
431 #[serde(rename = "continue")]
432 Continue,
433 #[serde(rename = "cancel")]
434 Cancel,
435}
436
437#[derive(Debug, Clone, Serialize, Deserialize, Default)]
438pub struct DisableParams {}
439
440impl DisableParams { pub const METHOD: &'static str = "Security.disable"; }
441
442impl<'a> crate::CdpCommand<'a> for DisableParams {
443 const METHOD: &'static str = "Security.disable";
444 type Response = crate::EmptyReturns;
445}
446
447#[derive(Debug, Clone, Serialize, Deserialize, Default)]
448pub struct EnableParams {}
449
450impl EnableParams { pub const METHOD: &'static str = "Security.enable"; }
451
452impl<'a> crate::CdpCommand<'a> for EnableParams {
453 const METHOD: &'static str = "Security.enable";
454 type Response = crate::EmptyReturns;
455}
456
457#[derive(Debug, Clone, Serialize, Deserialize, Default)]
460#[serde(rename_all = "camelCase")]
461pub struct SetIgnoreCertificateErrorsParams {
462 ignore: bool,
464}
465
466impl SetIgnoreCertificateErrorsParams {
467 pub fn builder(ignore: bool) -> SetIgnoreCertificateErrorsParamsBuilder {
468 SetIgnoreCertificateErrorsParamsBuilder {
469 ignore: ignore,
470 }
471 }
472 pub fn ignore(&self) -> bool { self.ignore }
473}
474
475
476pub struct SetIgnoreCertificateErrorsParamsBuilder {
477 ignore: bool,
478}
479
480impl SetIgnoreCertificateErrorsParamsBuilder {
481 pub fn build(self) -> SetIgnoreCertificateErrorsParams {
482 SetIgnoreCertificateErrorsParams {
483 ignore: self.ignore,
484 }
485 }
486}
487
488impl SetIgnoreCertificateErrorsParams { pub const METHOD: &'static str = "Security.setIgnoreCertificateErrors"; }
489
490impl<'a> crate::CdpCommand<'a> for SetIgnoreCertificateErrorsParams {
491 const METHOD: &'static str = "Security.setIgnoreCertificateErrors";
492 type Response = crate::EmptyReturns;
493}
494
495#[derive(Debug, Clone, Serialize, Deserialize, Default)]
498#[serde(rename_all = "camelCase")]
499pub struct HandleCertificateErrorParams {
500 eventId: u64,
502 action: CertificateErrorAction,
504}
505
506impl HandleCertificateErrorParams {
507 pub fn builder(eventId: u64, action: CertificateErrorAction) -> HandleCertificateErrorParamsBuilder {
508 HandleCertificateErrorParamsBuilder {
509 eventId: eventId,
510 action: action,
511 }
512 }
513 pub fn eventId(&self) -> u64 { self.eventId }
514 pub fn action(&self) -> &CertificateErrorAction { &self.action }
515}
516
517
518pub struct HandleCertificateErrorParamsBuilder {
519 eventId: u64,
520 action: CertificateErrorAction,
521}
522
523impl HandleCertificateErrorParamsBuilder {
524 pub fn build(self) -> HandleCertificateErrorParams {
525 HandleCertificateErrorParams {
526 eventId: self.eventId,
527 action: self.action,
528 }
529 }
530}
531
532impl HandleCertificateErrorParams { pub const METHOD: &'static str = "Security.handleCertificateError"; }
533
534impl<'a> crate::CdpCommand<'a> for HandleCertificateErrorParams {
535 const METHOD: &'static str = "Security.handleCertificateError";
536 type Response = crate::EmptyReturns;
537}
538
539#[derive(Debug, Clone, Serialize, Deserialize, Default)]
543#[serde(rename_all = "camelCase")]
544pub struct SetOverrideCertificateErrorsParams {
545 #[serde(rename = "override")]
547 override_: bool,
548}
549
550impl SetOverrideCertificateErrorsParams {
551 pub fn builder(override_: bool) -> SetOverrideCertificateErrorsParamsBuilder {
552 SetOverrideCertificateErrorsParamsBuilder {
553 override_: override_,
554 }
555 }
556 pub fn override_(&self) -> bool { self.override_ }
557}
558
559
560pub struct SetOverrideCertificateErrorsParamsBuilder {
561 override_: bool,
562}
563
564impl SetOverrideCertificateErrorsParamsBuilder {
565 pub fn build(self) -> SetOverrideCertificateErrorsParams {
566 SetOverrideCertificateErrorsParams {
567 override_: self.override_,
568 }
569 }
570}
571
572impl SetOverrideCertificateErrorsParams { pub const METHOD: &'static str = "Security.setOverrideCertificateErrors"; }
573
574impl<'a> crate::CdpCommand<'a> for SetOverrideCertificateErrorsParams {
575 const METHOD: &'static str = "Security.setOverrideCertificateErrors";
576 type Response = crate::EmptyReturns;
577}