feat(exit_code 3): add -z option (#1848)

Co-authored-by: sergargar <sergargar@users.noreply.github.com>
This commit is contained in:
Sergio Garcia
2023-02-07 09:51:46 +01:00
committed by GitHub
parent 13316b68aa
commit ed54c5b8b9
3 changed files with 20 additions and 0 deletions

View File

@@ -219,6 +219,10 @@ def prowler():
audit_output_options.output_directory,
)
# If there are failed findings exit code 3, except if -z is input
if not args.ignore_exit_code_3 and stats["total_fail"] > 0:
sys.exit(3)
if __name__ == "__main__":
prowler()

View File

@@ -138,6 +138,12 @@ Detailed documentation at https://docs.prowler.cloud
action="store_true",
help="Display detailed information about findings",
)
common_outputs_parser.add_argument(
"-z",
"--ignore-exit-code-3",
action="store_true",
help="Failed checks do not trigger exit code 3",
)
common_outputs_parser.add_argument(
"-b", "--no-banner", action="store_true", help="Hide Prowler banner"
)

View File

@@ -146,6 +146,16 @@ class Test_Parser:
parsed = self.parser.parse(command)
assert parsed.quiet
def test_root_parser_exit_code_3_short(self):
command = [prowler_command, "-z"]
parsed = self.parser.parse(command)
assert parsed.ignore_exit_code_3
def test_root_parser_exit_code_3_long(self):
command = [prowler_command, "--ignore-exit-code-3"]
parsed = self.parser.parse(command)
assert parsed.ignore_exit_code_3
def test_root_parser_default_output_modes(self):
command = [prowler_command]
parsed = self.parser.parse(command)