From b1d79b6d72e9d8be1e7882f131fcab5052d55707 Mon Sep 17 00:00:00 2001 From: Dirk Date: Fri, 28 Nov 2025 01:21:19 +0100 Subject: [PATCH] change style to be in line w others --- t/33_isJSON_severitylevel_valid.t | 44 ++++++++++++++++++------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/t/33_isJSON_severitylevel_valid.t b/t/33_isJSON_severitylevel_valid.t index 9c50521..a681507 100755 --- a/t/33_isJSON_severitylevel_valid.t +++ b/t/33_isJSON_severitylevel_valid.t @@ -5,33 +5,39 @@ use Test::More; use Data::Dumper; use JSON; -my ( - $out, - $json, - $json_pretty, - $found, - $tests -); +my $tests = 0; + -$tests = 0; my $prg="./testssl.sh"; +my $json=""; +my $json_file=""; my $check2run = '-S --beast --sweet32 --breach --beast --lucky13 --rc4 --severity LOW --color 0'; my $uri = 'badssl.com'; +my $out=""; +my $json_pretty=""; +my $found=1; + -printf "\n%s\n", "Doing severity level checks"; -die "Unable to open $prg" unless -f $prg; -unlink 'tmp.json'; # useful against "failed to flush stdout" messages STDOUT->autoflush(1); +die "Unable to open $prg" unless -f $prg; + +# Provide proper start conditions +$json_file="tmp.json"; +unlink $json_file; + +# Title +printf "\n%s\n", "Doing severity level checks"; + #1 pass(" .. running testssl.sh against $uri to create a JSON report with severity level >= LOW (may take 2~3 minutes)"); $tests++; -$out = `$prg $check2run --jsonfile tmp.json $uri`; -$json = json('tmp.json'); -unlink 'tmp.json'; +$out = `$prg $check2run --jsonfile $json_file $uri`; +$json = json($json_file); +unlink $json_file; $found = 0; cmp_ok(@$json,'>',0,"At least 1 finding is expected"); $tests++; foreach my $f ( @$json ) { @@ -44,9 +50,9 @@ is($found,0,"We should not have any finding with INFO level"); $tests++; #2 pass(" .. running testssl.sh against $uri to create a JSON-PRETTY report with severity level >= LOW (may take 2~3 minutes)"); $tests++; -$out = `$prg $check2run --jsonfile-pretty tmp.json $uri`; -$json_pretty = json('tmp.json'); -unlink 'tmp.json'; +$out = `$prg $check2run --jsonfile-pretty $json_file $uri`; +$json_pretty = json($json_file); +unlink $json_file; $found = 0; my $vulnerabilities = $json_pretty->{scanResult}->[0]->{vulnerabilities}; foreach my $f ( @$vulnerabilities ) { @@ -57,8 +63,8 @@ foreach my $f ( @$vulnerabilities ) { } is($found,0,"We should not have any finding with INFO level"); $tests++; -printf "\n"; done_testing($tests); +printf "\n\n"; sub json($) { my $file = shift; @@ -68,5 +74,5 @@ sub json($) { } -# vim:ts=5:sw=5:expandtab +# vim:ts=5:sw=5:expandtab