mirror of
https://github.com/drwetter/testssl.sh.git
synced 2025-01-03 23:39:45 +01:00
Beautify and simplify the code
This commit is contained in:
parent
c38a1e6896
commit
bdbc194491
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
# Just a functional test, whether there are any problems on the client side
|
# Just a functional test, whether there are any problems on the client side
|
||||||
# Probably we could also inspect the JSON for any problems for
|
# Probably we could also inspect the JSON for any problems for
|
||||||
# "id" : "scanProblem"
|
# "id" : "scanProblem"
|
||||||
# "finding" : "Scan interrupted"
|
# "finding" : "Scan interrupted"
|
||||||
|
|
||||||
@ -12,59 +12,54 @@ use JSON;
|
|||||||
|
|
||||||
my $tests = 0;
|
my $tests = 0;
|
||||||
my $check2run ="--client-simulation -q --ip=one --color 0";
|
my $check2run ="--client-simulation -q --ip=one --color 0";
|
||||||
|
my $uri="";
|
||||||
|
my $socketout="";
|
||||||
|
my $opensslout="";
|
||||||
|
|
||||||
|
# $check2run="--jsonfile tmp.json $check2run";
|
||||||
|
|
||||||
|
|
||||||
|
$uri="google.com";
|
||||||
|
|
||||||
unlink "tmp.json";
|
unlink "tmp.json";
|
||||||
printf "\n%s\n", "Running socket based client simulations against google.com ...";
|
printf "\n%s\n", "Client simulations unit test via sockets --> $uri ...";
|
||||||
# $tests++;
|
$socketout = `./testssl.sh $check2run $uri`;
|
||||||
my $socketout = `./testssl.sh $check2run --jsonfile tmp.json google.com`;
|
# my $socket = json('tmp.json');
|
||||||
my $socket = json('tmp.json');
|
|
||||||
#FIXME: This comparison is maybe not sufficient yet:
|
#FIXME: This comparison is maybe not sufficient yet:
|
||||||
unlike($socketout, qr/(e|E)rror|(f|F)atal/, "");
|
unlike($socketout, qr/(e|E)rror|(f|F)atal/, "");
|
||||||
$tests++;
|
$tests++;
|
||||||
|
|
||||||
|
|
||||||
unlink "tmp.json";
|
unlink "tmp.json";
|
||||||
printf "\n%s\n", "Running OpenSSL based client simulations against google.com ...";
|
printf "\n%s\n", "Client simulations unit test via OpenSSL --> $uri ...";
|
||||||
# $tests++;
|
$opensslout = `./testssl.sh $check2run --ssl-native $uri`;
|
||||||
my $opensslout = `./testssl.sh $check2run --ssl-native --jsonfile tmp.json google.com`;
|
# my $openssl = json('tmp.json');
|
||||||
my $openssl = json('tmp.json');
|
|
||||||
#FIXME: This comparison is maybe sufficient yet:
|
#FIXME: This comparison is maybe sufficient yet:
|
||||||
unlike($opensslout, qr/(e|E)rror|(f|F)atal|Oops|s_client connect problem/, "");
|
unlike($opensslout, qr/(e|E)rror|(f|F)atal|Oops|s_client connect problem/, "");
|
||||||
$tests++;
|
$tests++;
|
||||||
|
|
||||||
|
|
||||||
|
$uri="smtp-relay.gmail.com:587";
|
||||||
|
|
||||||
unlink "tmp.json";
|
unlink "tmp.json";
|
||||||
printf "\n%s\n", "STARTTLS: Running socket based client simulations against smtp-relay.gmail.com:587 ...";
|
printf "\n%s\n", "STARTTLS: Client simulations unit test via sockets --> $uri ...";
|
||||||
# $tests++;
|
$socketout = `./testssl.sh $check2run -t smtp $uri`;
|
||||||
my $socketout = `./testssl.sh $check2run --jsonfile tmp.json -t smtp smtp-relay.gmail.com:587`;
|
# my $socket = json('tmp.json');
|
||||||
my $socket = json('tmp.json');
|
|
||||||
unlike($socketout, qr/(e|E)rror|(f|F)atal/, "");
|
unlike($socketout, qr/(e|E)rror|(f|F)atal/, "");
|
||||||
$tests++;
|
$tests++;
|
||||||
|
|
||||||
|
|
||||||
unlink "tmp.json";
|
unlink "tmp.json";
|
||||||
printf "\n%s\n", "STARTTLS: Running OpenSSL based client simulations against smtp-relay.gmail.com:587 ...";
|
printf "\n%s\n", "STARTTLS: Client simulations unit test via OpenSSL --> $uri ...";
|
||||||
# $tests++;
|
$opensslout = `./testssl.sh --ssl-native $check2run -t smtp $uri`;
|
||||||
my $opensslout = `./testssl.sh --ssl-native $check2run --jsonfile tmp.json -t smtp smtp-relay.gmail.com:587`;
|
# my $openssl = json('tmp.json');
|
||||||
my $openssl = json('tmp.json');
|
|
||||||
unlike($opensslout, qr/(e|E)rror|(f|F)atal|Oops|s_client connect problem/, "");
|
unlike($opensslout, qr/(e|E)rror|(f|F)atal|Oops|s_client connect problem/, "");
|
||||||
$tests++;
|
$tests++;
|
||||||
|
|
||||||
#my $i = 0;
|
|
||||||
#foreach my $o ( @$openssl ) {
|
|
||||||
# my $s = $$socket[$i];
|
|
||||||
# if ( $o->{id} =~ /^client_/ ) {
|
|
||||||
# pass("Comparing $o->{id}"); $tests++;
|
|
||||||
# cmp_ok($o->{id}, "eq", $s->{id}, "Id's match"); $tests++;
|
|
||||||
# cmp_ok($o->{severity}, "eq", $s->{severity}, "Severities match"); $tests++;
|
|
||||||
# cmp_ok($o->{finding}, "eq", $s->{finding}, "Findings match"); $tests++;
|
|
||||||
# }
|
|
||||||
# $i++;
|
|
||||||
#}
|
|
||||||
|
|
||||||
done_testing($tests);
|
done_testing($tests);
|
||||||
unlink "tmp.json";
|
unlink "tmp.json";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sub json($) {
|
sub json($) {
|
||||||
my $file = shift;
|
my $file = shift;
|
||||||
$file = `cat $file`;
|
$file = `cat $file`;
|
||||||
|
Loading…
Reference in New Issue
Block a user