16
16
from rich .status import Status
17
17
from rich .table import Table
18
18
19
- from macaron .slsa_analyzer .checks .check_result import CheckResultType
20
-
21
19
22
20
class Check :
23
21
"""Class to represent a check with its status and target."""
@@ -72,6 +70,15 @@ def __init__(self, *args: Any, verbose: bool = False, **kwargs: Any) -> None:
72
70
"Policy Report" : Status ("[green]Generating[/]" ),
73
71
}
74
72
self .verification_summary_attestation : str | None = None
73
+ self .find_source_table = Table (show_header = False , box = None )
74
+ self .find_source_content : dict [str , str | Status ] = {
75
+ "Repository PURL:" : Status ("[green]Processing[/]" ),
76
+ "Commit Hash:" : Status ("[green]Processing[/]" ),
77
+ "JSON Report:" : "Not Generated" ,
78
+ }
79
+ for key , value in self .find_source_content .items ():
80
+ self .find_source_table .add_row (key , value )
81
+ self .dump_defaults : str | Status = Status ("[green]Generating[/]" )
75
82
self .verbose = verbose
76
83
self .verbose_panel = Panel (
77
84
"\n " .join (self .logs ),
@@ -137,7 +144,7 @@ def update_checks_summary(self, checks_summary: dict, total_checks: int) -> None
137
144
failed_checks_table .add_column ("Check ID" , justify = "left" )
138
145
failed_checks_table .add_column ("Description" , justify = "left" )
139
146
140
- failed_checks = checks_summary [CheckResultType . FAILED ]
147
+ failed_checks = checks_summary [" FAILED" ]
141
148
for check in failed_checks :
142
149
failed_checks_table .add_row (
143
150
"[bold red]FAILED[/]" ,
@@ -153,15 +160,15 @@ def update_checks_summary(self, checks_summary: dict, total_checks: int) -> None
153
160
summary_table .add_row ("Total Checks" , str (total_checks ), style = "white" )
154
161
155
162
for check_result_type , checks in checks_summary .items ():
156
- if check_result_type == CheckResultType . PASSED :
163
+ if check_result_type == " PASSED" :
157
164
summary_table .add_row ("PASSED" , str (len (checks )), style = "green" )
158
- if check_result_type == CheckResultType . FAILED :
165
+ if check_result_type == " FAILED" :
159
166
summary_table .add_row ("FAILED" , str (len (checks )), style = "red" )
160
- if check_result_type == CheckResultType . SKIPPED :
167
+ if check_result_type == " SKIPPED" :
161
168
summary_table .add_row ("SKIPPED" , str (len (checks )), style = "yellow" )
162
- if check_result_type == CheckResultType . DISABLED :
169
+ if check_result_type == " DISABLED" :
163
170
summary_table .add_row ("DISABLED" , str (len (checks )), style = "bright_blue" )
164
- if check_result_type == CheckResultType . UNKNOWN :
171
+ if check_result_type == " UNKNOWN" :
165
172
summary_table .add_row ("UNKNOWN" , str (len (checks )), style = "white" )
166
173
167
174
self .summary_table = summary_table
@@ -236,6 +243,20 @@ def update_policy_engine(self, results: dict) -> None:
236
243
237
244
self .generate_policy_summary_table ()
238
245
246
+ def update_find_source_table (self , key : str , value : str | Status ) -> None :
247
+ """Add or update a key-value pair in the find source table."""
248
+ self .find_source_content [key ] = value
249
+ find_source_table = Table (show_header = False , box = None )
250
+ find_source_table .add_column ("Details" , justify = "left" )
251
+ find_source_table .add_column ("Value" , justify = "left" )
252
+ for field , content in self .find_source_content .items ():
253
+ find_source_table .add_row (field , content )
254
+ self .find_source_table = find_source_table
255
+
256
+ def update_dump_defaults (self , value : str | Status ) -> None :
257
+ """Update the dump defaults status."""
258
+ self .dump_defaults = value
259
+
239
260
def make_layout (self ) -> Group :
240
261
"""Create the overall layout for the console output."""
241
262
layout : list [RenderableType ] = []
@@ -303,6 +324,15 @@ def make_layout(self) -> Group:
303
324
)
304
325
305
326
layout = layout + [vsa_table ]
327
+ elif self .command == "find-source" :
328
+ if self .find_source_table .row_count > 0 :
329
+ layout = layout + [self .find_source_table ]
330
+ elif self .command == "dump-defaults" :
331
+ dump_defaults_table = Table (show_header = False , box = None )
332
+ dump_defaults_table .add_column ("Detail" , justify = "left" )
333
+ dump_defaults_table .add_column ("Value" , justify = "left" )
334
+ dump_defaults_table .add_row ("Dump Defaults" , self .dump_defaults )
335
+ layout = layout + [dump_defaults_table ]
306
336
307
337
if self .verbose :
308
338
layout = layout + ["" , self .verbose_panel ]
0 commit comments