Massing testing with command line error

There is a bug in testssl.sh that occurs if mass testing is being performed, there is an error in the command line for one of the child tests, and either a single HTML file or a single JSON file is being created.

If mass testing is being performed and `parse_cmd_line()` detects an error in the command line for one of the child tests, then it will call `help()`, which will exit the program, resulting in `cleanup ()` being called. `cleanup ()` will call `html_footer()` and `fileout_footer()`. Since `html_header()` and `json_header()` have not yet been called, `$HTMLHEADER` and `$JSONHEADER` will both be `true, and so `html_footer()` and `fileout_footer()` will output HTML and JSON footers, even though no headers have been output.

This PR fixes the problem by having `help()` set `$HTMLHEADER` and `$JSONHEADER` to `false` so that no HTML or JSON footers are created.

A related problem is that if a single JSON file is being created, the parent process will insert a separator (a comma) into the JSON file between the outputs of each child process. However, if there is an error in one of the child process's command lines, then this child process will not produce any JSON output and so the JSON file will have two consecutive separators (commas), which is invalid according to http://jsonlint.com.

This PR provides a partial fix for the problem for parallel mass testing by checking whether a child process has created a non-empty JSON output before adding a separator to the JSON file. It leaves two unresolved problems:

* It does not fix the problem at all for `run_mass_testing()`, where the separator is added before the test with the command line error is run.

* It does not fix the problem for parallel mass testing for the case in which the first child test has a command line error.
This commit is contained in:
David Cooper 2017-05-22 16:57:15 -04:00 committed by GitHub
parent 26bf3300e8
commit 1311fe595b
1 changed files with 9 additions and 2 deletions

View File

@ -340,7 +340,7 @@ set_severity_level() {
SEVERITY_LEVEL=$CRITICAL
else
echo "Supported severity levels are LOW, MEDIUM, HIGH, CRITICAL!"
help
help 1
fi
}
@ -11180,6 +11180,10 @@ Options requiring a value can also be called with '=' e.g. testssl.sh -t=smtp --
URI always needs to be the last parameter.
EOF
# Set HTMLHEADER and JSONHEADER to false so that the cleanup() function won't
# try to write footers to the HTML and JSON files.
HTMLHEADER=false
JSONHEADER=false
#' Fix syntax highlight on sublime
exit $1
}
@ -12293,7 +12297,10 @@ get_next_message_testing_parallel_result() {
outln "${PARALLEL_TESTING_CMDLINE[NEXT_PARALLEL_TEST_TO_FINISH]}"
if [[ "$1" == "completed" ]]; then
cat "$TEMPDIR/term_output_$(printf "%08d" $NEXT_PARALLEL_TEST_TO_FINISH).log"
[[ $NEXT_PARALLEL_TEST_TO_FINISH -gt 0 ]] && fileout_separator # this is needed for appended output, see #687
if [[ $NEXT_PARALLEL_TEST_TO_FINISH -gt 0 ]] && "$JSONHEADER" && \
[[ -s "$TEMPDIR/jsonfile_$(printf "%08d" $NEXT_PARALLEL_TEST_TO_FINISH).json" ]]; then
fileout_separator # this is needed for appended output, see #687
fi
"$JSONHEADER" && cat "$TEMPDIR/jsonfile_$(printf "%08d" $NEXT_PARALLEL_TEST_TO_FINISH).json" >> "$JSONFILE"
"$CSVHEADER" && cat "$TEMPDIR/csvfile_$(printf "%08d" $NEXT_PARALLEL_TEST_TO_FINISH).csv" >> "$CSVFILE"
"$HTMLHEADER" && cat "$TEMPDIR/htmlfile_$(printf "%08d" $NEXT_PARALLEL_TEST_TO_FINISH).html" >> "$HTMLFILE"