Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(output): Add HTML outputs to Prowler #4005

Merged
merged 13 commits into from
May 20, 2024

Conversation

pedrooot
Copy link
Member

@pedrooot pedrooot commented May 15, 2024

Description

HTML outputs are back for all the providers.

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@pedrooot pedrooot requested review from a team as code owners May 15, 2024 06:46
sergargar and others added 3 commits May 15, 2024 11:29
…3986)

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Sergio Garcia <38561120+sergargar@users.noreply.github.com>
@github-actions github-actions bot added documentation github_actions Pull requests that update GitHub Actions code labels May 15, 2024
Copy link
Contributor

You can check the documentation for this PR here -> SaaS Documentation

Copy link
Contributor

You can check the documentation for this PR here -> SaaS Documentation

@sergargar
Copy link
Member

Great job!! Please change the screenshot in the docs index and solve the kubernetes summary tables.

Copy link
Contributor

You can check the documentation for this PR here -> SaaS Documentation

Copy link
Member

@jfagoagas jfagoagas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work bringing back the HTML format @pedrooot 👏

I left some comments since I don't understand some parts of the code. We need to make some parts clearer and fix the failing tests.

@@ -294,14 +294,16 @@ The following code is an example output of the [JSON-ASFF](https://docs.aws.amaz
???+ note
Each finding is a `json` object within a list.

### HTML

The following photo is an example of the HTML output:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The following photo is an example of the HTML output:
The following image is an example of the HTML output:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if "html" in mode:
add_html_footer(
global_provider.output_options.output_filename,
args.output_directory,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
args.output_directory,
global_provider.output_options.output_directory,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please modify this too in line 269.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

fill_html_overview_statistics(
stats,
global_provider.output_options.output_filename,
args.output_directory,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
args.output_directory,
global_provider.output_options.output_directory,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -146,8 +146,8 @@ def __init_outputs_parser__(self):
"-M",
nargs="+",
help="Output modes, by default csv and json-oscf are saved. When using AWS Security Hub integration, json-asff output is also saved.",
default=["csv", "json-ocsf"],
choices=["csv", "json-asff", "json-ocsf"],
default=["csv", "json-ocsf", "html"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the tests related with this change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 207 to 210
if not isinstance(finding, FindingOutput):
check_id = finding.check_metadata.CheckID
else:
check_id = finding.check_id
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? The HTML should get this from the finding object.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True

timestamp,
)
from prowler.lib.logger import logger
from prowler.lib.outputs.compliance.compliance import get_check_compliance
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be needed here, please get that information from the finding object.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True

Comment on lines 21 to 27
parameters = sys.argv[1:]
for index, parameter in enumerate(parameters):
if (
parameter == "--kubeconfig-file"
and "/.kube/config" in parameters[index + 1]
):
parameters[index + 1] = "~/.kube/config"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this? Please leave this function jus to fill the header, if you need to do some other changes pass do them in another place.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

# It is not pretty but useful
# AWS_provider --> aws
# GCP_provider --> gcp
# Azure_provider --> azure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to do it for K8s right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to update the comment but it's already done for Kubernetes

fill_html(
file_descriptors["html"], finding_output, output_options
)
file_descriptors["html"].write("")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the report is written, first of all the html header is created and the method fill_html is called when creating the report.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know but I mean about file_descriptors["html"].write("")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fact, it's unneeded

Copy link
Contributor

You can check the documentation for this PR here -> SaaS Documentation

1 similar comment
Copy link
Contributor

You can check the documentation for this PR here -> SaaS Documentation

@jfagoagas jfagoagas self-requested a review May 20, 2024 10:44
Copy link
Contributor

You can check the documentation for this PR here -> SaaS Documentation

Copy link
Contributor

You can check the documentation for this PR here -> SaaS Documentation

Copy link

codecov bot commented May 20, 2024

Codecov Report

Attention: Patch coverage is 34.09091% with 87 lines in your changes are missing coverage. Please review.

Project coverage is 86.23%. Comparing base (53cfcff) to head (0e35629).
Report is 4 commits behind head on master.

Files Patch % Lines
prowler/lib/outputs/html/html.py 26.41% 78 Missing ⚠️
prowler/__main__.py 0.00% 5 Missing ⚠️
prowler/lib/outputs/outputs.py 33.33% 2 Missing ⚠️
prowler/lib/outputs/summary_table.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4005      +/-   ##
==========================================
- Coverage   86.65%   86.23%   -0.43%     
==========================================
  Files         777      777              
  Lines       24139    24292     +153     
==========================================
+ Hits        20918    20947      +29     
- Misses       3221     3345     +124     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@jfagoagas jfagoagas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @pedrooot 👏 HTML is back 🚀

@jfagoagas jfagoagas merged commit db29c75 into master May 20, 2024
10 of 12 checks passed
@jfagoagas jfagoagas deleted the PRWLR-3709-prowler-oss-bring-back-html branch May 20, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation github_actions Pull requests that update GitHub Actions code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants