-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
chore(CLI): start working on CLI #4067
Changes from all commits
b6be1a9
db17ca6
d0576ca
a72b894
1893a7f
787888d
c8d09f2
093cb7e
1df94e0
492e682
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# CLI | ||
To show the banner, use: | ||
`python cli/cli.py banner` | ||
## Listing | ||
List services by provider. | ||
`python cli/cli.py <provider> list-services` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import typer | ||
|
||
from prowler.lib.banner import print_banner | ||
from prowler.lib.check.check import ( | ||
list_fixers, | ||
list_services, | ||
print_fixers, | ||
print_services, | ||
) | ||
|
||
app = typer.Typer() | ||
aws = typer.Typer(name="aws") | ||
azure = typer.Typer(name="azure") | ||
gcp = typer.Typer(name="gcp") | ||
kubernetes = typer.Typer(name="kubernetes") | ||
|
||
app.add_typer(aws, name="aws") | ||
app.add_typer(azure, name="azure") | ||
app.add_typer(gcp, name="gcp") | ||
app.add_typer(kubernetes, name="kubernetes") | ||
|
||
|
||
def list_resources(provider: str, resource_type: str): | ||
if resource_type == "services": | ||
print_services(list_services(provider)) | ||
elif resource_type == "fixers": | ||
print_fixers(list_fixers(provider)) | ||
|
||
|
||
def create_list_commands(provider_typer: typer.Typer): | ||
provider_name = provider_typer.info.name | ||
|
||
@provider_typer.command( | ||
"list-services", | ||
help=f"List the {provider_name} services that are supported by Prowler.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you get the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, done |
||
) | ||
def list_services_command(): | ||
list_resources(provider_name, "services") | ||
|
||
@provider_typer.command( | ||
"list-fixers", | ||
help=f"List the {provider_name} fixers that are supported by Prowler.", | ||
) | ||
def list_fixers_command(): | ||
list_resources(provider_name, "fixers") | ||
|
||
|
||
create_list_commands(aws) | ||
create_list_commands(azure) | ||
create_list_commands(gcp) | ||
create_list_commands(kubernetes) | ||
|
||
|
||
@app.command("banner", help="Prints the banner of the tool.") | ||
def banner(show: bool = True): | ||
if show: | ||
print_banner(show) | ||
else: | ||
print("Banner is not shown.") | ||
|
||
|
||
if __name__ == "__main__": | ||
app() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an
__init__.py
file in this folder please.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done