Skip to content

Commit

Permalink
Reporter: convert to class implementation (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
rlxdev authored Aug 14, 2024
1 parent 5cc10af commit 9eec6e8
Show file tree
Hide file tree
Showing 2 changed files with 375 additions and 342 deletions.
30 changes: 15 additions & 15 deletions scubagoggles/orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
from scubagoggles.auth import gws_auth
from scubagoggles.provider import Provider
from scubagoggles.run_rego import opa_eval
from scubagoggles.reporter import reporter, md_parser
from scubagoggles.reporter import md_parser
from scubagoggles.reporter.reporter import Reporter
from scubagoggles.utils import rel_abs_path


Expand Down Expand Up @@ -277,17 +278,16 @@ def _run_reporter(self):
products_bar = tqdm(products, leave=False, disable=args.quiet)
for product in products_bar:
products_bar.set_description(f"Creating the HTML and JSON Report for {product}...")
stats_and_data[product] = reporter.rego_json_to_ind_reports(
test_results_data,
product,
out_folder,
tenant_domain,
main_report_name,
prod_to_fullname,
baseline_policies[product],
successful_calls,
unsuccessful_calls
)
reporter = Reporter(product,
tenant_domain,
main_report_name,
prod_to_fullname,
baseline_policies[product],
successful_calls,
unsuccessful_calls)
stats_and_data[product] = \
reporter.rego_json_to_ind_reports(test_results_data,
out_folder)
baseline_product_summary = {product:stats_and_data[product][0]}
baseline_product_results_json = {product:stats_and_data[product][1]}
summary.update(baseline_product_summary)
Expand Down Expand Up @@ -323,9 +323,9 @@ def _run_reporter(self):
"Details": self._generate_summary(stats[0])
})

fragments.append(reporter.create_html_table(table_data))
fragments.append(Reporter.create_html_table(table_data))
with open(f"{report_path}", mode='w', encoding='UTF-8') as file:
file.write(reporter.build_front_page_html(fragments, tenant_info))
file.write(Reporter.build_front_page_html(fragments, tenant_info))

# suppress opening the report in the browser
if args.quiet:
Expand Down Expand Up @@ -359,7 +359,7 @@ def _run_cached(self):
if not os.path.exists(f'{args.outputpath}/{args.outputproviderfilename}.json'):
# When running run_cached, the provider output might not exist as a stand-alone
# file depending what version of ScubaGoggles created the output. If the provider
# ouptut doesn't exist as a standa-lone file, create it from the scuba results
# output doesn't exist as a standalone file, create it from the scuba results
# file so the other functions can execute as normal.
with open(f'{args.outputpath}/{args.outjsonfilename}.json', 'r',
encoding='UTF-8') as scuba_results:
Expand Down
Loading

0 comments on commit 9eec6e8

Please sign in to comment.