Commit 4e556a3f by fwkz

Fixing flake8 violations within core

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