Commit 4e556a3f by fwkz

Fixing flake8 violations within core

parent 34297343
......@@ -19,4 +19,4 @@ from routersploit.utils import (
from routersploit import exploits
from routersploit import wordlists
from routersploit import validators
from routersploit.shell import shell
from routersploit.shell import shell
......@@ -3,4 +3,4 @@ class RoutersploitException(Exception):
class OptionValidationError(RoutersploitException):
pass
\ No newline at end of file
pass
......@@ -356,9 +356,9 @@ class RoutersploitInterpreter(BaseInterpreter):
@utils.module_required
def _show_info(self, *args, **kwargs):
utils.pprint_dict_in_order(
self.module_metadata,
("name", "description", "devices", "authors", "references"),
)
self.module_metadata,
("name", "description", "devices", "authors", "references"),
)
utils.print_info()
@utils.module_required
......
from routersploit.test.test_case import RoutersploitTestCase
\ No newline at end of file
from routersploit.test.test_case import RoutersploitTestCase
......@@ -14,11 +14,11 @@ class RoutersploitTestCase(unittest.TestCase):
decorator_name,
decorator_list,
msg="'{}' method should be decorated with 'module_required'".format(function.__name__)
)
)
def assertIsSequence(self, arg):
self.assertEqual(
True,
isinstance(arg, NonStringIterable),
"'{}' is not a sequence".format(arg)
)
\ No newline at end of file
)
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
from routersploit.test import RoutersploitTestCase
from routersploit.exploits import Exploit, Option, GLOBAL_OPTS
......@@ -86,4 +81,3 @@ class OptionTest(RoutersploitTestCase):
if __name__ == '__main__':
unittest.main()
......@@ -382,8 +382,9 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
mock.call('authors_desc'),
mock.call('\nReferences:'),
mock.call('references_desc'),
mock.call()]
)
mock.call()
]
)
@mock.patch('__builtin__.print')
def test_command_show_info_module_with_no_metadata(self, mock_print):
......@@ -395,9 +396,8 @@ class RoutersploitInterpreterTest(RoutersploitTestCase):
self.interpreter._show_info()
self.assertEqual(
mock_print.mock_calls,
[
mock.call()]
)
[mock.call()]
)
@mock.patch('__builtin__.print')
def test_show_options(self, mock_print):
......
......@@ -53,4 +53,4 @@ class UtilsTest(RoutersploitTestCase):
)
if __name__ == '__main__':
unittest.main()
\ No newline at end of file
unittest.main()
import unittest
import socket
try:
import unittest.mock as mock
......
......@@ -25,10 +25,10 @@ MODULES_DIR = rsf_modules.__path__[0]
print_lock = threading.Lock()
colors = {
'grey': 30, 'red': 31,
'grey': 30, 'red': 31,
'green': 32, 'yellow': 33,
'blue': 34, 'magenta': 35,
'cyan': 36, 'white': 37,
'blue': 34, 'magenta': 35,
'cyan': 36, 'white': 37,
}
# Disable certificate verification warnings
......@@ -148,7 +148,8 @@ def stop_after(space_number):
class DummyFile(object):
""" Mocking file object. Optimalization for the "mute" decorator. """
def write(self, x): pass
def write(self, x):
pass
def mute(fn):
......@@ -390,9 +391,9 @@ def pprint_dict_in_order(dictionary, order=None):
prettyprint(rest_keys, dictionary[rest_keys])
def random_text(length, alph=string.ascii_letters+string.digits):
def random_text(length, alph=string.ascii_letters + string.digits):
""" Random text generator. NOT crypto safe.
Generates random text with specified length and alphabet.
"""
return ''.join(random.choice(alph) for _ in range(length))
......@@ -460,29 +461,24 @@ def posix_shell(chan):
while(True):
r, w, e = select.select([chan, sys.stdin], [], [])
if(chan in r):
if chan in r:
try:
x = unicode(chan.recv(1024))
if(len(x) == 0):
if len(x) == 0:
break
sys.stdout.write(x)
sys.stdout.flush()
except socket.timeout:
pass
if(sys.stdin in r):
if sys.stdin in r:
x = sys.stdin.read(1)
if(len(x) == 0):
break
if len(x) == 0:
break
chan.send(x)
finally:
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, oldtty)
return
return
def windows_shell(chan):
......@@ -532,4 +528,3 @@ def tokenize(token_specification, text):
else:
column = mo.start() - line_start
yield Token(kind, value, line_num, column, mo)
......@@ -4,4 +4,4 @@ import pkg_resources
defaults = 'file://' + pkg_resources.resource_filename(__name__, 'defaults.txt')
passwords = 'file://' + pkg_resources.resource_filename(__name__, 'passwords.txt')
usernames = 'file://' + pkg_resources.resource_filename(__name__, 'usernames.txt')
snmp = 'file://'+ pkg_resources.resource_filename(__name__, 'snmp.txt')
snmp = 'file://' + pkg_resources.resource_filename(__name__, 'snmp.txt')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment