@@ -20,7 +20,9 @@ def nagios_exit(message, code):
20
20
'CRITICAL' : 4 ,
21
21
}
22
22
try :
23
- parser = argparse .ArgumentParser (description = 'Check output of testssl.sh' )
23
+ parser = argparse .ArgumentParser (description = 'Test support of TLS/SSL ciphers, '
24
+ 'protocols as well as cryptographic flaws and much more. This is a wrapper '
25
+ 'around testssl.sh (https://github.com/drwetter/testssl.sh' )
24
26
parser .add_argument ('--uri' , help = 'host|host:port|URL|URL:port.'
25
27
'Port 443 is default, URL can only contain HTTPS protocol' , required = True )
26
28
parser .add_argument ('--testssl' , help = 'Path to the testssl.sh script' , required = True )
@@ -29,12 +31,13 @@ def nagios_exit(message, code):
29
31
choices = severities .keys (), default = 'CRITICAL' )
30
32
parser .add_argument ('--warning' , help = 'Findings of this severity level trigger a WARNING' ,
31
33
choices = severities .keys (), default = 'HIGH' )
32
- # FIXME this is unreliable
33
- #parser.add_argument('trailing_args ', nargs=argparse.REMAINDER)
34
+ parser . add_argument ( 'trailing_args' , help = 'Provide extra arguments to testssl.sh at the end, '
35
+ 'separated by \' -- \' ' , nargs = argparse .REMAINDER )
34
36
args = parser .parse_args ()
35
37
36
38
if severities [args .critical ] < severities [args .warning ]:
37
- parser .error ('The severity level to raise a WARNING can not be higher than the level to raise a CRITICAL' )
39
+ parser .error ('The severity level to raise a WARNING can not be higher'
40
+ 'than the level to raise a CRITICAL' )
38
41
39
42
if urlparse (args .uri ).scheme != 'https' :
40
43
parser .error ('The scheme of the URI must be \' https\' ' )
@@ -44,8 +47,7 @@ def nagios_exit(message, code):
44
47
critical = args .critical
45
48
warning = args .warning
46
49
ignore_ids = args .ignore_ids .split (',' )
47
- # trailing_args = args.trailing_args
48
- # pprint(args)
50
+ trailing_args = args .trailing_args
49
51
50
52
51
53
# Possible nagios statuses
@@ -62,17 +64,19 @@ def nagios_exit(message, code):
62
64
# Set command and arguments
63
65
subproc_args = [
64
66
testssl ,
65
- # '--fast',
66
67
'--jsonfile-pretty' ,
67
68
temp_path ,
68
- uri
69
69
]
70
70
71
- # FIXME this is unreliable
72
- # Inject this script's trailing command line arguments before the 'uri' part of
73
- # the testssl.sh command.
74
- # for extra in trailing_args:
75
- # subproc_args.insert(3, extra)
71
+ # Remove '--' separator from the trailing arguments
72
+ trailing_args .remove ('--' )
73
+
74
+ # Add the trailing arguments
75
+ subproc_args .extend (trailing_args )
76
+
77
+ # Add the URI as the last argument
78
+ subproc_args .extend ([uri ])
79
+
76
80
77
81
# Run it
78
82
proc = subprocess .run (subproc_args , stdout = subprocess .PIPE )
0 commit comments