@@ -556,7 +556,8 @@ async def get_status(
556556def _build_report_url (base_url , report , * args , ** kwargs ):
557557 if kwargs .get ('download' ):
558558 return f"{ base_url } reports/{ report } "
559- url = f"{ base_url } page/report/{ report } "
559+ report_page = 'report_full' if kwargs .get ('full' ) else 'report'
560+ url = f"{ base_url } page/{ report_page } /{ report } "
560561 if len (args ) == 2 : # version, testcase_id --> add corresponding fragment specifier
561562 url += f"#{ args [0 ]} _{ args [1 ]} "
562563 return url
@@ -570,16 +571,54 @@ def render_view(view, view_type, detail_page='detail', base_url='/', title=None,
570571 def scope_url (uuid ): return f"{ base_url } page/scope/{ uuid } " # noqa: E306,E704
571572 def detail_url (subject , scope ): return f"{ base_url } page/{ detail_page } /{ subject } /{ scope } " # noqa: E306,E704
572573 def report_url (report , * args , ** kwargs ): return _build_report_url (base_url , report , * args , ** kwargs ) # noqa: E306,E704
573- fragment = templates_map [stage1 ].render (detail_url = detail_url , report_url = report_url , scope_url = scope_url , ** kwargs )
574+ fragment = templates_map [stage1 ].render (base_url = base_url , detail_url = detail_url , report_url = report_url , scope_url = scope_url , ** kwargs )
574575 if view_type != ViewType .markdown and stage1 .endswith ('.md' ):
575576 fragment = markdown (fragment , extensions = ['extra' ])
576577 if stage1 != stage2 :
577578 fragment = templates_map [stage2 ].render (fragment = fragment , title = title )
578579 return Response (content = fragment , media_type = media_type )
579580
580581
582+ def _redact_report (report ):
583+ """remove all lines from script output in `report` that are not directly linked to any testcase"""
584+ if 'run' not in report or 'invocations' not in report ['run' ]:
585+ return
586+ for invdata in report ['run' ]['invocations' ].values ():
587+ stdout = invdata .get ('stdout' , [])
588+ redacted = [line for line in stdout if line [- 4 :] in ('PASS' , 'FAIL' )]
589+ if len (redacted ) != len (stdout ):
590+ redacted .insert (0 , '(the following has been redacted)' )
591+ invdata ['stdout' ] = redacted
592+ invdata ['redacted' ] = True
593+ stderr = invdata .get ('stderr' , [])
594+ redacted = [line for line in stderr if line [:6 ] in ('WARNIN' , 'ERROR:' )]
595+ if len (redacted ) != len (stderr ):
596+ redacted .insert (0 , '(the following has been redacted)' )
597+ invdata ['stderr' ] = redacted
598+ invdata ['redacted' ] = True
599+
600+
581601@app .get ("/{view_type}/report/{report_uuid}" )
582602async def get_report_view (
603+ request : Request ,
604+ conn : Annotated [connection , Depends (get_conn )],
605+ view_type : ViewType ,
606+ report_uuid : str ,
607+ ):
608+ with conn .cursor () as cur :
609+ specs = db_get_report (cur , report_uuid )
610+ if not specs :
611+ raise HTTPException (status_code = 404 )
612+ spec = specs [0 ]
613+ _redact_report (spec )
614+ return render_view (
615+ VIEW_REPORT , view_type , report = spec , base_url = settings .base_url ,
616+ title = f'Report { report_uuid } (redacted)' ,
617+ )
618+
619+
620+ @app .get ("/{view_type}/report_full/{report_uuid}" )
621+ async def get_report_view_full (
583622 request : Request ,
584623 account : Annotated [Optional [tuple [str , str ]], Depends (auth )],
585624 conn : Annotated [connection , Depends (get_conn )],
@@ -592,7 +631,10 @@ async def get_report_view(
592631 raise HTTPException (status_code = 404 )
593632 spec = specs [0 ]
594633 check_role (account , spec ['subject' ], ROLES ['read_any' ])
595- return render_view (VIEW_REPORT , view_type , report = spec , base_url = settings .base_url , title = f'Report { report_uuid } ' )
634+ return render_view (
635+ VIEW_REPORT , view_type , report = spec , base_url = settings .base_url ,
636+ title = f'Report { report_uuid } (full)' ,
637+ )
596638
597639
598640@app .get ("/{view_type}/detail/{subject}/{scopeuuid}" )
@@ -606,28 +648,32 @@ async def get_detail(
606648 with conn .cursor () as cur :
607649 rows2 = db_get_relevant_results2 (cur , subject , scopeuuid , approved_only = True )
608650 results2 = convert_result_rows_to_dict2 (
609- rows2 , get_scopes (), grace_period_days = GRACE_PERIOD_DAYS ,
651+ rows2 , get_scopes (), include_report = True , grace_period_days = GRACE_PERIOD_DAYS ,
610652 subjects = (subject , ), scopes = (scopeuuid , ),
611653 )
612- return render_view (VIEW_DETAIL , view_type , results = results2 , base_url = settings .base_url , title = f'{ subject } compliance' )
654+ return render_view (
655+ VIEW_DETAIL , view_type , results = results2 , base_url = settings .base_url ,
656+ title = f'{ subject } compliance' ,
657+ )
613658
614659
615660@app .get ("/{view_type}/detail_full/{subject}/{scopeuuid}" )
616661async def get_detail_full (
617662 request : Request ,
618- account : Annotated [Optional [tuple [str , str ]], Depends (auth )],
619663 conn : Annotated [connection , Depends (get_conn )],
620664 view_type : ViewType ,
621665 subject : str ,
622666 scopeuuid : str ,
623667):
624- check_role (account , subject , ROLES ['read_any' ])
625668 with conn .cursor () as cur :
626669 rows2 = db_get_relevant_results2 (cur , subject , scopeuuid , approved_only = False )
627670 results2 = convert_result_rows_to_dict2 (
628671 rows2 , get_scopes (), include_report = True , subjects = (subject , ), scopes = (scopeuuid , ),
629672 )
630- return render_view (VIEW_DETAIL , view_type , results = results2 , base_url = settings .base_url , title = f'{ subject } compliance' )
673+ return render_view (
674+ VIEW_DETAIL , view_type , results = results2 , base_url = settings .base_url ,
675+ title = f'{ subject } compliance (incl. unverified results)' ,
676+ )
631677
632678
633679@app .get ("/{view_type}/table" )
@@ -639,24 +685,24 @@ async def get_table(
639685 with conn .cursor () as cur :
640686 rows2 = db_get_relevant_results2 (cur , approved_only = True )
641687 results2 = convert_result_rows_to_dict2 (rows2 , get_scopes (), grace_period_days = GRACE_PERIOD_DAYS )
642- return render_view (VIEW_TABLE , view_type , results = results2 , base_url = settings .base_url , title = "SCS compliance overview" )
688+ return render_view (
689+ VIEW_TABLE , view_type , results = results2 , base_url = settings .base_url , detail_page = 'detail' ,
690+ title = "SCS compliance overview" ,
691+ )
643692
644693
645694@app .get ("/{view_type}/table_full" )
646695async def get_table_full (
647696 request : Request ,
648- account : Annotated [Optional [tuple [str , str ]], Depends (auth )],
649697 conn : Annotated [connection , Depends (get_conn )],
650698 view_type : ViewType ,
651699):
652- check_role (account , None , ROLES ['read_any' ])
653700 with conn .cursor () as cur :
654701 rows2 = db_get_relevant_results2 (cur , approved_only = False )
655702 results2 = convert_result_rows_to_dict2 (rows2 , get_scopes ())
656703 return render_view (
657- VIEW_TABLE , view_type , results = results2 ,
658- detail_page = 'detail_full' , base_url = settings .base_url ,
659- title = "SCS compliance overview" ,
704+ VIEW_TABLE , view_type , results = results2 , base_url = settings .base_url , detail_page = 'detail_full' ,
705+ title = "SCS compliance overview (incl. unverified results)" , unverified = True ,
660706 )
661707
662708
0 commit comments