summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2019-06-21 20:41:46 -0400
committerJeff Forcier <jeff@bitprophet.org>2019-06-21 20:41:46 -0400
commitdccc563c3a581a14ceaa261b5fe0d08539f84b87 (patch)
tree9f69145d279208686e39ac69ce988538ae718ac3
parent4aecbe2f9bb150a25e564cc47a556da8849305c6 (diff)
Extend new algorithm disabling to compressions
-rw-r--r--paramiko/transport.py18
-rw-r--r--tests/test_transport.py5
2 files changed, 16 insertions, 7 deletions
diff --git a/paramiko/transport.py b/paramiko/transport.py
index fa3cb661..8919043f 100644
--- a/paramiko/transport.py
+++ b/paramiko/transport.py
@@ -521,6 +521,10 @@ class Transport(threading.Thread, ClosingContextManager):
def preferred_kex(self):
return self._filter_algorithm("kex")
+ @property
+ def preferred_compression(self):
+ return self._filter_algorithm("compression")
+
def __repr__(self):
"""
Returns a string representation of this object, for debugging.
@@ -2283,8 +2287,8 @@ class Transport(threading.Thread, ClosingContextManager):
m.add_list(self.preferred_ciphers)
m.add_list(self.preferred_macs)
m.add_list(self.preferred_macs)
- m.add_list(self._preferred_compression)
- m.add_list(self._preferred_compression)
+ m.add_list(self.preferred_compression)
+ m.add_list(self.preferred_compression)
m.add_string(bytes())
m.add_string(bytes())
m.add_boolean(False)
@@ -2441,13 +2445,13 @@ class Transport(threading.Thread, ClosingContextManager):
if self.server_mode:
agreed_remote_compression = list(
filter(
- self._preferred_compression.__contains__,
+ self.preferred_compression.__contains__,
client_compress_algo_list,
)
)
agreed_local_compression = list(
filter(
- self._preferred_compression.__contains__,
+ self.preferred_compression.__contains__,
server_compress_algo_list,
)
)
@@ -2455,13 +2459,13 @@ class Transport(threading.Thread, ClosingContextManager):
agreed_local_compression = list(
filter(
client_compress_algo_list.__contains__,
- self._preferred_compression,
+ self.preferred_compression,
)
)
agreed_remote_compression = list(
filter(
server_compress_algo_list.__contains__,
- self._preferred_compression,
+ self.preferred_compression,
)
)
if (
@@ -2474,7 +2478,7 @@ class Transport(threading.Thread, ClosingContextManager):
msg.format(
agreed_local_compression,
agreed_remote_compression,
- self._preferred_compression,
+ self.preferred_compression,
)
)
self.local_compression = agreed_local_compression[0]
diff --git a/tests/test_transport.py b/tests/test_transport.py
index 28f30d63..e2174896 100644
--- a/tests/test_transport.py
+++ b/tests/test_transport.py
@@ -1139,8 +1139,12 @@ class AlgorithmDisablingTests(unittest.TestCase):
"macs": ["hmac-md5"],
"keys": ["ssh-dss"],
"kex": ["diffie-hellman-group14-sha256"],
+ "compression": ["zlib"],
},
)
+ # Enable compression cuz otherwise disabling one option for it makes no
+ # sense...
+ t.use_compression(True)
# Effectively a random spot check, but kex init touches most/all of the
# algorithm lists so it's a good spot.
t._send_message = Mock()
@@ -1164,3 +1168,4 @@ class AlgorithmDisablingTests(unittest.TestCase):
assert "hmac-md5" not in macs
assert "ssh-dss" not in server_keys
assert "diffie-hellman-group14-sha256" not in kexen
+ assert "zlib" not in compressions