@@ -5,33 +5,39 @@ use Test::More;
55use Data::Dumper;
66use JSON;
77
8- my (
9- $out ,
10- $json ,
11- $json_pretty ,
12- $found ,
13- $tests
14- );
8+ my $tests = 0;
9+
1510
16- $tests = 0;
1711
1812my $prg =" ./testssl.sh" ;
13+ my $json =" " ;
14+ my $json_file =" " ;
1915my $check2run = ' -S --beast --sweet32 --breach --beast --lucky13 --rc4 --severity LOW --color 0' ;
2016my $uri = ' badssl.com' ;
17+ my $out =" " ;
18+ my $json_pretty =" " ;
19+ my $found =1;
20+
2121
22- printf " \n %s \n " , " Doing severity level checks" ;
2322
24- die " Unable to open $prg " unless -f $prg ;
25- unlink ' tmp.json' ;
2623
2724# useful against "failed to flush stdout" messages
2825STDOUT -> autoflush(1);
2926
27+ die " Unable to open $prg " unless -f $prg ;
28+
29+ # Provide proper start conditions
30+ $json_file =" tmp.json" ;
31+ unlink $json_file ;
32+
33+ # Title
34+ printf " \n %s \n " , " Doing severity level checks" ;
35+
3036# 1
3137pass(" .. running testssl.sh against $uri to create a JSON report with severity level >= LOW (may take 2~3 minutes)" ); $tests ++;
32- $out = ` $prg $check2run --jsonfile tmp.json $uri ` ;
33- $json = json(' tmp.json ' );
34- unlink ' tmp.json ' ;
38+ $out = ` $prg $check2run --jsonfile $json_file $uri ` ;
39+ $json = json($json_file );
40+ unlink $json_file ;
3541$found = 0;
3642cmp_ok(@$json ,' >' ,0," At least 1 finding is expected" ); $tests ++;
3743foreach my $f ( @$json ) {
@@ -44,9 +50,9 @@ is($found,0,"We should not have any finding with INFO level"); $tests++;
4450
4551# 2
4652pass(" .. running testssl.sh against $uri to create a JSON-PRETTY report with severity level >= LOW (may take 2~3 minutes)" ); $tests ++;
47- $out = ` $prg $check2run --jsonfile-pretty tmp.json $uri ` ;
48- $json_pretty = json(' tmp.json ' );
49- unlink ' tmp.json ' ;
53+ $out = ` $prg $check2run --jsonfile-pretty $json_file $uri ` ;
54+ $json_pretty = json($json_file );
55+ unlink $json_file ;
5056$found = 0;
5157my $vulnerabilities = $json_pretty -> {scanResult }-> [0]-> {vulnerabilities };
5258foreach my $f ( @$vulnerabilities ) {
@@ -57,8 +63,8 @@ foreach my $f ( @$vulnerabilities ) {
5763}
5864is($found ,0," We should not have any finding with INFO level" ); $tests ++;
5965
60- printf " \n " ;
6166done_testing($tests );
67+ printf " \n\n " ;
6268
6369sub json ($) {
6470 my $file = shift ;
@@ -68,5 +74,5 @@ sub json($) {
6874}
6975
7076
71- # vim:ts=5:sw=5:expandtab
77+ # vim:ts=5:sw=5:expandtab
7278
0 commit comments