blob: 00b04a40386e938397abd2a1920ebfcc250f17aa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#!/usr/bin/env perl
use strict;
use Test::More;
use Data::Dumper;
use JSON;
my (
$out,
$json,
$json_pretty,
$found,
$tests
);
$tests = 0;
my $prg="./testssl.sh";
my $check2run = '-S -e --ids-friendly -U --severity LOW --color 0';
my $uri = 'badssl.com';
printf "\n%s\n", "Doing severity level checks";
die "Unable to open $prg" unless -f $prg;
unlink 'tmp.json';
#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';
$found = 0;
cmp_ok(@$json,'>',0,"At least 1 finding is expected"); $tests++;
foreach my $f ( @$json ) {
if ( $f->{severity} eq "INFO" ) {
$found = 1;
last;
}
}
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';
$found = 0;
my $vulnerabilities = $json_pretty->{scanResult}->[0]->{vulnerabilities};
foreach my $f ( @$vulnerabilities ) {
if ( $f->{severity} eq "INFO" ) {
$found = 1;
last;
}
}
is($found,0,"We should not have any finding with INFO level"); $tests++;
printf "\n";
done_testing($tests);
sub json($) {
my $file = shift;
$file = `cat $file`;
unlink $file;
return from_json($file);
}
# vim:ts=5:sw=5:expandtab
|