11"""
2- Validate OpenDoor GitHub Actions E2E reports against v5.15.2 report shape.
2+ Validate OpenDoor GitHub Actions E2E reports against current filtered report shape.
33"""
44
55import json
1818 "/login" ,
1919}
2020
21- EXPECTED_IGNORED_404_PATHS = {
21+ EXPECTED_FILTERED_404_PATHS = {
2222 "/nonexistent" ,
2323 "/ghost" ,
2424 "/random-miss" ,
@@ -62,22 +62,6 @@ def item_urls(report: dict, bucket: str) -> list[str]:
6262 ]
6363
6464
65- def item_details (report : dict , bucket : str ) -> list [dict ]:
66- details = report .get ("report_items" , {}).get (bucket )
67-
68- if isinstance (details , list ):
69- return [
70- item
71- for item in details
72- if isinstance (item , dict )
73- ]
74-
75- return [
76- {"url" : str (item ), "code" : "-" }
77- for item in report .get ("items" , {}).get (bucket , [])
78- ]
79-
80-
8165def has_path (urls : list [str ], path : str ) -> bool :
8266 return any (url .endswith (path ) or path in url for url in urls )
8367
@@ -90,7 +74,10 @@ def validate_json_report() -> None:
9074 assert_true (total .get ("forbidden" ) == 1 , "JSON: forbidden bucket has exactly 1 hit" )
9175 assert_true (total .get ("auth" ) == 1 , "JSON: auth bucket has exactly 1 hit" )
9276 assert_true (total .get ("redirect" ) == 1 , "JSON: redirect bucket has exactly 1 hit" )
93- assert_true (total .get ("ignored" ) == 4 , "JSON: ignored bucket has exactly 4 filtered misses" )
77+ assert_true (
78+ total .get ("ignored" ) in (None , 0 ),
79+ "JSON: ignored bucket is absent or empty for filtered misses" ,
80+ )
9481
9582 success_urls = item_urls (report , "success" )
9683
@@ -107,16 +94,12 @@ def validate_json_report() -> None:
10794 "JSON: /auth-required is in auth bucket" ,
10895 )
10996
110- ignored_items = item_details (report , "ignored" )
97+ ignored_urls = item_urls (report , "ignored" )
11198
112- for path in sorted (EXPECTED_IGNORED_404_PATHS ):
99+ for path in sorted (EXPECTED_FILTERED_404_PATHS ):
113100 assert_true (
114- any (
115- has_path ([str (item .get ("url" , "" ))], path )
116- and str (item .get ("code" )) == "404"
117- for item in ignored_items
118- ),
119- f"JSON: { path } is preserved as ignored 404" ,
101+ not has_path (ignored_urls , path ),
102+ f"JSON: { path } is not preserved as an ignored report item" ,
120103 )
121104
122105 active_buckets = ("success" , "forbidden" , "auth" , "redirect" )
@@ -126,7 +109,7 @@ def validate_json_report() -> None:
126109 for url in item_urls (report , bucket )
127110 ]
128111
129- for path in sorted (EXPECTED_IGNORED_404_PATHS ):
112+ for path in sorted (EXPECTED_FILTERED_404_PATHS ):
130113 assert_true (
131114 not has_path (active_urls , path ),
132115 f"JSON: { path } is not in active finding buckets" ,
@@ -190,10 +173,15 @@ def result_matches(rule_id: str, path: str | None = None, code: int | None = Non
190173 "SARIF: redirect bucket has status 301" ,
191174 )
192175
193- for path in sorted (EXPECTED_IGNORED_404_PATHS ):
176+ assert_true (
177+ not result_matches ("opendoor.finding.ignored" ),
178+ "SARIF: ignored filtered misses are not reported as findings" ,
179+ )
180+
181+ for path in sorted (EXPECTED_FILTERED_404_PATHS ):
194182 assert_true (
195- result_matches ("opendoor.finding.ignored" , path , 404 ),
196- f"SARIF: { path } is ignored/404" ,
183+ not result_matches ("opendoor.finding.ignored" , path , 404 ),
184+ f"SARIF: { path } is not reported as ignored/404" ,
197185 )
198186
199187
@@ -210,4 +198,4 @@ def main() -> int:
210198
211199
212200if __name__ == "__main__" :
213- raise SystemExit (main ())
201+ raise SystemExit (main ())
0 commit comments