Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions cloudsplaining/command/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@
is_flag=True,
help="Flag risky trust policies in roles.",
)
@click.option(
"-dA",
"--disable-appendices",
required=False,
default=False,
is_flag=True,
help="Disable the Guidance and Appendices tabs in the HTML report.",
)
def scan(
input_file: str,
exclusions_file: str,
Expand All @@ -114,6 +122,8 @@ def scan(
verbosity: int,
severity: list[str],
flag_trust_policies: bool,
# New argument to disable appendices in the HTML report:
disable_appendices: bool,
) -> None: # pragma: no cover
"""
Given the path to account authorization details files and the exclusions config file, scan all inline and
Expand Down Expand Up @@ -152,6 +162,8 @@ def scan(
flag_conditional_statements=flag_conditional_statements,
flag_resource_arn_statements=flag_resource_arn_statements,
flag_trust_policies=flag_trust_policies,
# Dependency injection of new argument to disable appendices in the HTML report:
disable_appendices=disable_appendices,
severity=severity,
)
html_output_file = os.path.join(output, f"iam-report-{account_name}.html")
Expand Down Expand Up @@ -185,6 +197,8 @@ def scan(
output,
write_data_files=True,
minimize=minimize,
# dependency injection of new argument to disable appendices in the HTML report:
disable_appendices=disable_appendices,
severity=severity,
)
html_output_file = os.path.join(output, f"iam-report-{account_name}.html")
Expand Down Expand Up @@ -235,6 +249,8 @@ def scan_account_authorization_details(
flag_resource_arn_statements: bool = ...,
flag_trust_policies: bool = ...,
severity: list[str] | None = ...,
# New argument to disable appendices in the HTML report:
disable_appendices: bool = ...,
) -> str: ...


Expand All @@ -250,6 +266,8 @@ def scan_account_authorization_details(
flag_resource_arn_statements: bool = False,
flag_trust_policies: bool = False,
severity: list[str] | None = None,
# New argument to disable appendices in the HTML report:
disable_appendices: bool = False,
) -> str | dict[str, Any]: # pragma: no cover
"""
Given the path to account authorization details files and the exclusions config file, scan all inline and
Expand Down Expand Up @@ -280,6 +298,8 @@ def scan_account_authorization_details(
account_name=account_name,
results=results,
minimize=minimize,
# dependency injection of new argument to disable appendices in the HTML report:
disable_appendices=disable_appendices,
)
rendered_report = html_report.get_html_report()

Expand Down
6 changes: 6 additions & 0 deletions cloudsplaining/output/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ def __init__(
account_name: str,
results: dict[str, dict[str, Any]],
minimize: bool = False,
# New argument to disable appendices in the HTML report:
disable_appendices: bool = False,
) -> None:
self.account_name = account_name
self.account_id = account_id
self.report_generated_time = datetime.datetime.now().strftime("%Y-%m-%d")
self.minimize = minimize
# dependency injection of new argument to disable appendices in the HTML report:
self.disable_appendices = disable_appendices
self.results = f"var iam_data = {json.dumps(results, default=str)}"
self.template_config = TemplateConfig()

Expand Down Expand Up @@ -79,6 +83,8 @@ def get_html_report(self) -> str:
appendices_content=self.template_config.appendices_content,
show_guidance_nav=self.template_config.show_guidance_nav,
show_appendices_nav=self.template_config.show_appendices_nav,
# dependency injection of new argument to disable appendices in the HTML report:
disable_appendices=self.disable_appendices,
)
template_path = os.path.dirname(__file__)
env = Environment(loader=FileSystemLoader(template_path)) # noqa: S701
Expand Down
2 changes: 2 additions & 0 deletions cloudsplaining/output/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@
var appendices_content;
var show_guidance_nav;
var show_appendices_nav;
var disable_appendices;
account_id = "{{ t.account_id }}";
account_name = "{{ t.account_name }}";
report_generated_time = "{{ t.report_generated_time }}";
cloudsplaining_version = "{{ t.cloudsplaining_version }}";
show_guidance_nav = "{{ t.show_guidance_nav }}";
show_appendices_nav = "{{ t.show_appendices_nav }}";
disable_appendices = "{{ t.disable_appendices }}";
guidance_content = "{{ t.guidance_content|safe if t.show_guidance_nav else '' }}";
appendices_content = "{{ t.appendices_content|safe if t.show_appendices_nav else '' }}";

Expand Down