mirror of
https://github.com/jtesta/ssh-audit.git
synced 2025-06-23 19:14:32 +02:00
Flake8 fixes (#35)
* Apply Flake8 also on `setup.py` modified: tox.ini * Fix W605 - invalid escape syntax modified: packages/setup.py modified: tox.ini * Update comment about Flake8: W504 W503 and W504 are mutual exclusive - so we have to keep one of them. modified: tox.ini * Fix F841 - variable assigned but never used modified: ssh-audit.py modified: tox.ini * Fix E741 - ambiguous variable name 'l' modified: ssh-audit.py modified: tox.ini * Fix E712 - comparison to False should be 'if cond is False' ... and not 'if conf == False'. modified: ssh-audit.py modified: tox.ini * Fix E711 - comparison to None should be 'if cond is not None' ... and not 'if cond != None'. modified: ssh-audit.py modified: tox.ini * Fix E305 - expected 2 blank lines ... after class or function definition, found 1. modified: ssh-audit.py modified: tox.ini * Fix E303 - too many blank lines modified: ssh-audit.py modified: tox.ini * Fix E303 - too many blank lines modified: ssh-audit.py modified: tox.ini * Fix E301 - expected 1 blank line, found 0 No code change necessary, probably fixed by another commit. modified: tox.ini * Fix E265 - block comment should start with '# ' There is lots of commented out code, which usually should be just deleted. I will keep it for now, as I am not yet very familiar with the code base. modified: ssh-audit.py modified: tox.ini * Fix E261 - at least two spaces before inline comment modified: ssh-audit.py modified: tox.ini * Fix E251 - unexpected spaces around keyword / parameter equals modified: packages/setup.py modified: tox.ini * Fix E231 - missing whitespace after ',' No code change necessary, probably fixed by previous commit. modified: tox.ini * Fix E226 - missing whitespace around arithmetic operator modified: ssh-audit.py modified: tox.ini * Fix W293 - blank line contains whitespace modified: ssh-audit.py modified: tox.ini * Fix E221 - multiple spaces before operator modified: ssh-audit.py modified: tox.ini * Update comment about Flake 8 E241 Lots of data is formatted as tables, so this warning is disabled for a good reason. modified: tox.ini * Fix E401 - multiple imports on one line modified: ssh-audit.py modified: tox.ini * Do not ignore Flake8 warning F401 ... as there were no errors in source code anyway. modified: tox.ini * Fix F821 - undefined name modified: ssh-audit.py modified: tox.ini * Reformat ignore section for Flake8 modified: tox.ini * Flake8 test suite modified: test/conftest.py modified: test/test_auditconf.py modified: test/test_banner.py modified: test/test_buffer.py modified: test/test_errors.py modified: test/test_output.py modified: test/test_resolve.py modified: test/test_socket.py modified: test/test_software.py modified: test/test_ssh1.py modified: test/test_ssh2.py modified: test/test_ssh_algorithm.py modified: test/test_utils.py modified: test/test_version_compare.py modified: tox.ini
This commit is contained in:
@ -8,19 +8,19 @@ class TestVersionCompare(object):
|
||||
@pytest.fixture(autouse=True)
|
||||
def init(self, ssh_audit):
|
||||
self.ssh = ssh_audit.SSH
|
||||
|
||||
|
||||
def get_dropbear_software(self, v):
|
||||
b = self.ssh.Banner.parse('SSH-2.0-dropbear_{0}'.format(v))
|
||||
return self.ssh.Software.parse(b)
|
||||
|
||||
|
||||
def get_openssh_software(self, v):
|
||||
b = self.ssh.Banner.parse('SSH-2.0-OpenSSH_{0}'.format(v))
|
||||
return self.ssh.Software.parse(b)
|
||||
|
||||
|
||||
def get_libssh_software(self, v):
|
||||
b = self.ssh.Banner.parse('SSH-2.0-libssh-{0}'.format(v))
|
||||
return self.ssh.Software.parse(b)
|
||||
|
||||
|
||||
def test_dropbear_compare_version_pre_years(self):
|
||||
s = self.get_dropbear_software('0.44')
|
||||
assert s.compare_version(None) == 1
|
||||
@ -32,7 +32,7 @@ class TestVersionCompare(object):
|
||||
assert s.between_versions('0.43', '0.45')
|
||||
assert s.between_versions('0.43', '0.43') is False
|
||||
assert s.between_versions('0.45', '0.43') is False
|
||||
|
||||
|
||||
def test_dropbear_compare_version_with_years(self):
|
||||
s = self.get_dropbear_software('2015.71')
|
||||
assert s.compare_version(None) == 1
|
||||
@ -44,7 +44,7 @@ class TestVersionCompare(object):
|
||||
assert s.between_versions('2014.66', '2016.74')
|
||||
assert s.between_versions('2014.66', '2015.69') is False
|
||||
assert s.between_versions('2016.74', '2014.66') is False
|
||||
|
||||
|
||||
def test_dropbear_compare_version_mixed(self):
|
||||
s = self.get_dropbear_software('0.53.1')
|
||||
assert s.compare_version(None) == 1
|
||||
@ -56,7 +56,7 @@ class TestVersionCompare(object):
|
||||
assert s.between_versions('0.53', '2011.54')
|
||||
assert s.between_versions('0.53', '0.53') is False
|
||||
assert s.between_versions('2011.54', '0.53') is False
|
||||
|
||||
|
||||
def test_dropbear_compare_version_patchlevel(self):
|
||||
s1 = self.get_dropbear_software('0.44')
|
||||
s2 = self.get_dropbear_software('0.44test3')
|
||||
@ -80,7 +80,7 @@ class TestVersionCompare(object):
|
||||
assert s2.between_versions('0.44', '0.43') is False
|
||||
assert s1.compare_version(s2) > 0
|
||||
assert s2.compare_version(s1) < 0
|
||||
|
||||
|
||||
def test_dropbear_compare_version_sequential(self):
|
||||
versions = []
|
||||
for i in range(28, 44):
|
||||
@ -105,18 +105,18 @@ class TestVersionCompare(object):
|
||||
versions.append('2015.{0}'.format(i))
|
||||
for i in range(72, 75):
|
||||
versions.append('2016.{0}'.format(i))
|
||||
l = len(versions)
|
||||
for i in range(l):
|
||||
length = len(versions)
|
||||
for i in range(length):
|
||||
v = versions[i]
|
||||
s = self.get_dropbear_software(v)
|
||||
assert s.compare_version(v) == 0
|
||||
if i - 1 >= 0:
|
||||
vbefore = versions[i - 1]
|
||||
assert s.compare_version(vbefore) > 0
|
||||
if i + 1 < l:
|
||||
if i + 1 < length:
|
||||
vnext = versions[i + 1]
|
||||
assert s.compare_version(vnext) < 0
|
||||
|
||||
|
||||
def test_openssh_compare_version_simple(self):
|
||||
s = self.get_openssh_software('3.7.1')
|
||||
assert s.compare_version(None) == 1
|
||||
@ -128,7 +128,7 @@ class TestVersionCompare(object):
|
||||
assert s.between_versions('3.7', '3.8')
|
||||
assert s.between_versions('3.6', '3.7') is False
|
||||
assert s.between_versions('3.8', '3.7') is False
|
||||
|
||||
|
||||
def test_openssh_compare_version_patchlevel(self):
|
||||
s1 = self.get_openssh_software('2.1.1')
|
||||
s2 = self.get_openssh_software('2.1.1p2')
|
||||
@ -141,7 +141,7 @@ class TestVersionCompare(object):
|
||||
assert s2.compare_version('2.1.1p3') < 0
|
||||
assert s1.compare_version(s2) == 0
|
||||
assert s2.compare_version(s1) == 0
|
||||
|
||||
|
||||
def test_openbsd_compare_version_sequential(self):
|
||||
versions = []
|
||||
for v in ['1.2.3', '2.1.0', '2.1.1', '2.2.0', '2.3.0']:
|
||||
@ -164,18 +164,18 @@ class TestVersionCompare(object):
|
||||
versions.append('6.{0}'.format(i))
|
||||
for i in range(0, 4):
|
||||
versions.append('7.{0}'.format(i))
|
||||
l = len(versions)
|
||||
for i in range(l):
|
||||
length = len(versions)
|
||||
for i in range(length):
|
||||
v = versions[i]
|
||||
s = self.get_openssh_software(v)
|
||||
assert s.compare_version(v) == 0
|
||||
if i - 1 >= 0:
|
||||
vbefore = versions[i - 1]
|
||||
assert s.compare_version(vbefore) > 0
|
||||
if i + 1 < l:
|
||||
if i + 1 < length:
|
||||
vnext = versions[i + 1]
|
||||
assert s.compare_version(vnext) < 0
|
||||
|
||||
|
||||
def test_libssh_compare_version_simple(self):
|
||||
s = self.get_libssh_software('0.3')
|
||||
assert s.compare_version(None) == 1
|
||||
@ -187,7 +187,7 @@ class TestVersionCompare(object):
|
||||
assert s.between_versions('0.2', '0.3.1')
|
||||
assert s.between_versions('0.1', '0.2') is False
|
||||
assert s.between_versions('0.3.1', '0.2') is False
|
||||
|
||||
|
||||
def test_libssh_compare_version_sequential(self):
|
||||
versions = []
|
||||
for v in ['0.2', '0.3']:
|
||||
@ -202,14 +202,14 @@ class TestVersionCompare(object):
|
||||
versions.append('0.6.{0}'.format(i))
|
||||
for i in range(0, 5):
|
||||
versions.append('0.7.{0}'.format(i))
|
||||
l = len(versions)
|
||||
for i in range(l):
|
||||
length = len(versions)
|
||||
for i in range(length):
|
||||
v = versions[i]
|
||||
s = self.get_libssh_software(v)
|
||||
assert s.compare_version(v) == 0
|
||||
if i - 1 >= 0:
|
||||
vbefore = versions[i - 1]
|
||||
assert s.compare_version(vbefore) > 0
|
||||
if i + 1 < l:
|
||||
if i + 1 < length:
|
||||
vnext = versions[i + 1]
|
||||
assert s.compare_version(vnext) < 0
|
||||
|
Reference in New Issue
Block a user