diff --git a/MANUAL.md b/MANUAL.md index 161ed99349..cc66388b4a 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -35,7 +35,7 @@ Possible output levels: -q, --quiet suppress output -l {debug,info,warning,error,critical}, --log {debug,info,warning,error,critical} log level - -o {csv,json,console}, --output {csv,json,console} + -o OUTPUT_FILE, --output-file OUTPUT_FILE update output format (default: console) -f FILENAME, --filename FILENAME provide output file name @@ -171,6 +171,16 @@ This option controls the frequency of updates for the CVE data from the National Output modes ------------ +### -o OUTPUT_FILE, --output-file OUTPUT_FILE + +This option allows you to specify the filename for the report, rather than having CVE Binary Tool generate it by itself. + +### -f {csv,json,console}, --format {csv,json,console} + +This option allows the CVE Binary Tool to produce a report in an alternate format. This is useful if you have other tools which only take a specific format. + +### Output verbosity + The tool has several different output modes, from most information to least as follows: 1. Regular mode (no flag) prints only the final summary of findings diff --git a/cve_bin_tool/OutputEngine.py b/cve_bin_tool/OutputEngine.py index 61c0e2d6ff..1c6ecae111 100644 --- a/cve_bin_tool/OutputEngine.py +++ b/cve_bin_tool/OutputEngine.py @@ -70,7 +70,6 @@ def output_file(self, output="csv"): if self.filename == None: self.generate_filename(output) else: - self.filename = f"{self.filename}.{output}" # check if the filename already exists file_list = os.listdir(os.getcwd()) if self.filename in file_list: diff --git a/cve_bin_tool/cli.py b/cve_bin_tool/cli.py index 5ec8e6ca9e..eb09a0c310 100755 --- a/cve_bin_tool/cli.py +++ b/cve_bin_tool/cli.py @@ -329,18 +329,18 @@ def main(argv=None, outfile=sys.stdout): ) output_group.add_argument( "-o", - "--output", + "--output-file", action="store", - choices=["csv", "json", "console"], - default="console", - help="update output format (default: console)", + default=None, + help="provide output filename", ) output_group.add_argument( "-f", - "--filename", + "--format", action="store", - default=None, - help="provide output file name", + choices=["csv", "json", "console"], + default="console", + help="update output format (default: console)", ) parser.add_argument( "-v", "--version", action="version", version=f"{get_version_string()}", @@ -484,16 +484,18 @@ def main(argv=None, outfile=sys.stdout): LOGGER.info(f"Known CVEs in {affected_string}:") # Creates a Object for OutputEngine - output = OutputEngine(modules=scanner.all_cves, filename=args.filename) + output = OutputEngine( + modules=scanner.all_cves, filename=args.output_file + ) if ( LOGGER.getEffectiveLevel() != logging.CRITICAL - and args.output == "console" + and args.format == "console" ): output.output_cves(outfile) else: # If the args are passed for csv/json we will generate a file output - output.output_file(args.output) + output.output_file(args.format) # Use the number of files with known cves as error code # as requested by folk planning to automate use of this script.