Skip to content

Commit 9eb03de

Browse files
added non interactive mode
1 parent 019250e commit 9eb03de

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

app.py

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def cli():
4848
)
4949
@click.option("--db_enabled", help="Enable db", default=False, is_flag=True, flag_value=True)
5050
@click.option("--falco_enabled", help="Enable falco", default=False, is_flag=True, flag_value=True)
51+
@click.option("--non_interactive", help="Run scsctl in non interactive mode", default= False, is_flag=True, flag_value=True)
5152
@click.option(
5253
"--docker_file_folder_path", help="Path of the docker file to rebuild", default=None, is_flag=False, flag_value=None
5354
)
@@ -62,6 +63,7 @@ def scan(
6263
db_enabled=False,
6364
falco_enabled=False,
6465
config_file=None,
66+
non_interactive = False
6567
):
6668
config_data = {}
6769
if config_file is not None:
@@ -159,23 +161,37 @@ def scan(
159161
choices.remove("Falco detected packages")
160162

161163
if scan_status:
162-
while True:
163-
choice = questionary.select("Select an option", choices=choices, style=custom_style_fancy).ask()
164-
if choice == "Exit":
165-
break
166-
if choice == "Sbom report":
167-
print_sbom_report(sbom_report)
168-
if choice == "Pyroscope detected packages":
169-
print_pyroscope_packages(pyroscope_data)
170-
if choice == "Falco detected packages":
171-
print_falco_packages(falco_found_extra_packages)
172-
if choice == "Final report":
173-
click.echo("Vulnerable packages that can be uninstalled from the docker image are:")
174-
click.echo(final_report)
175-
if choice == "Rebuild the image":
176-
if docker_file_folder_path == None:
177-
docker_file_folder_path = click.prompt("Enter docker file folder path", type=str)
178-
modify_and_build_docker_image(docker_file_folder_path, pyroscope_found_extra_packages, batch_id)
164+
if(non_interactive):
165+
click.echo("Sbom report")
166+
click.echo("===========")
167+
print_sbom_report(sbom_report)
168+
click.echo("Pyroscope detected packages")
169+
click.echo("===========================")
170+
print_pyroscope_packages(pyroscope_data)
171+
click.echo("Falco detected packages")
172+
click.echo("=======================")
173+
print_falco_packages(falco_found_extra_packages)
174+
click.echo("Final Report")
175+
click.echo("=============")
176+
click.echo(final_report)
177+
else:
178+
while True:
179+
choice = questionary.select("Select an option", choices=choices, style=custom_style_fancy).ask()
180+
if choice == "Exit":
181+
break
182+
if choice == "Sbom report":
183+
print_sbom_report(sbom_report)
184+
if choice == "Pyroscope detected packages":
185+
print_pyroscope_packages(pyroscope_data)
186+
if choice == "Falco detected packages":
187+
print_falco_packages(falco_found_extra_packages)
188+
if choice == "Final report":
189+
click.echo("Vulnerable packages that can be uninstalled from the docker image are:")
190+
click.echo(final_report)
191+
if choice == "Rebuild the image":
192+
if docker_file_folder_path == None:
193+
docker_file_folder_path = click.prompt("Enter docker file folder path", type=str)
194+
modify_and_build_docker_image(docker_file_folder_path, pyroscope_found_extra_packages, batch_id)
179195

180196

181197
cli.add_command(scan)

0 commit comments

Comments
 (0)