mirror of
				https://github.com/drwetter/testssl.sh.git
				synced 2025-10-30 21:35:26 +01:00 
			
		
		
		
	Output adjustments closer to a more common format
This commit is contained in:
		| @@ -18,24 +18,25 @@ printf "\n%s\n", "Testing whether just calling \"./testssl.sh\" produces no erro | ||||
| $fileout = `timeout 10 bash ./testssl.sh 2>&1`; | ||||
| my $retval=$?; | ||||
|  | ||||
| unlike($fileout, qr/$error_regexp1/, ""); | ||||
| unlike($fileout, qr/$error_regexp1/, "regex 1"); | ||||
| $tests++; | ||||
|  | ||||
| unlike($fileout, qr/$error_regexp2/, ""); | ||||
| unlike($fileout, qr/$error_regexp2/, "regex 2"); | ||||
| $tests++; | ||||
|  | ||||
| unlike($fileout, qr/$error_regexp3/, ""); | ||||
| unlike($fileout, qr/$error_regexp3/, "regex 3"); | ||||
| $tests++; | ||||
|  | ||||
| unlike($fileout, qr/$error_regexp4/, ""); | ||||
| unlike($fileout, qr/$error_regexp4/, "regex 4"); | ||||
| $tests++; | ||||
|  | ||||
| unlike($fileout, qr/$error_regexp5/, ""); | ||||
| unlike($fileout, qr/$error_regexp5/, "regex 5"); | ||||
| $tests++; | ||||
|  | ||||
| is($retval, 0, "return value should be equal zero: \"$retval\""); | ||||
| $tests++; | ||||
|  | ||||
| printf "\n"; | ||||
| done_testing($tests); | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -21,27 +21,28 @@ printf "\n%s\n", "Testing whether just calling \"./testssl.sh --banner\" produce | ||||
| $fileout = `timeout 10 bash ./testssl.sh --banner 2>&1`; | ||||
| my $retval=$?; | ||||
|  | ||||
| unlike($fileout, qr/$error_regexp1/, ""); | ||||
| unlike($fileout, qr/$error_regexp1/, "regex 1"); | ||||
| $tests++; | ||||
|  | ||||
| unlike($fileout, qr/$error_regexp2/, ""); | ||||
| unlike($fileout, qr/$error_regexp2/, "regex 2"); | ||||
| $tests++; | ||||
|  | ||||
| unlike($fileout, qr/$error_regexp3/, ""); | ||||
| unlike($fileout, qr/$error_regexp3/, "regex 3"); | ||||
| $tests++; | ||||
|  | ||||
| unlike($fileout, qr/$error_regexp4/, ""); | ||||
| unlike($fileout, qr/$error_regexp4/, "regex 4"); | ||||
| $tests++; | ||||
|  | ||||
| unlike($fileout, qr/$error_regexp5/, ""); | ||||
| unlike($fileout, qr/$error_regexp5/, "regex 5"); | ||||
| $tests++; | ||||
|  | ||||
| like($fileout, qr/$good_regexp/, ""); | ||||
| like($fileout, qr/$good_regexp/, "regex positive"); | ||||
| $tests++; | ||||
|  | ||||
| is($retval, 0, "return value should be equal zero: \"$retval\""); | ||||
| $tests++; | ||||
|  | ||||
| printf "\n"; | ||||
| done_testing($tests); | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -14,12 +14,13 @@ my $error_regexp2='client-simulation.txt:'; | ||||
|  | ||||
| printf "\n%s\n", "Testing whether \"~/etc/client-simulation.txt\" isn't broken ..."; | ||||
| $fileout = `bash ./etc/client-simulation.txt 2>&1`; | ||||
| unlike($fileout, qr/$error_regexp1/, ""); | ||||
| unlike($fileout, qr/$error_regexp1/, "regex 1"); | ||||
| $tests++; | ||||
|  | ||||
| unlike($fileout, qr/$error_regexp2/, ""); | ||||
| unlike($fileout, qr/$error_regexp2/, "regex 2"); | ||||
| $tests++; | ||||
|  | ||||
| printf "\n"; | ||||
| done_testing($tests); | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -1,9 +1,12 @@ | ||||
| #!/usr/bin/env perl | ||||
|  | ||||
| use strict; | ||||
| use Test::More tests => 1; | ||||
| use Test::More; | ||||
|  | ||||
| printf "\n%s\n", "Testing whether CA certificates are newer their SPKI hashes \"~/etc/ca_hashes.txt\" ..."; | ||||
|  | ||||
| printf "\n%s\n", "Testing whether CA certificates are newer than \"~/etc/ca_hashes.txt\" ..."; | ||||
| my $newer_bundles=`find etc/*.pem -newer etc/ca_hashes.txt`; | ||||
| is($newer_bundles,"","List of CA bundles newer then etc/ca_hashes.txt should be empty. If not run utils/create_ca_hashes.sh"); | ||||
| is($newer_bundles,"","If there's an output with a *.pem file run \"~/utils/create_ca_hashes.sh\""); | ||||
|  | ||||
| printf "\n"; | ||||
| done_testing; | ||||
|   | ||||
| @@ -21,10 +21,10 @@ die "Unable to open $prg" unless -f $prg; | ||||
|  | ||||
| my $uri="cloudflare.com"; | ||||
|  | ||||
| printf "\n%s", "Unit testing JSON output ..."; | ||||
| printf "\n%s\n", "Unit testing JSON output ..."; | ||||
|  | ||||
| #1 | ||||
| printf "%s\n", ".. plain JSON output --> $uri "; | ||||
| printf "%s\n", ".. plain JSON --> $uri "; | ||||
| $out = `./testssl.sh $check2run --jsonfile tmp.json $uri`; | ||||
| $json = json('tmp.json'); | ||||
| unlink 'tmp.json'; | ||||
| @@ -33,7 +33,7 @@ is(@errors,0,"no errors"); | ||||
| $tests++; | ||||
|  | ||||
| #2 | ||||
| printf "%s\n", ".. pretty JSON output --> $uri "; | ||||
| printf "%s\n", ".. pretty JSON --> $uri "; | ||||
| $out = `./testssl.sh $check2run --jsonfile-pretty tmp.json $uri`; | ||||
| $json = json('tmp.json'); | ||||
| unlink 'tmp.json'; | ||||
| @@ -45,7 +45,7 @@ $tests++; | ||||
| #3 | ||||
| # This testss.sh run deliberately does NOT work as travis-ci.org blocks port 25 egress. | ||||
| # but the output should be fine. The idea is to have a unit test for a failed connection. | ||||
| printf "%s\n", ".. plain JSON output for a failed run '--mx $uri' ..."; | ||||
| printf "%s\n", ".. plain JSON for a failed run: '--mx $uri' ..."; | ||||
| $out = `./testssl.sh --ssl-native --openssl-timeout=10 $check2run --jsonfile tmp.json --mx $uri`; | ||||
| $json = json('tmp.json'); | ||||
| unlink 'tmp.json'; | ||||
| @@ -55,7 +55,7 @@ $tests++; | ||||
|  | ||||
| #4 | ||||
| # Same as above but with pretty JSON | ||||
| printf "%s\n", ".. pretty JSON output for a failed run '--mx $uri' ..."; | ||||
| printf "%s\n", ".. pretty JSON for a failed run '--mx $uri' ..."; | ||||
| $out = `./testssl.sh --ssl-native --openssl-timeout=10 $check2run --jsonfile-pretty tmp.json --mx $uri`; | ||||
| $json = json('tmp.json'); | ||||
| unlink 'tmp.json'; | ||||
| @@ -65,7 +65,7 @@ $tests++; | ||||
|  | ||||
| #5 | ||||
| my $uri = "smtp-relay.gmail.com:587"; | ||||
| printf "%s\n", " .. plain JSON output --> $uri ..."; | ||||
| printf "%s\n", " .. plain JSON and STARTTLS --> $uri ..."; | ||||
| $out = `./testssl.sh  --jsonfile tmp.json $check2run -t smtp $uri`; | ||||
| $json = json('tmp.json'); | ||||
| unlink 'tmp.json'; | ||||
| @@ -73,7 +73,7 @@ unlink 'tmp.json'; | ||||
| is(@errors,0,"no errors"); | ||||
| $tests++; | ||||
|  | ||||
|  | ||||
| printf "\n"; | ||||
| done_testing($tests); | ||||
|  | ||||
| sub json($) { | ||||
|   | ||||
| @@ -18,8 +18,10 @@ my $check2run="--color 0 --htmlfile tmp.html"; | ||||
|  | ||||
| die "Unable to open $prg" unless -f $prg; | ||||
|  | ||||
| printf "\n%s\n", "Doing HTML output checks"; | ||||
|  | ||||
| #1 | ||||
| printf "\n%s\n", "Running $prg against $uri to create HTML and terminal outputs (may take 2~3 minutes) ..."; | ||||
| printf "%s\n", " .. running $prg against $uri to create HTML and terminal outputs (may take 2~3 minutes)"; | ||||
| # specify a TERM_WIDTH so that the two calls to testssl.sh don't create HTML files with different values of TERM_WIDTH | ||||
| $out = `TERM_WIDTH=120 $prg $check2run $uri`; | ||||
| $html = `cat tmp.html`; | ||||
| @@ -41,12 +43,12 @@ $edited_html =~ s/>/>/g; | ||||
| $edited_html =~ s/"/"/g; | ||||
| $edited_html =~ s/'/'/g; | ||||
|  | ||||
| printf "\n%s\n", "Comparing HTML and terminal outputs"; | ||||
| printf "\n%s\n", " .. comparing HTML and terminal outputs"; | ||||
| cmp_ok($edited_html, "eq", $out, "HTML file matches terminal output"); | ||||
| $tests++; | ||||
|  | ||||
| #2 | ||||
| printf "\n%s\n", "Running $prg against $uri with --debug 4 to create HTML output (may take 2~3 minutes)"; | ||||
| printf "\n%s\n", " .. running $prg against $uri with --debug 4 to create HTML output (may take another 2~3 minutes)"; | ||||
| # Redirect stderr to /dev/null in order to avoid some unexplained "date: invalid date" error messages | ||||
| $out = `TERM_WIDTH=120 $prg $check2run --debug 4 $uri 2> /dev/null`; | ||||
| $debughtml = `cat tmp.html`; | ||||
| @@ -66,9 +68,9 @@ $debughtml =~ s/HTTP clock skew              \+?-?[0-9]* /HTTP clock skew | ||||
| $debughtml =~ s/ Pre-test: .*\n//g; | ||||
| $debughtml =~ s/.*OK: below 825 days.*\n//g; | ||||
|  | ||||
| printf "\n%s\n", "Checking that using the --debug option doesn't affect the HTML file"; | ||||
| printf "\n%s\n", " .. checking that using the --debug option doesn't affect the HTML file"; | ||||
| cmp_ok($debughtml, "eq", $html, "HTML file created with --debug 4 matches HTML file created without --debug"); | ||||
| $tests++; | ||||
| printf "\n%s\n"; | ||||
|  | ||||
| printf "\n"; | ||||
| done_testing($tests); | ||||
|   | ||||
| @@ -15,8 +15,11 @@ my ( | ||||
|  | ||||
| $tests = 0; | ||||
|  | ||||
|  | ||||
| printf "\n%s\n", "Doing severity level checks"; | ||||
|  | ||||
| #1 | ||||
| pass("Running testssl.sh against badssl.com to create a JSON report with severity level equal greater than LOW (may take 2~3 minutes)"); $tests++; | ||||
| pass(" .. running testssl.sh against badssl.com to create a JSON report with severity level equal greater than LOW (may take 2~3 minutes)"); $tests++; | ||||
| $out = `./testssl.sh -S -e -U --jsonfile tmp.json --severity LOW --color 0 badssl.com`; | ||||
| $json = json('tmp.json'); | ||||
| unlink 'tmp.json'; | ||||
| @@ -31,7 +34,7 @@ foreach my $f ( @$json ) { | ||||
| is($found,0,"We should not have any finding with INFO level"); $tests++; | ||||
|  | ||||
| #2 | ||||
| pass("Running testssl.sh against badssl.com to create a JSON-PRETTY report with severity level equal greater than LOW (may take 2~3 minutes)"); $tests++; | ||||
| pass(" .. running testssl.sh against badssl.com to create a JSON-PRETTY report with severity level equal greater than LOW (may take 2~3 minutes)"); $tests++; | ||||
| $out = `./testssl.sh -S -e -U --jsonfile-pretty tmp.json --severity LOW --color 0 badssl.com`; | ||||
| $json_pretty = json('tmp.json'); | ||||
| unlink 'tmp.json'; | ||||
| @@ -45,6 +48,7 @@ foreach my $f ( @$vulnerabilities ) { | ||||
| } | ||||
| is($found,0,"We should not have any finding with INFO level"); $tests++; | ||||
|  | ||||
| printf "\n"; | ||||
| done_testing($tests); | ||||
|  | ||||
| sub json($) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Dirk Wetter
					Dirk Wetter