Skip to content

Commit 1452e4d

Browse files
committed
When running against multiple hosts, now prints each target host regardless of output level.
1 parent 28a1e23 commit 1452e4d

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ For convenience, a web front-end on top of the command-line tool is available at
219219
### v3.4.0-dev
220220
- Added warning to all key exchanges that do not include protections against quantum attacks due to the Harvest Now, Decrypt Later strategy (see https://en.wikipedia.org/wiki/Harvest_now,_decrypt_later).
221221
- Migrated from deprecated `getopt` module to `argparse`; partial credit [oam7575](https://github.com/oam7575).
222+
- When running against multiple hosts, now prints each target host regardless of output level.
222223

223224
### v3.3.0 (2024-10-15)
224225
- Added Python 3.13 support.

src/ssh_audit/outputbuffer.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ def __init__(self, buffer_output: bool = True) -> None:
5454
self.__is_color_supported = ('colorama' in sys.modules) or (os.name == 'posix')
5555
self.line_ended = True
5656

57-
def _print(self, level: str, s: str = '', line_ended: bool = True) -> None:
57+
def _print(self, level: str, s: str = '', line_ended: bool = True, always_print: bool = False) -> None:
5858
'''Saves output to buffer (if in buffered mode), or immediately prints to stdout otherwise.'''
5959

60-
# If we're logging only 'warn' or above, and this is an 'info', ignore message.
61-
if self.get_level(level) < self.__level:
60+
# If we're logging only 'warn' or above, and this is an 'info', ignore message, unless always_print is True (useful for printing informational lines regardless of the level setting).
61+
if (always_print is False) and (self.get_level(level) < self.__level):
6262
return
6363

6464
if self.use_colors and self.colors_supported and len(s) > 0 and level != 'info':
@@ -145,22 +145,22 @@ def head(self, s: str, line_ended: bool = True) -> 'OutputBuffer':
145145
self._print('head', s, line_ended)
146146
return self
147147

148-
def fail(self, s: str, line_ended: bool = True, write_now: bool = False) -> 'OutputBuffer':
149-
self._print('fail', s, line_ended)
148+
def fail(self, s: str, line_ended: bool = True, write_now: bool = False, always_print: bool = False) -> 'OutputBuffer':
149+
self._print('fail', s, line_ended, always_print=always_print)
150150
if write_now:
151151
self.write()
152152
return self
153153

154-
def warn(self, s: str, line_ended: bool = True) -> 'OutputBuffer':
155-
self._print('warn', s, line_ended)
154+
def warn(self, s: str, line_ended: bool = True, always_print: bool = False) -> 'OutputBuffer':
155+
self._print('warn', s, line_ended, always_print=always_print)
156156
return self
157157

158-
def info(self, s: str, line_ended: bool = True) -> 'OutputBuffer':
159-
self._print('info', s, line_ended)
158+
def info(self, s: str, line_ended: bool = True, always_print: bool = False) -> 'OutputBuffer':
159+
self._print('info', s, line_ended, always_print=always_print)
160160
return self
161161

162-
def good(self, s: str, line_ended: bool = True) -> 'OutputBuffer':
163-
self._print('good', s, line_ended)
162+
def good(self, s: str, line_ended: bool = True, always_print: bool = False) -> 'OutputBuffer':
163+
self._print('good', s, line_ended, always_print=always_print)
164164
return self
165165

166166
def sep(self) -> 'OutputBuffer':

src/ssh_audit/ssh_audit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,9 @@ def output(out: OutputBuffer, aconf: AuditConf, banner: Optional[Banner], header
532532
else:
533533
host = '%s:%d' % (aconf.host, aconf.port)
534534

535-
out.good('(gen) target: {}'. format(host))
535+
out.good('(gen) target: {}'. format(host), always_print=True)
536536
if client_audit:
537-
out.good('(gen) client IP: {}'.format(client_host))
537+
out.good('(gen) client IP: {}'.format(client_host), always_print=True)
538538
if len(header) > 0:
539539
out.info('(gen) header: ' + '\n'.join(header))
540540
if banner is not None:

0 commit comments

Comments
 (0)