-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathaudits.py
More file actions
1990 lines (1596 loc) · 79.3 KB
/
audits.py
File metadata and controls
1990 lines (1596 loc) · 79.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# DO NOT EDIT THIS FILE!
#
# This file is generated from the CDP specification. If you need to make
# changes, edit the generator and regenerate all of the modules.
#
# CDP domain: Audits (experimental)
from __future__ import annotations
from cdp.util import event_class, T_JSON_DICT
from dataclasses import dataclass
import enum
import typing
from . import dom
from . import network
from . import page
from . import runtime
@dataclass
class AffectedCookie:
r'''
Information about a cookie that is affected by an inspector issue.
'''
#: The following three properties uniquely identify a cookie
name: str
path: str
domain: str
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['name'] = self.name
json['path'] = self.path
json['domain'] = self.domain
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AffectedCookie:
return cls(
name=str(json['name']),
path=str(json['path']),
domain=str(json['domain']),
)
@dataclass
class AffectedRequest:
r'''
Information about a request that is affected by an inspector issue.
'''
url: str
#: The unique request id.
request_id: typing.Optional[network.RequestId] = None
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['url'] = self.url
if self.request_id is not None:
json['requestId'] = self.request_id.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AffectedRequest:
return cls(
url=str(json['url']),
request_id=network.RequestId.from_json(json['requestId']) if 'requestId' in json else None,
)
@dataclass
class AffectedFrame:
r'''
Information about the frame affected by an inspector issue.
'''
frame_id: page.FrameId
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['frameId'] = self.frame_id.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AffectedFrame:
return cls(
frame_id=page.FrameId.from_json(json['frameId']),
)
class CookieExclusionReason(enum.Enum):
EXCLUDE_SAME_SITE_UNSPECIFIED_TREATED_AS_LAX = "ExcludeSameSiteUnspecifiedTreatedAsLax"
EXCLUDE_SAME_SITE_NONE_INSECURE = "ExcludeSameSiteNoneInsecure"
EXCLUDE_SAME_SITE_LAX = "ExcludeSameSiteLax"
EXCLUDE_SAME_SITE_STRICT = "ExcludeSameSiteStrict"
EXCLUDE_DOMAIN_NON_ASCII = "ExcludeDomainNonASCII"
EXCLUDE_THIRD_PARTY_COOKIE_BLOCKED_IN_FIRST_PARTY_SET = "ExcludeThirdPartyCookieBlockedInFirstPartySet"
EXCLUDE_THIRD_PARTY_PHASEOUT = "ExcludeThirdPartyPhaseout"
EXCLUDE_PORT_MISMATCH = "ExcludePortMismatch"
EXCLUDE_SCHEME_MISMATCH = "ExcludeSchemeMismatch"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> CookieExclusionReason:
return cls(json)
class CookieWarningReason(enum.Enum):
WARN_SAME_SITE_UNSPECIFIED_CROSS_SITE_CONTEXT = "WarnSameSiteUnspecifiedCrossSiteContext"
WARN_SAME_SITE_NONE_INSECURE = "WarnSameSiteNoneInsecure"
WARN_SAME_SITE_UNSPECIFIED_LAX_ALLOW_UNSAFE = "WarnSameSiteUnspecifiedLaxAllowUnsafe"
WARN_SAME_SITE_STRICT_LAX_DOWNGRADE_STRICT = "WarnSameSiteStrictLaxDowngradeStrict"
WARN_SAME_SITE_STRICT_CROSS_DOWNGRADE_STRICT = "WarnSameSiteStrictCrossDowngradeStrict"
WARN_SAME_SITE_STRICT_CROSS_DOWNGRADE_LAX = "WarnSameSiteStrictCrossDowngradeLax"
WARN_SAME_SITE_LAX_CROSS_DOWNGRADE_STRICT = "WarnSameSiteLaxCrossDowngradeStrict"
WARN_SAME_SITE_LAX_CROSS_DOWNGRADE_LAX = "WarnSameSiteLaxCrossDowngradeLax"
WARN_ATTRIBUTE_VALUE_EXCEEDS_MAX_SIZE = "WarnAttributeValueExceedsMaxSize"
WARN_DOMAIN_NON_ASCII = "WarnDomainNonASCII"
WARN_THIRD_PARTY_PHASEOUT = "WarnThirdPartyPhaseout"
WARN_CROSS_SITE_REDIRECT_DOWNGRADE_CHANGES_INCLUSION = "WarnCrossSiteRedirectDowngradeChangesInclusion"
WARN_DEPRECATION_TRIAL_METADATA = "WarnDeprecationTrialMetadata"
WARN_THIRD_PARTY_COOKIE_HEURISTIC = "WarnThirdPartyCookieHeuristic"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> CookieWarningReason:
return cls(json)
class CookieOperation(enum.Enum):
SET_COOKIE = "SetCookie"
READ_COOKIE = "ReadCookie"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> CookieOperation:
return cls(json)
class InsightType(enum.Enum):
r'''
Represents the category of insight that a cookie issue falls under.
'''
GIT_HUB_RESOURCE = "GitHubResource"
GRACE_PERIOD = "GracePeriod"
HEURISTICS = "Heuristics"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> InsightType:
return cls(json)
@dataclass
class CookieIssueInsight:
r'''
Information about the suggested solution to a cookie issue.
'''
type_: InsightType
#: Link to table entry in third-party cookie migration readiness list.
table_entry_url: typing.Optional[str] = None
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['type'] = self.type_.to_json()
if self.table_entry_url is not None:
json['tableEntryUrl'] = self.table_entry_url
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> CookieIssueInsight:
return cls(
type_=InsightType.from_json(json['type']),
table_entry_url=str(json['tableEntryUrl']) if 'tableEntryUrl' in json else None,
)
@dataclass
class CookieIssueDetails:
r'''
This information is currently necessary, as the front-end has a difficult
time finding a specific cookie. With this, we can convey specific error
information without the cookie.
'''
cookie_warning_reasons: typing.List[CookieWarningReason]
cookie_exclusion_reasons: typing.List[CookieExclusionReason]
#: Optionally identifies the site-for-cookies and the cookie url, which
#: may be used by the front-end as additional context.
operation: CookieOperation
#: If AffectedCookie is not set then rawCookieLine contains the raw
#: Set-Cookie header string. This hints at a problem where the
#: cookie line is syntactically or semantically malformed in a way
#: that no valid cookie could be created.
cookie: typing.Optional[AffectedCookie] = None
raw_cookie_line: typing.Optional[str] = None
site_for_cookies: typing.Optional[str] = None
cookie_url: typing.Optional[str] = None
request: typing.Optional[AffectedRequest] = None
#: The recommended solution to the issue.
insight: typing.Optional[CookieIssueInsight] = None
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['cookieWarningReasons'] = [i.to_json() for i in self.cookie_warning_reasons]
json['cookieExclusionReasons'] = [i.to_json() for i in self.cookie_exclusion_reasons]
json['operation'] = self.operation.to_json()
if self.cookie is not None:
json['cookie'] = self.cookie.to_json()
if self.raw_cookie_line is not None:
json['rawCookieLine'] = self.raw_cookie_line
if self.site_for_cookies is not None:
json['siteForCookies'] = self.site_for_cookies
if self.cookie_url is not None:
json['cookieUrl'] = self.cookie_url
if self.request is not None:
json['request'] = self.request.to_json()
if self.insight is not None:
json['insight'] = self.insight.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> CookieIssueDetails:
return cls(
cookie_warning_reasons=[CookieWarningReason.from_json(i) for i in json['cookieWarningReasons']],
cookie_exclusion_reasons=[CookieExclusionReason.from_json(i) for i in json['cookieExclusionReasons']],
operation=CookieOperation.from_json(json['operation']),
cookie=AffectedCookie.from_json(json['cookie']) if 'cookie' in json else None,
raw_cookie_line=str(json['rawCookieLine']) if 'rawCookieLine' in json else None,
site_for_cookies=str(json['siteForCookies']) if 'siteForCookies' in json else None,
cookie_url=str(json['cookieUrl']) if 'cookieUrl' in json else None,
request=AffectedRequest.from_json(json['request']) if 'request' in json else None,
insight=CookieIssueInsight.from_json(json['insight']) if 'insight' in json else None,
)
class PerformanceIssueType(enum.Enum):
DOCUMENT_COOKIE = "DocumentCookie"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> PerformanceIssueType:
return cls(json)
@dataclass
class PerformanceIssueDetails:
r'''
Details for a performance issue.
'''
performance_issue_type: PerformanceIssueType
source_code_location: typing.Optional[SourceCodeLocation] = None
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['performanceIssueType'] = self.performance_issue_type.to_json()
if self.source_code_location is not None:
json['sourceCodeLocation'] = self.source_code_location.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> PerformanceIssueDetails:
return cls(
performance_issue_type=PerformanceIssueType.from_json(json['performanceIssueType']),
source_code_location=SourceCodeLocation.from_json(json['sourceCodeLocation']) if 'sourceCodeLocation' in json else None,
)
class MixedContentResolutionStatus(enum.Enum):
MIXED_CONTENT_BLOCKED = "MixedContentBlocked"
MIXED_CONTENT_AUTOMATICALLY_UPGRADED = "MixedContentAutomaticallyUpgraded"
MIXED_CONTENT_WARNING = "MixedContentWarning"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> MixedContentResolutionStatus:
return cls(json)
class MixedContentResourceType(enum.Enum):
ATTRIBUTION_SRC = "AttributionSrc"
AUDIO = "Audio"
BEACON = "Beacon"
CSP_REPORT = "CSPReport"
DOWNLOAD = "Download"
EVENT_SOURCE = "EventSource"
FAVICON = "Favicon"
FONT = "Font"
FORM = "Form"
FRAME = "Frame"
IMAGE = "Image"
IMPORT = "Import"
JSON = "JSON"
MANIFEST = "Manifest"
PING = "Ping"
PLUGIN_DATA = "PluginData"
PLUGIN_RESOURCE = "PluginResource"
PREFETCH = "Prefetch"
RESOURCE = "Resource"
SCRIPT = "Script"
SERVICE_WORKER = "ServiceWorker"
SHARED_WORKER = "SharedWorker"
SPECULATION_RULES = "SpeculationRules"
STYLESHEET = "Stylesheet"
TRACK = "Track"
VIDEO = "Video"
WORKER = "Worker"
XML_HTTP_REQUEST = "XMLHttpRequest"
XSLT = "XSLT"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> MixedContentResourceType:
return cls(json)
@dataclass
class MixedContentIssueDetails:
#: The way the mixed content issue is being resolved.
resolution_status: MixedContentResolutionStatus
#: The unsafe http url causing the mixed content issue.
insecure_url: str
#: The url responsible for the call to an unsafe url.
main_resource_url: str
#: The type of resource causing the mixed content issue (css, js, iframe,
#: form,...). Marked as optional because it is mapped to from
#: blink::mojom::RequestContextType, which will be replaced
#: by network::mojom::RequestDestination
resource_type: typing.Optional[MixedContentResourceType] = None
#: The mixed content request.
#: Does not always exist (e.g. for unsafe form submission urls).
request: typing.Optional[AffectedRequest] = None
#: Optional because not every mixed content issue is necessarily linked to a frame.
frame: typing.Optional[AffectedFrame] = None
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['resolutionStatus'] = self.resolution_status.to_json()
json['insecureURL'] = self.insecure_url
json['mainResourceURL'] = self.main_resource_url
if self.resource_type is not None:
json['resourceType'] = self.resource_type.to_json()
if self.request is not None:
json['request'] = self.request.to_json()
if self.frame is not None:
json['frame'] = self.frame.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> MixedContentIssueDetails:
return cls(
resolution_status=MixedContentResolutionStatus.from_json(json['resolutionStatus']),
insecure_url=str(json['insecureURL']),
main_resource_url=str(json['mainResourceURL']),
resource_type=MixedContentResourceType.from_json(json['resourceType']) if 'resourceType' in json else None,
request=AffectedRequest.from_json(json['request']) if 'request' in json else None,
frame=AffectedFrame.from_json(json['frame']) if 'frame' in json else None,
)
class BlockedByResponseReason(enum.Enum):
r'''
Enum indicating the reason a response has been blocked. These reasons are
refinements of the net error BLOCKED_BY_RESPONSE.
'''
COEP_FRAME_RESOURCE_NEEDS_COEP_HEADER = "CoepFrameResourceNeedsCoepHeader"
COOP_SANDBOXED_I_FRAME_CANNOT_NAVIGATE_TO_COOP_PAGE = "CoopSandboxedIFrameCannotNavigateToCoopPage"
CORP_NOT_SAME_ORIGIN = "CorpNotSameOrigin"
CORP_NOT_SAME_ORIGIN_AFTER_DEFAULTED_TO_SAME_ORIGIN_BY_COEP = "CorpNotSameOriginAfterDefaultedToSameOriginByCoep"
CORP_NOT_SAME_ORIGIN_AFTER_DEFAULTED_TO_SAME_ORIGIN_BY_DIP = "CorpNotSameOriginAfterDefaultedToSameOriginByDip"
CORP_NOT_SAME_ORIGIN_AFTER_DEFAULTED_TO_SAME_ORIGIN_BY_COEP_AND_DIP = "CorpNotSameOriginAfterDefaultedToSameOriginByCoepAndDip"
CORP_NOT_SAME_SITE = "CorpNotSameSite"
SRI_MESSAGE_SIGNATURE_MISMATCH = "SRIMessageSignatureMismatch"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> BlockedByResponseReason:
return cls(json)
@dataclass
class BlockedByResponseIssueDetails:
r'''
Details for a request that has been blocked with the BLOCKED_BY_RESPONSE
code. Currently only used for COEP/COOP, but may be extended to include
some CSP errors in the future.
'''
request: AffectedRequest
reason: BlockedByResponseReason
parent_frame: typing.Optional[AffectedFrame] = None
blocked_frame: typing.Optional[AffectedFrame] = None
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['request'] = self.request.to_json()
json['reason'] = self.reason.to_json()
if self.parent_frame is not None:
json['parentFrame'] = self.parent_frame.to_json()
if self.blocked_frame is not None:
json['blockedFrame'] = self.blocked_frame.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> BlockedByResponseIssueDetails:
return cls(
request=AffectedRequest.from_json(json['request']),
reason=BlockedByResponseReason.from_json(json['reason']),
parent_frame=AffectedFrame.from_json(json['parentFrame']) if 'parentFrame' in json else None,
blocked_frame=AffectedFrame.from_json(json['blockedFrame']) if 'blockedFrame' in json else None,
)
class HeavyAdResolutionStatus(enum.Enum):
HEAVY_AD_BLOCKED = "HeavyAdBlocked"
HEAVY_AD_WARNING = "HeavyAdWarning"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> HeavyAdResolutionStatus:
return cls(json)
class HeavyAdReason(enum.Enum):
NETWORK_TOTAL_LIMIT = "NetworkTotalLimit"
CPU_TOTAL_LIMIT = "CpuTotalLimit"
CPU_PEAK_LIMIT = "CpuPeakLimit"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> HeavyAdReason:
return cls(json)
@dataclass
class HeavyAdIssueDetails:
#: The resolution status, either blocking the content or warning.
resolution: HeavyAdResolutionStatus
#: The reason the ad was blocked, total network or cpu or peak cpu.
reason: HeavyAdReason
#: The frame that was blocked.
frame: AffectedFrame
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['resolution'] = self.resolution.to_json()
json['reason'] = self.reason.to_json()
json['frame'] = self.frame.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> HeavyAdIssueDetails:
return cls(
resolution=HeavyAdResolutionStatus.from_json(json['resolution']),
reason=HeavyAdReason.from_json(json['reason']),
frame=AffectedFrame.from_json(json['frame']),
)
class ContentSecurityPolicyViolationType(enum.Enum):
K_INLINE_VIOLATION = "kInlineViolation"
K_EVAL_VIOLATION = "kEvalViolation"
K_URL_VIOLATION = "kURLViolation"
K_SRI_VIOLATION = "kSRIViolation"
K_TRUSTED_TYPES_SINK_VIOLATION = "kTrustedTypesSinkViolation"
K_TRUSTED_TYPES_POLICY_VIOLATION = "kTrustedTypesPolicyViolation"
K_WASM_EVAL_VIOLATION = "kWasmEvalViolation"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> ContentSecurityPolicyViolationType:
return cls(json)
@dataclass
class SourceCodeLocation:
url: str
line_number: int
column_number: int
script_id: typing.Optional[runtime.ScriptId] = None
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['url'] = self.url
json['lineNumber'] = self.line_number
json['columnNumber'] = self.column_number
if self.script_id is not None:
json['scriptId'] = self.script_id.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> SourceCodeLocation:
return cls(
url=str(json['url']),
line_number=int(json['lineNumber']),
column_number=int(json['columnNumber']),
script_id=runtime.ScriptId.from_json(json['scriptId']) if 'scriptId' in json else None,
)
@dataclass
class ContentSecurityPolicyIssueDetails:
#: Specific directive that is violated, causing the CSP issue.
violated_directive: str
is_report_only: bool
content_security_policy_violation_type: ContentSecurityPolicyViolationType
#: The url not included in allowed sources.
blocked_url: typing.Optional[str] = None
frame_ancestor: typing.Optional[AffectedFrame] = None
source_code_location: typing.Optional[SourceCodeLocation] = None
violating_node_id: typing.Optional[dom.BackendNodeId] = None
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['violatedDirective'] = self.violated_directive
json['isReportOnly'] = self.is_report_only
json['contentSecurityPolicyViolationType'] = self.content_security_policy_violation_type.to_json()
if self.blocked_url is not None:
json['blockedURL'] = self.blocked_url
if self.frame_ancestor is not None:
json['frameAncestor'] = self.frame_ancestor.to_json()
if self.source_code_location is not None:
json['sourceCodeLocation'] = self.source_code_location.to_json()
if self.violating_node_id is not None:
json['violatingNodeId'] = self.violating_node_id.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> ContentSecurityPolicyIssueDetails:
return cls(
violated_directive=str(json['violatedDirective']),
is_report_only=bool(json['isReportOnly']),
content_security_policy_violation_type=ContentSecurityPolicyViolationType.from_json(json['contentSecurityPolicyViolationType']),
blocked_url=str(json['blockedURL']) if 'blockedURL' in json else None,
frame_ancestor=AffectedFrame.from_json(json['frameAncestor']) if 'frameAncestor' in json else None,
source_code_location=SourceCodeLocation.from_json(json['sourceCodeLocation']) if 'sourceCodeLocation' in json else None,
violating_node_id=dom.BackendNodeId.from_json(json['violatingNodeId']) if 'violatingNodeId' in json else None,
)
class SharedArrayBufferIssueType(enum.Enum):
TRANSFER_ISSUE = "TransferIssue"
CREATION_ISSUE = "CreationIssue"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> SharedArrayBufferIssueType:
return cls(json)
@dataclass
class SharedArrayBufferIssueDetails:
r'''
Details for a issue arising from an SAB being instantiated in, or
transferred to a context that is not cross-origin isolated.
'''
source_code_location: SourceCodeLocation
is_warning: bool
type_: SharedArrayBufferIssueType
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['sourceCodeLocation'] = self.source_code_location.to_json()
json['isWarning'] = self.is_warning
json['type'] = self.type_.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> SharedArrayBufferIssueDetails:
return cls(
source_code_location=SourceCodeLocation.from_json(json['sourceCodeLocation']),
is_warning=bool(json['isWarning']),
type_=SharedArrayBufferIssueType.from_json(json['type']),
)
@dataclass
class CorsIssueDetails:
r'''
Details for a CORS related issue, e.g. a warning or error related to
CORS RFC1918 enforcement.
'''
cors_error_status: network.CorsErrorStatus
is_warning: bool
request: AffectedRequest
location: typing.Optional[SourceCodeLocation] = None
initiator_origin: typing.Optional[str] = None
resource_ip_address_space: typing.Optional[network.IPAddressSpace] = None
client_security_state: typing.Optional[network.ClientSecurityState] = None
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['corsErrorStatus'] = self.cors_error_status.to_json()
json['isWarning'] = self.is_warning
json['request'] = self.request.to_json()
if self.location is not None:
json['location'] = self.location.to_json()
if self.initiator_origin is not None:
json['initiatorOrigin'] = self.initiator_origin
if self.resource_ip_address_space is not None:
json['resourceIPAddressSpace'] = self.resource_ip_address_space.to_json()
if self.client_security_state is not None:
json['clientSecurityState'] = self.client_security_state.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> CorsIssueDetails:
return cls(
cors_error_status=network.CorsErrorStatus.from_json(json['corsErrorStatus']),
is_warning=bool(json['isWarning']),
request=AffectedRequest.from_json(json['request']),
location=SourceCodeLocation.from_json(json['location']) if 'location' in json else None,
initiator_origin=str(json['initiatorOrigin']) if 'initiatorOrigin' in json else None,
resource_ip_address_space=network.IPAddressSpace.from_json(json['resourceIPAddressSpace']) if 'resourceIPAddressSpace' in json else None,
client_security_state=network.ClientSecurityState.from_json(json['clientSecurityState']) if 'clientSecurityState' in json else None,
)
class AttributionReportingIssueType(enum.Enum):
PERMISSION_POLICY_DISABLED = "PermissionPolicyDisabled"
UNTRUSTWORTHY_REPORTING_ORIGIN = "UntrustworthyReportingOrigin"
INSECURE_CONTEXT = "InsecureContext"
INVALID_HEADER = "InvalidHeader"
INVALID_REGISTER_TRIGGER_HEADER = "InvalidRegisterTriggerHeader"
SOURCE_AND_TRIGGER_HEADERS = "SourceAndTriggerHeaders"
SOURCE_IGNORED = "SourceIgnored"
TRIGGER_IGNORED = "TriggerIgnored"
OS_SOURCE_IGNORED = "OsSourceIgnored"
OS_TRIGGER_IGNORED = "OsTriggerIgnored"
INVALID_REGISTER_OS_SOURCE_HEADER = "InvalidRegisterOsSourceHeader"
INVALID_REGISTER_OS_TRIGGER_HEADER = "InvalidRegisterOsTriggerHeader"
WEB_AND_OS_HEADERS = "WebAndOsHeaders"
NO_WEB_OR_OS_SUPPORT = "NoWebOrOsSupport"
NAVIGATION_REGISTRATION_WITHOUT_TRANSIENT_USER_ACTIVATION = "NavigationRegistrationWithoutTransientUserActivation"
INVALID_INFO_HEADER = "InvalidInfoHeader"
NO_REGISTER_SOURCE_HEADER = "NoRegisterSourceHeader"
NO_REGISTER_TRIGGER_HEADER = "NoRegisterTriggerHeader"
NO_REGISTER_OS_SOURCE_HEADER = "NoRegisterOsSourceHeader"
NO_REGISTER_OS_TRIGGER_HEADER = "NoRegisterOsTriggerHeader"
NAVIGATION_REGISTRATION_UNIQUE_SCOPE_ALREADY_SET = "NavigationRegistrationUniqueScopeAlreadySet"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> AttributionReportingIssueType:
return cls(json)
class SharedDictionaryError(enum.Enum):
USE_ERROR_CROSS_ORIGIN_NO_CORS_REQUEST = "UseErrorCrossOriginNoCorsRequest"
USE_ERROR_DICTIONARY_LOAD_FAILURE = "UseErrorDictionaryLoadFailure"
USE_ERROR_MATCHING_DICTIONARY_NOT_USED = "UseErrorMatchingDictionaryNotUsed"
USE_ERROR_UNEXPECTED_CONTENT_DICTIONARY_HEADER = "UseErrorUnexpectedContentDictionaryHeader"
WRITE_ERROR_COSS_ORIGIN_NO_CORS_REQUEST = "WriteErrorCossOriginNoCorsRequest"
WRITE_ERROR_DISALLOWED_BY_SETTINGS = "WriteErrorDisallowedBySettings"
WRITE_ERROR_EXPIRED_RESPONSE = "WriteErrorExpiredResponse"
WRITE_ERROR_FEATURE_DISABLED = "WriteErrorFeatureDisabled"
WRITE_ERROR_INSUFFICIENT_RESOURCES = "WriteErrorInsufficientResources"
WRITE_ERROR_INVALID_MATCH_FIELD = "WriteErrorInvalidMatchField"
WRITE_ERROR_INVALID_STRUCTURED_HEADER = "WriteErrorInvalidStructuredHeader"
WRITE_ERROR_INVALID_TTL_FIELD = "WriteErrorInvalidTTLField"
WRITE_ERROR_NAVIGATION_REQUEST = "WriteErrorNavigationRequest"
WRITE_ERROR_NO_MATCH_FIELD = "WriteErrorNoMatchField"
WRITE_ERROR_NON_INTEGER_TTL_FIELD = "WriteErrorNonIntegerTTLField"
WRITE_ERROR_NON_LIST_MATCH_DEST_FIELD = "WriteErrorNonListMatchDestField"
WRITE_ERROR_NON_SECURE_CONTEXT = "WriteErrorNonSecureContext"
WRITE_ERROR_NON_STRING_ID_FIELD = "WriteErrorNonStringIdField"
WRITE_ERROR_NON_STRING_IN_MATCH_DEST_LIST = "WriteErrorNonStringInMatchDestList"
WRITE_ERROR_NON_STRING_MATCH_FIELD = "WriteErrorNonStringMatchField"
WRITE_ERROR_NON_TOKEN_TYPE_FIELD = "WriteErrorNonTokenTypeField"
WRITE_ERROR_REQUEST_ABORTED = "WriteErrorRequestAborted"
WRITE_ERROR_SHUTTING_DOWN = "WriteErrorShuttingDown"
WRITE_ERROR_TOO_LONG_ID_FIELD = "WriteErrorTooLongIdField"
WRITE_ERROR_UNSUPPORTED_TYPE = "WriteErrorUnsupportedType"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> SharedDictionaryError:
return cls(json)
class SRIMessageSignatureError(enum.Enum):
MISSING_SIGNATURE_HEADER = "MissingSignatureHeader"
MISSING_SIGNATURE_INPUT_HEADER = "MissingSignatureInputHeader"
INVALID_SIGNATURE_HEADER = "InvalidSignatureHeader"
INVALID_SIGNATURE_INPUT_HEADER = "InvalidSignatureInputHeader"
SIGNATURE_HEADER_VALUE_IS_NOT_BYTE_SEQUENCE = "SignatureHeaderValueIsNotByteSequence"
SIGNATURE_HEADER_VALUE_IS_PARAMETERIZED = "SignatureHeaderValueIsParameterized"
SIGNATURE_HEADER_VALUE_IS_INCORRECT_LENGTH = "SignatureHeaderValueIsIncorrectLength"
SIGNATURE_INPUT_HEADER_MISSING_LABEL = "SignatureInputHeaderMissingLabel"
SIGNATURE_INPUT_HEADER_VALUE_NOT_INNER_LIST = "SignatureInputHeaderValueNotInnerList"
SIGNATURE_INPUT_HEADER_VALUE_MISSING_COMPONENTS = "SignatureInputHeaderValueMissingComponents"
SIGNATURE_INPUT_HEADER_INVALID_COMPONENT_TYPE = "SignatureInputHeaderInvalidComponentType"
SIGNATURE_INPUT_HEADER_INVALID_COMPONENT_NAME = "SignatureInputHeaderInvalidComponentName"
SIGNATURE_INPUT_HEADER_INVALID_HEADER_COMPONENT_PARAMETER = "SignatureInputHeaderInvalidHeaderComponentParameter"
SIGNATURE_INPUT_HEADER_INVALID_DERIVED_COMPONENT_PARAMETER = "SignatureInputHeaderInvalidDerivedComponentParameter"
SIGNATURE_INPUT_HEADER_KEY_ID_LENGTH = "SignatureInputHeaderKeyIdLength"
SIGNATURE_INPUT_HEADER_INVALID_PARAMETER = "SignatureInputHeaderInvalidParameter"
SIGNATURE_INPUT_HEADER_MISSING_REQUIRED_PARAMETERS = "SignatureInputHeaderMissingRequiredParameters"
VALIDATION_FAILED_SIGNATURE_EXPIRED = "ValidationFailedSignatureExpired"
VALIDATION_FAILED_INVALID_LENGTH = "ValidationFailedInvalidLength"
VALIDATION_FAILED_SIGNATURE_MISMATCH = "ValidationFailedSignatureMismatch"
VALIDATION_FAILED_INTEGRITY_MISMATCH = "ValidationFailedIntegrityMismatch"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> SRIMessageSignatureError:
return cls(json)
class UnencodedDigestError(enum.Enum):
MALFORMED_DICTIONARY = "MalformedDictionary"
UNKNOWN_ALGORITHM = "UnknownAlgorithm"
INCORRECT_DIGEST_TYPE = "IncorrectDigestType"
INCORRECT_DIGEST_LENGTH = "IncorrectDigestLength"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> UnencodedDigestError:
return cls(json)
class ConnectionAllowlistError(enum.Enum):
INVALID_HEADER = "InvalidHeader"
MORE_THAN_ONE_LIST = "MoreThanOneList"
ITEM_NOT_INNER_LIST = "ItemNotInnerList"
INVALID_ALLOWLIST_ITEM_TYPE = "InvalidAllowlistItemType"
REPORTING_ENDPOINT_NOT_TOKEN = "ReportingEndpointNotToken"
INVALID_URL_PATTERN = "InvalidUrlPattern"
def to_json(self) -> str:
return self.value
@classmethod
def from_json(cls, json: str) -> ConnectionAllowlistError:
return cls(json)
@dataclass
class AttributionReportingIssueDetails:
r'''
Details for issues around "Attribution Reporting API" usage.
Explainer: https://github.com/WICG/attribution-reporting-api
'''
violation_type: AttributionReportingIssueType
request: typing.Optional[AffectedRequest] = None
violating_node_id: typing.Optional[dom.BackendNodeId] = None
invalid_parameter: typing.Optional[str] = None
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['violationType'] = self.violation_type.to_json()
if self.request is not None:
json['request'] = self.request.to_json()
if self.violating_node_id is not None:
json['violatingNodeId'] = self.violating_node_id.to_json()
if self.invalid_parameter is not None:
json['invalidParameter'] = self.invalid_parameter
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> AttributionReportingIssueDetails:
return cls(
violation_type=AttributionReportingIssueType.from_json(json['violationType']),
request=AffectedRequest.from_json(json['request']) if 'request' in json else None,
violating_node_id=dom.BackendNodeId.from_json(json['violatingNodeId']) if 'violatingNodeId' in json else None,
invalid_parameter=str(json['invalidParameter']) if 'invalidParameter' in json else None,
)
@dataclass
class QuirksModeIssueDetails:
r'''
Details for issues about documents in Quirks Mode
or Limited Quirks Mode that affects page layouting.
'''
#: If false, it means the document's mode is "quirks"
#: instead of "limited-quirks".
is_limited_quirks_mode: bool
document_node_id: dom.BackendNodeId
url: str
frame_id: page.FrameId
loader_id: network.LoaderId
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['isLimitedQuirksMode'] = self.is_limited_quirks_mode
json['documentNodeId'] = self.document_node_id.to_json()
json['url'] = self.url
json['frameId'] = self.frame_id.to_json()
json['loaderId'] = self.loader_id.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> QuirksModeIssueDetails:
return cls(
is_limited_quirks_mode=bool(json['isLimitedQuirksMode']),
document_node_id=dom.BackendNodeId.from_json(json['documentNodeId']),
url=str(json['url']),
frame_id=page.FrameId.from_json(json['frameId']),
loader_id=network.LoaderId.from_json(json['loaderId']),
)
@dataclass
class NavigatorUserAgentIssueDetails:
url: str
location: typing.Optional[SourceCodeLocation] = None
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['url'] = self.url
if self.location is not None:
json['location'] = self.location.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> NavigatorUserAgentIssueDetails:
return cls(
url=str(json['url']),
location=SourceCodeLocation.from_json(json['location']) if 'location' in json else None,
)
@dataclass
class SharedDictionaryIssueDetails:
shared_dictionary_error: SharedDictionaryError
request: AffectedRequest
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['sharedDictionaryError'] = self.shared_dictionary_error.to_json()
json['request'] = self.request.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> SharedDictionaryIssueDetails:
return cls(
shared_dictionary_error=SharedDictionaryError.from_json(json['sharedDictionaryError']),
request=AffectedRequest.from_json(json['request']),
)
@dataclass
class SRIMessageSignatureIssueDetails:
error: SRIMessageSignatureError
signature_base: str
integrity_assertions: typing.List[str]
request: AffectedRequest
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['error'] = self.error.to_json()
json['signatureBase'] = self.signature_base
json['integrityAssertions'] = [i for i in self.integrity_assertions]
json['request'] = self.request.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> SRIMessageSignatureIssueDetails:
return cls(
error=SRIMessageSignatureError.from_json(json['error']),
signature_base=str(json['signatureBase']),
integrity_assertions=[str(i) for i in json['integrityAssertions']],
request=AffectedRequest.from_json(json['request']),
)
@dataclass
class UnencodedDigestIssueDetails:
error: UnencodedDigestError
request: AffectedRequest
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['error'] = self.error.to_json()
json['request'] = self.request.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> UnencodedDigestIssueDetails:
return cls(
error=UnencodedDigestError.from_json(json['error']),
request=AffectedRequest.from_json(json['request']),
)
@dataclass
class ConnectionAllowlistIssueDetails:
error: ConnectionAllowlistError
request: AffectedRequest
def to_json(self) -> T_JSON_DICT:
json: T_JSON_DICT = dict()
json['error'] = self.error.to_json()
json['request'] = self.request.to_json()
return json
@classmethod
def from_json(cls, json: T_JSON_DICT) -> ConnectionAllowlistIssueDetails:
return cls(
error=ConnectionAllowlistError.from_json(json['error']),
request=AffectedRequest.from_json(json['request']),
)
class GenericIssueErrorType(enum.Enum):
FORM_LABEL_FOR_NAME_ERROR = "FormLabelForNameError"
FORM_DUPLICATE_ID_FOR_INPUT_ERROR = "FormDuplicateIdForInputError"
FORM_INPUT_WITH_NO_LABEL_ERROR = "FormInputWithNoLabelError"
FORM_AUTOCOMPLETE_ATTRIBUTE_EMPTY_ERROR = "FormAutocompleteAttributeEmptyError"
FORM_EMPTY_ID_AND_NAME_ATTRIBUTES_FOR_INPUT_ERROR = "FormEmptyIdAndNameAttributesForInputError"
FORM_ARIA_LABELLED_BY_TO_NON_EXISTING_ID_ERROR = "FormAriaLabelledByToNonExistingIdError"
FORM_INPUT_ASSIGNED_AUTOCOMPLETE_VALUE_TO_ID_OR_NAME_ATTRIBUTE_ERROR = "FormInputAssignedAutocompleteValueToIdOrNameAttributeError"
FORM_LABEL_HAS_NEITHER_FOR_NOR_NESTED_INPUT_ERROR = "FormLabelHasNeitherForNorNestedInputError"
FORM_LABEL_FOR_MATCHES_NON_EXISTING_ID_ERROR = "FormLabelForMatchesNonExistingIdError"
FORM_INPUT_HAS_WRONG_BUT_WELL_INTENDED_AUTOCOMPLETE_VALUE_ERROR = "FormInputHasWrongButWellIntendedAutocompleteValueError"
RESPONSE_WAS_BLOCKED_BY_ORB = "ResponseWasBlockedByORB"
NAVIGATION_ENTRY_MARKED_SKIPPABLE = "NavigationEntryMarkedSkippable"