Skip to content

Commit

Permalink
fix(json): check if profile is None (#3043)
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCloudSec authored Nov 16, 2023
1 parent 9205ef3 commit 3d56335
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
7 changes: 4 additions & 3 deletions prowler/lib/outputs/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,9 @@ def add_html_footer(output_filename, output_directory):
def get_aws_html_assessment_summary(audit_info):
try:
if isinstance(audit_info, AWS_Audit_Info):
if not audit_info.profile:
audit_info.profile = "ENV"
profile = (
audit_info.profile if audit_info.profile is not None else "default"
)
if isinstance(audit_info.audited_regions, list):
audited_regions = " ".join(audit_info.audited_regions)
elif not audit_info.audited_regions:
Expand All @@ -361,7 +362,7 @@ def get_aws_html_assessment_summary(audit_info):
</li>
<li class="list-group-item">
<b>AWS-CLI Profile:</b> """
+ audit_info.profile
+ profile
+ """
</li>
<li class="list-group-item">
Expand Down
5 changes: 2 additions & 3 deletions prowler/lib/outputs/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def fill_json_ocsf(audit_info, finding, output_options) -> Check_Output_JSON_OCS
aws_org_uid = ""
account = None
org = None
profile = audit_info.profile if audit_info.profile is not None else "default"
if (
hasattr(audit_info, "organizations_metadata")
and audit_info.organizations_metadata
Expand Down Expand Up @@ -249,9 +250,7 @@ def fill_json_ocsf(audit_info, finding, output_options) -> Check_Output_JSON_OCS
original_time=outputs_unix_timestamp(
output_options.unix_timestamp, timestamp
),
profiles=[audit_info.profile]
if hasattr(audit_info, "organizations_metadata")
else [],
profiles=[profile],
)
compliance = Compliance_OCSF(
status=generate_json_ocsf_status(finding.status),
Expand Down
2 changes: 1 addition & 1 deletion tests/providers/common/common_outputs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def test_aws_get_assessment_summary(self):
<b>AWS Account:</b> {audit_info.audited_account}
</li>
<li class="list-group-item">
<b>AWS-CLI Profile:</b> {audit_info.profile}
<b>AWS-CLI Profile:</b> default
</li>
<li class="list-group-item">
<b>Audited Regions:</b> All Regions
Expand Down

0 comments on commit 3d56335

Please sign in to comment.