Skip to content

Commit

Permalink
Fixed crash when running with '-P' and '-T' options simultaneously. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jtesta committed Jul 3, 2024
1 parent 87e22ae commit dcbc43a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ For convenience, a web front-end on top of the command-line tool is available at
### v3.3.0-dev (???)
- Added built-in policies for Ubuntu 24.04 LTS server and client.
- Added IPv6 support for DHEat and connection rate tests.
- Fixed crash when running with `-P` and `-T` options simultaneously.

### v3.2.0 (2024-04-22)
- Added implementation of the DHEat denial-of-service attack (see `--dheat` option; [CVE-2002-20001](https://nvd.nist.gov/vuln/detail/CVE-2002-20001)).
Expand Down
26 changes: 26 additions & 0 deletions src/ssh_audit/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,3 +605,29 @@ def __str__(self) -> str:
dh_modulus_sizes_str = str(self._dh_modulus_sizes)

return "Name: %s\nVersion: %s\nAllow Algorithm Subset and/or Reordering: %r\nBanner: %s\nCompressions: %s\nHost Keys: %s\nOptional Host Keys: %s\nKey Exchanges: %s\nCiphers: %s\nMACs: %s\nHost Key Sizes: %s\nDH Modulus Sizes: %s\nServer Policy: %r" % (name, version, self._allow_algorithm_subset_and_reordering, banner, compressions_str, host_keys_str, optional_host_keys_str, kex_str, ciphers_str, macs_str, hostkey_sizes_str, dh_modulus_sizes_str, self._server_policy)


def __getstate__(self) -> Dict[str, Any]:
'''Called when pickling this object. The file descriptor isn't serializable, so we'll remove it from the state and include a string representation.'''

state = self.__dict__.copy()

if state['_warning_target'] == sys.stdout:
state['_warning_target_type'] = 'stdout'
else:
state['_warning_target_type'] = 'stderr'

del state['_warning_target']
return state


def __setstate__(self, state: Dict[str, Any]) -> None:
'''Called when unpickling this object. Based on the string representation of the file descriptor, we'll restore the right handle.'''

if state['_warning_target_type'] == 'stdout':
state['_warning_target'] = sys.stdout
else:
state['_warning_target'] = sys.stderr

del state['_warning_target_type']
self.__dict__.update(state)

0 comments on commit dcbc43a

Please sign in to comment.