From a861fe0c8ab47fac6b0e3c16c6ed8dea3b463602 Mon Sep 17 00:00:00 2001 From: Andris Raugulis Date: Sat, 17 Sep 2016 00:30:04 +0300 Subject: [PATCH] Since text could be empty or client-only. --- ssh-audit.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ssh-audit.py b/ssh-audit.py index 09206ec..88a8c91 100755 --- a/ssh-audit.py +++ b/ssh-audit.py @@ -87,6 +87,7 @@ class AuditConf(object): def ssh2(self, v): self.__ssh2 = v + class Output(object): LEVELS = ['info', 'warn', 'fail'] COLORS = {'head': 36, 'good': 32, 'warn': 33, 'fail': 31} @@ -1046,9 +1047,17 @@ def get_ssh_timeframe(kex): def get_alg_since_text(alg_desc): tv = [] versions = alg_desc[0] + if len(versions) == 0 or versions[0] is None: + return None for v in versions[0].split(','): ssh_prefix, ssh_version = get_ssh_version(v) + if not ssh_version: + continue + if ssh_version.endswith('C'): + ssh_version = '{0} (client only)'.format(ssh_version[:-1]) tv.append('{0} {1}'.format(ssh_prefix, ssh_version)) + if len(tv) == 0: + return None return 'available since ' + ', '.join(tv).rstrip(', ') @@ -1073,7 +1082,9 @@ def output_algorithm(alg_type, alg_name, alg_max_len=0): ldesc = len(alg_desc) for idx, level in enumerate(['fail', 'warn', 'info']): if level == 'info': - texts.append((level, get_alg_since_text(alg_desc))) + since_text = get_alg_since_text(alg_desc) + if since_text: + texts.append((level, since_text)) idx = idx + 1 if ldesc > idx: for t in alg_desc[idx]: