diff --git a/log4j-finder.py b/log4j-finder.py index c2b6498..8239d55 100755 --- a/log4j-finder.py +++ b/log4j-finder.py @@ -290,6 +290,7 @@ def main(): help="be more quiet, disables banner and summary", ) parser.add_argument("-b", "--no-banner", action="store_true", help="disable banner") + parser.add_argument("-f", "--fail", action="store_true", help="Exit with error status when vulnerability is found") parser.add_argument( "-V", "--version", action="version", version=f"%(prog)s {__version__}" ) @@ -365,6 +366,10 @@ def main(): print_summary(stats) print(f"\nElapsed time: {elapsed:.2f} seconds") + # If we find vulnerabilities and the args -f (or --fail), then exit with a string which cause a error status on the exit. + if args.fail: + if stats["vulnerable"]: + return "Vulnerabilities found." if __name__ == "__main__": try: