From 9daec2a515aee68a89193b78f0a4dad19566b2dd Mon Sep 17 00:00:00 2001 From: Dirk Date: Wed, 1 Nov 2017 09:58:52 +0100 Subject: [PATCH] Add "auto" keyword to -oA/-oa (FIX #887) File names are now auto-generated by using "-oA auto" / -oa "auto" --similar to --csv and friends. Also the formerly hidden switches --outFile and --outfile were added in the help and in the manual. --- doc/testssl.1 | 7 +++++-- doc/testssl.1.md | 4 +++- testssl.sh | 37 +++++++++++++++++++++++-------------- 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/doc/testssl.1 b/doc/testssl.1 index 9b2e779..89058bc 100644 --- a/doc/testssl.1 +++ b/doc/testssl.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "TESTSSL" "1" "October 2017" "" "" +.TH "TESTSSL" "1" "November 2017" "" "" . .SH "NAME" \fBtestssl\fR @@ -393,7 +393,10 @@ whole 9 yards \fB\-\-htmlfile \fR or \fB\-oH \fR Similar to the aforementioned \fB\-\-jsonfile\fR or \fB\-\-logfile\fR it logs the output in HTML format (see \fB\-\-html\fR) additionally into a file or a directory\. For further explanation see \fB\-\-jsonfile\fR or \fB\-\-logfile\fR\. \fBHTMLFILE\fR is the variable you need to set if you prefer to work with environment variables instead\. . .P -\fB\-oA \fR / \fB\-oa \fR Similar to nmap it does a file output to all available file formats: LOG,JSON,CSV,HTML\. \fB\-oA\fR does JSON pretty, \fB\-oa\fR flat JSON +\fB\-oA \fR / \fB\-\-outFile \fR Similar to nmap it does a file output to all available file formats: LOG,JSON pretty,CSV,HTML\. If the filename supplied is equal \fBauto\fR the filename is automatically generated using \'\e${NODE}\-p${port}\e${YYYYMMDD\-HHMM}\.\e${EXT}\' with the according extension\. +. +.P +\fB\-oa \fR / \fB\-\-outfile \fR Does the same as the previous option but uses flat JSON instead\. . .P \fB\-\-hints\fR This option is not in use yet\. This option is meant to give hints how to fix a finding or at least a help to improve something\. GIVE_HINTS is the environment variable for this\. diff --git a/doc/testssl.1.md b/doc/testssl.1.md index b491f0f..0ca3b99 100644 --- a/doc/testssl.1.md +++ b/doc/testssl.1.md @@ -266,7 +266,9 @@ The same can be achieved by setting the environment variable `WARNINGS`. `--htmlfile ` or `-oH ` Similar to the aforementioned `--jsonfile` or `--logfile` it logs the output in HTML format (see `--html`) additionally into a file or a directory. For further explanation see `--jsonfile` or `--logfile`. `HTMLFILE` is the variable you need to set if you prefer to work with environment variables instead. -`-oA ` / `-oa ` Similar to nmap it does a file output to all available file formats: LOG,JSON,CSV,HTML. `-oA` does JSON pretty, `-oa` flat JSON +`-oA ` / `--outFile ` Similar to nmap it does a file output to all available file formats: LOG,JSON pretty,CSV,HTML. If the filename supplied is equal `auto` the filename is automatically generated using '\${NODE}-p${port}\${YYYYMMDD-HHMM}.\${EXT}' with the according extension. + +`-oa ` / `--outfile ` Does the same as the previous option but uses flat JSON instead. `--hints` This option is not in use yet. This option is meant to give hints how to fix a finding or at least a help to improve something. GIVE_HINTS is the environment variable for this. diff --git a/testssl.sh b/testssl.sh index 04cfe47..89697c6 100755 --- a/testssl.sh +++ b/testssl.sh @@ -12697,11 +12697,11 @@ file output options (can also be preset via environment variables) --jsonfile|-oj additional output to the specified flat JSON file or directory, similar to --logfile --json-pretty additional JSON structured output of findings to a file '\${NODE}-p\${port}\${YYYYMMDD-HHMM}.json' in cwd --jsonfile-pretty|-oJ additional JSON structured output to the specified file or directory, similar to --logfile - --csv additional output of findings to CSV file '\${NODE}-p${port}\${YYYYMMDD-HHMM}.csv' in cwd or directory + --csv additional output of findings to CSV file '\${NODE}-p\${port}\${YYYYMMDD-HHMM}.csv' in cwd or directory --csvfile|-oC additional output as CSV to the specified file or directory, similar to --logfile - --html additional output as HTML to file '\${NODE}-p${port}\${YYYYMMDD-HHMM}.html' + --html additional output as HTML to file '\${NODE}-p\${port}\${YYYYMMDD-HHMM}.html' --htmlfile|-oH additional output as HTML to the specifed file or directory, similar to --logfile - -oa/-oA similar to nmap it outputs a LOG,JSON,CSV,HTML file. -oA: JSON pretty, -oa: flat JSON + --out(f,F)ile|-oa/-oA log to a LOG,JSON,CSV,HTML file (see nmap). -oA/-oa: pretty/flat JSON. "auto" uses '\${NODE}-p\${port}\${YYYYMMDD-HHMM}' --hints additional hints to findings --severity severities with lower level will be filtered for CSV+JSON, possible values --append if , , or exists rather append then overwrite. Omits any header @@ -14291,6 +14291,10 @@ create_cmd_line_string() { } parse_cmd_line() { + local outfile_arg="" + local cipher_mapping + local -i retvat=0 + CMDLINE="$(create_cmd_line_string "${CMDLINE_ARRAY[@]}")" # Show usage if no options were specified @@ -14620,22 +14624,28 @@ parse_cmd_line() { [[ $? -eq 0 ]] && shift do_html=true ;; - --outFile|--outFile|-oa|-oa=*) - HTMLFILE="$(parse_opt_equal_sign "$1" "$2").html" - CSVFILE="$(parse_opt_equal_sign "$1" "$2").csv" - JSONFILE="$(parse_opt_equal_sign "$1" "$2").json" - LOGFILE="$(parse_opt_equal_sign "$1" "$2").log" + --outfile|--outfile|-oa|-oa=*) + outfile_arg="$(parse_opt_equal_sign "$1" "$2")" + if [[ "$outfile_arg" != "auto" ]]; then + HTMLFILE="$outfile_arg.html" + CSVFILE="$outfile_arg.csv" + JSONFILE="$outfile_arg.json" + LOGFILE="$outfile_arg.log" + fi [[ $? -eq 0 ]] && shift do_html=true do_json=true do_csv=true do_logging=true ;; - --outfile|--outfile|-oA|-oA=*) - HTMLFILE="$(parse_opt_equal_sign "$1" "$2").html" - CSVFILE="$(parse_opt_equal_sign "$1" "$2").csv" - JSONFILE="$(parse_opt_equal_sign "$1" "$2").json" - LOGFILE="$(parse_opt_equal_sign "$1" "$2").log" + --outFile|--outFile|foA|-oA=*) + outfile_arg="$(parse_opt_equal_sign "$1" "$2")" + if [[ "$outfile_arg" != "auto" ]]; then + HTMLFILE="$outfile_arg.html" + CSVFILE="$outfile_arg.csv" + JSONFILE="$outfile_arg.json" + LOGFILE="$outfile_arg.log" + fi [[ $? -eq 0 ]] && shift do_html=true do_pretty_json=true @@ -14654,7 +14664,6 @@ parse_cmd_line() { [[ $? -eq 0 ]] && shift ;; --mapping|--mapping=*) - local cipher_mapping cipher_mapping="$(parse_opt_equal_sign "$1" "$2")" [[ $? -eq 0 ]] && shift case "$cipher_mapping" in