Skip to content

Commit

Permalink
Make it so that the scubagoggles reports link to the baselines (#323)
Browse files Browse the repository at this point in the history
* #200 added reports link to baselines

* #200 fixing pylint error with f-string

* #200 fixing pylint errors

* #200 fixing pylint errors

* #200 fixing pylint errors

* Update scubagoggles/reporter/reporter.py

Co-authored-by: Alden Hilton <106177711+adhilto@users.noreply.github.com>

* #312 updated group_reference_url variable to add to ScubaResults.json file, similar to ScubaGear

* #312 fixing pylint error

* #312 fixed spacing encoding in URL

* #312 added variables for baseline version and tool version

---------

Co-authored-by: Alden Hilton <106177711+adhilto@users.noreply.github.com>
  • Loading branch information
jfevang and adhilto authored Jul 3, 2024
1 parent 29a3dae commit 9401ead
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
14 changes: 13 additions & 1 deletion scubagoggles/reporter/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ def rego_json_to_ind_reports(test_results_data : str, product : list, out_path :
ind_report_name = product_capitalized + "Report"
fragments = []
json_data = []
baseline_version = '0.2'
tool_version = '0.2.0'
report_stats = {
"Manual": 0,
"Passes": 0,
Expand All @@ -246,6 +248,7 @@ def rego_json_to_ind_reports(test_results_data : str, product : list, out_path :
for baseline_group in product_policies:
table_data = []
results_data ={}
full_name = prod_to_fullname[product]
for control in baseline_group['Controls']:
tests = [test for test in test_results_data if test['PolicyId'] == control['Id']]
if len(tests) == 0:
Expand Down Expand Up @@ -293,6 +296,7 @@ def rego_json_to_ind_reports(test_results_data : str, product : list, out_path :
# results that belong to the Common Controls report is they're
# marked as Not-Implemented. This if excludes them from the
# rules report.
full_name = "Common Controls"
continue
report_stats[get_summary_category(result)] += 1
table_data.append({
Expand All @@ -317,11 +321,19 @@ def rego_json_to_ind_reports(test_results_data : str, product : list, out_path :
'Result': result,
'Criticality': test['Criticality'],
'Details': details})
markdown_group_name = "-".join(baseline_group['GroupName'].split())
group_reference_url = f'{SCUBA_GITHUB_URL}/blob/v{tool_version}/baselines/'\
f'{full_name} Minimum Viable Secure Configuration Baseline v{baseline_version}.md#'\
f'{baseline_group["GroupNumber"]}-{markdown_group_name}'
group_reference_url_spacing = "%20".join(group_reference_url.split())
markdown_link = fr'<a href="{group_reference_url_spacing}" target="_blank"\>'\
f'{baseline_group["GroupName"]}</a>'
fragments.append(f"<h2>{product_upper}-{baseline_group['GroupNumber']} \
{baseline_group['GroupName']}</h2>")
{markdown_link}</h2>")
fragments.append(create_html_table(table_data))
results_data.update({"GroupName": baseline_group['GroupName']})
results_data.update({"GroupNumber": baseline_group['GroupNumber']})
results_data.update({"GroupReferenceURL":group_reference_url_spacing})
results_data.update({"Controls": table_data})
json_data.append(results_data)
html = build_report_html(fragments, prod_to_fullname[product], tenant_domain, main_report_name)
Expand Down
23 changes: 23 additions & 0 deletions scubagoggles/reporter/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,27 @@ img {
.setting {
font-style: italic;
color: rgba(0, 0, 0, 0.8);
}

a.control_group:link {
font-family: Arial, Helvetica, sans-serif;
color: var(--unvisited-link-color);
text-decoration: underline;
}

a.control_group:visited {
font-family: Arial, Helvetica, sans-serif;
color: var(--link-color);
}

a.control_group:hover {
font-family: Arial, Helvetica, sans-serif;
color: var(--link-color);
text-decoration: none;
}

a.control_group:active {
font-family: Arial, Helvetica, sans-serif;
color: var(--link-color);
text-decoration: none;
}

0 comments on commit 9401ead

Please sign in to comment.