From 83f9e48271afcd79ec48f90ad43953a771b7f0b6 Mon Sep 17 00:00:00 2001 From: thecliguy Date: Tue, 20 Jun 2023 21:09:37 +0100 Subject: [PATCH] Recommendation output now respects level (#196) --- src/ssh_audit/ssh_audit.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/ssh_audit/ssh_audit.py b/src/ssh_audit/ssh_audit.py index 465a1b1..0a9c84c 100755 --- a/src/ssh_audit/ssh_audit.py +++ b/src/ssh_audit/ssh_audit.py @@ -379,6 +379,12 @@ def output_recommendations(out: OutputBuffer, algs: Algorithms, algorithm_recomm ret = False return ret + level_to_output = { + "informational": out.good, + "warning": out.warn, + "critical": out.fail + } + with out: recommendations = get_algorithm_recommendations(algs, algorithm_recommendation_suppress_list, software, for_server=True) @@ -391,15 +397,15 @@ def output_recommendations(out: OutputBuffer, algs: Algorithms, algorithm_recomm p = '' if out.batch else ' ' * (padlen - len(name)) + fn = level_to_output[level] + if action == 'del': - an, sg, fn = 'remove', '-', out.warn + an, sg = 'remove', '-' ret = False - if level == 'critical': - fn = out.fail elif action == 'add': - an, sg, fn = 'append', '+', out.good + an, sg = 'append', '+' elif action == 'chg': - an, sg, fn = 'change', '!', out.fail + an, sg = 'change', '!' ret = False if notes != '':