From 2da27d59b61b02e407a66510fa6c3627be430ea3 Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Thu, 15 Dec 2022 15:16:29 +0100 Subject: [PATCH] fix: Release fixes (#1543) --- README.md | 11 +++++- docs/faq.md | 7 ++++ docs/tutorials/quick-inventory.md | 2 +- mkdocs.yml | 1 + prowler/__main__.py | 2 +- prowler/config/config.py | 4 +-- prowler/lib/cli/parser.py | 48 +++++++++++++++++++++++--- prowler/providers/common/audit_info.py | 1 - pyproject.toml | 4 +-- 9 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 docs/faq.md diff --git a/README.md b/README.md index 4dbee9d7..a59f88c0 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,15 @@ prowler aws --profile custom-profile -f us-east-1 eu-south-2 ``` > By default, `prowler` will scan all AWS regions. +## Azure + +With Azure you need to specify which auth method is going to be used: + +```console +prowler azure [--sp-env-auth, --az-cli-auth, --browser-auth, --managed-identity-auth] +``` +> By default, `prowler` will scan all Azure subscriptions. + # 🎉 New Features - Multi-cloud support! @@ -152,7 +161,7 @@ prowler aws --profile custom-profile -f us-east-1 eu-south-2 The full documentation can be found here: -[https://prowler-cloud.github.io/prowler/](https://prowler-cloud.github.io/prowler/) +[https://docs.prowler.cloud](https://docs.prowler.cloud) # 📃 License Prowler is licensed as Apache License 2.0 as specified in each file. You may obtain a copy of the License at diff --git a/docs/faq.md b/docs/faq.md new file mode 100644 index 00000000..71100bc1 --- /dev/null +++ b/docs/faq.md @@ -0,0 +1,7 @@ +# FAQ +- I am getting `OSError` related with `Too many open files`, what can I do? + +In case of a bad connection, high API response times can be given, so they will generate problems because of having several simultaneous connections, to solve this problem in your system, use the command ulimit to increase the simultaneous open files: +``` +ulimit -n 1000 +``` diff --git a/docs/tutorials/quick-inventory.md b/docs/tutorials/quick-inventory.md index d7b72600..a3cd31ac 100644 --- a/docs/tutorials/quick-inventory.md +++ b/docs/tutorials/quick-inventory.md @@ -14,4 +14,4 @@ prowler -i - Also, it creates by default a CSV and JSON to see detailed information about the resources extracted. -![Quick Inventory Example](/img/quick-inventory.png) +![Quick Inventory Example](../img/quick-inventory.png) diff --git a/mkdocs.yml b/mkdocs.yml index 5d16eef0..3b799a8c 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -44,6 +44,7 @@ nav: - Authentication: tutorials/azure/authentication.md - Subscriptions: tutorials/azure/subscriptions.md - Contact Us: contact.md + - FAQ: faq.md - About: about.md # Customization extra: diff --git a/prowler/__main__.py b/prowler/__main__.py index 9003d074..2ed180d0 100644 --- a/prowler/__main__.py +++ b/prowler/__main__.py @@ -42,7 +42,7 @@ from prowler.providers.common.outputs import set_provider_output_options def prowler(): # Parse Arguments parser = ProwlerArgumentParser() - args = parser.parser.parse_args() + args = parser.parse() # Save Arguments provider = args.provider diff --git a/prowler/config/config.py b/prowler/config/config.py index c8cceeac..0492bf6d 100644 --- a/prowler/config/config.py +++ b/prowler/config/config.py @@ -9,7 +9,7 @@ from prowler.lib.utils.utils import open_file, parse_json_file timestamp = datetime.today() timestamp_utc = datetime.now(timezone.utc).replace(tzinfo=timezone.utc) -prowler_version = "3.0-beta-21Nov2022" +prowler_version = "3.0.0" html_logo_url = "https://github.com/prowler-cloud/prowler/" html_logo_img = ( "https://github.com/prowler-cloud/prowler/raw/master/util/html/prowler-logo-new.png" @@ -32,7 +32,7 @@ csv_file_suffix = ".csv" json_file_suffix = ".json" json_asff_file_suffix = ".asff.json" html_file_suffix = ".html" -config_yaml = "prowler/config/config.yaml" +config_yaml = f"{os.path.dirname(os.path.realpath(__file__))}/config.yaml" def change_config_var(variable, value): diff --git a/prowler/lib/cli/parser.py b/prowler/lib/cli/parser.py index dc844008..a7dc0c32 100644 --- a/prowler/lib/cli/parser.py +++ b/prowler/lib/cli/parser.py @@ -1,6 +1,7 @@ import argparse from prowler.config.config import default_output_directory, prowler_version +import sys class ProwlerArgumentParser: @@ -9,7 +10,7 @@ class ProwlerArgumentParser: # CLI Arguments self.parser = argparse.ArgumentParser( prog="prowler", - epilog="To see the different available options on a specific provider, run: prowler {provider} -h", + epilog="To see the different available options on a specific provider, run: prowler {provider} -h|--help", ) # Default self.parser.add_argument( @@ -24,7 +25,8 @@ class ProwlerArgumentParser: # Providers Parser self.subparsers = self.parser.add_subparsers( - title="Prowler Available Cloud Providers", dest="provider" + title="Prowler Available Cloud Providers", + dest="provider", ) self.__init_allowlist_parser__() @@ -38,6 +40,44 @@ class ProwlerArgumentParser: self.__init_aws_parser__() self.__init_azure_parser__() + def parse(self) -> argparse.Namespace: + """ + parse is a wrapper to call parse_args() and do some validation + """ + # Set AWS as the default provider if no provider is supplied + if len(sys.argv) == 1: + sys.argv = self.__set_default_provider__(sys.argv) + + # Help and Version flags cannot set a default provider + if ( + len(sys.argv) >= 2 + and (sys.argv[1] not in ("-h", "--help")) + and (sys.argv[1] not in ("-v", "--version")) + ): + # Since the provider is always the second argument, we are checking if + # a flag, starting by "-", is supplied + if "-" in sys.argv[1]: + sys.argv = self.__set_default_provider__(sys.argv) + + # Parse arguments + args = self.parser.parse_args() + + # A provider is always required + if not args.provider: + self.parser.error( + "A provider is required to see its specific help options." + ) + + return args + + def __set_default_provider__(self, args: list) -> list: + default_args = [args[0]] + provider = "aws" + default_args.append(provider) + default_args.extend(args[1:]) + # Save the arguments with the default provider included + return default_args + def __init_allowlist_parser__(self): # Allowlist allowlist_parser = self.common_providers_parser.add_argument_group("Allowlist") @@ -232,7 +272,7 @@ class ProwlerArgumentParser: help="AWS region names to run Prowler against", ) # AWS Organizations - aws_orgs_subparser = aws_parser.add_argument_group("Organizations") + aws_orgs_subparser = aws_parser.add_argument_group("AWS Organizations") aws_orgs_subparser.add_argument( "-O", "--organizations-role", @@ -240,7 +280,7 @@ class ProwlerArgumentParser: help="Specify AWS Organizations management role ARN to be assumed, to get Organization metadata", ) # AWS Security Hub - aws_security_hub_subparser = aws_parser.add_argument_group("Security Hub") + aws_security_hub_subparser = aws_parser.add_argument_group("AWS Security Hub") aws_security_hub_subparser.add_argument( "-S", "--security-hub", diff --git a/prowler/providers/common/audit_info.py b/prowler/providers/common/audit_info.py index 83065937..80f0ddba 100644 --- a/prowler/providers/common/audit_info.py +++ b/prowler/providers/common/audit_info.py @@ -101,7 +101,6 @@ Caller Identity ARN: {Fore.YELLOW}[{audit_info.audited_identity_arn}]{Style.RESE input_role = arguments.get("role") input_session_duration = arguments.get("session_duration") input_external_id = arguments.get("external_id") - print(input_session_duration) if input_session_duration and input_session_duration not in range(900, 43200): raise Exception("Value for -T option must be between 900 and 43200") diff --git a/pyproject.toml b/pyproject.toml index 96cce0de..d52cc579 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta" [project] name = "prowler-cloud" # https://peps.python.org/pep-0440/ -version = "3.0.0-rc1" +version = "3.0.0" authors = [{ name = "Toni de la Fuente", email = "toni@blyx.com" }] maintainers = [ { name = "Sergio Garcia", email = "sergio@verica.io" }, @@ -44,7 +44,7 @@ dependencies = [ [project.urls] "Homepage" = "https://github.com/prowler-cloud/prowler" -"Documentation" = "https://github.com/prowler-cloud/prowler/blob/master/README.md" +"Documentation" = "https://docs.prowler.cloud" "Issue tracker" = "https://github.com/prowler-cloud/prowler/issues" "Changelog" = "https://github.com/prowler-cloud/prowler/releases"