Skip to content

Commit d0f17dd

Browse files
authored
Code format (#54)
* Reformat code with Black linter * Update makefile
1 parent b5dd2d8 commit d0f17dd

File tree

33 files changed

+87
-48
lines changed

33 files changed

+87
-48
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ tests:
1717

1818
clean:
1919
docker-compose down
20+
docker volume rm osint-framework_postgres -f

src/core/base/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class BaseRunner:
1111
"""
1212
Defines base runner class to create childs from
1313
"""
14+
1415
required = []
1516

1617
def __init__(self, logger: str = __name__):

src/core/runner/manager.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ class CaseManager:
2828
"default": BaseCase,
2929
}
3030

31-
def __init__(self, cases: list or None = None, max_workers: int = CoreDefaults.MAX_PROCESSES):
31+
def __init__(
32+
self, cases: list or None = None, max_workers: int = CoreDefaults.MAX_PROCESSES
33+
):
3234
"""
3335
Init manager
3436
:param cases: cases to run
@@ -63,10 +65,7 @@ def single_case_runner(
6365
"case_class": self.MAPPING.get(case_class, "default").__name__,
6466
"case_name": case_name,
6567
"case_description": case_description,
66-
"case_data": {
67-
"args": args,
68-
"kwargs": kwargs
69-
},
68+
"case_data": {"args": args, "kwargs": kwargs},
7069
"case_results": case.get_results() or {},
7170
}
7271

@@ -93,7 +92,8 @@ def multi_case_runner(
9392
case_description=case.get("description"),
9493
*case.get("args", []),
9594
**case.get("kwargs", {}),
96-
): sleep(1.0) for case in cases
95+
): sleep(1.0)
96+
for case in cases
9797
}
9898
for future in as_completed(futures):
9999
yield future.result()

src/core/runner/runner.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def run_category(
119119
max_workers: int = CoreDefaults.MAX_THREADS,
120120
timeout: int = CoreDefaults.CASE_TIMEOUT,
121121
*args,
122-
**kwargs
122+
**kwargs,
123123
) -> None:
124124
"""
125125
Run a category with scripts
@@ -132,7 +132,9 @@ def run_category(
132132
self.get_scripts()
133133
with ThreadPoolExecutor(max_workers=max_workers) as executor:
134134
futures = {
135-
executor.submit(self.exec_script, path=script, args=args, kwargs=kwargs): sleep(0.1)
135+
executor.submit(
136+
self.exec_script, path=script, args=args, kwargs=kwargs
137+
): sleep(0.1)
136138
for script in self.scripts.get(category, [])
137139
}
138140
try:

src/core/utils/log.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ def get_logger(name: str, separate_name: bool = True) -> getLogger:
3131
formatter = Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
3232

3333
# Choose the right handler: color Rich handler for CLI, StreamHandler for server part and Docker
34-
handler = RichHandler() if environ.get("LOG_HANDLER", default="rich") == "rich" else StreamHandler()
34+
handler = (
35+
RichHandler()
36+
if environ.get("LOG_HANDLER", default="rich") == "rich"
37+
else StreamHandler()
38+
)
3539
handler.setFormatter(formatter)
3640

3741
logger.addHandler(handler)

src/core/values/defaults.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ class TestDefaults:
1919
PORT_RANGE = (20_000, 65_535)
2020
PORT = None
2121

22-
def __init__(self, host: str or None = None, down_timeout: float or None = None) -> None:
22+
def __init__(
23+
self, host: str or None = None, down_timeout: float or None = None
24+
) -> None:
2325
"""
2426
Init random port
2527
:param host: host to set

src/db/crud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def wrapped_function(*args, **kwargs):
3535
try:
3636
return function(*args, **kwargs)
3737
except exc.DBAPIError:
38-
sleep(0.5*attempt)
38+
sleep(0.5 * attempt)
3939
continue
4040
return function(*args, **kwargs)
4141

src/db/database.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class DefaultValues:
2424
f"postgres+psycopg2://"
2525
f"{DefaultValues.POSTGRES_USER}:{DefaultValues.POSTGRES_PASSWORD}@"
2626
f"{DefaultValues.POSTGRES_HOST}:{str(DefaultValues.POSTGRES_PORT)}/"
27-
f"{DefaultValues.POSTGRES_DATABASE}", poolclass=NullPool
27+
f"{DefaultValues.POSTGRES_DATABASE}",
28+
poolclass=NullPool,
2829
)
2930
if not database_exists(Engine.url):
3031
create_database(Engine.url)

src/queue/consumer.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,17 @@
1414

1515

1616
class Consumer:
17-
def __init__(self, host: str = Default.RABBITMQ_HOST, port: int = Default.RABBITMQ_PORT):
17+
def __init__(
18+
self, host: str = Default.RABBITMQ_HOST, port: int = Default.RABBITMQ_PORT
19+
):
1820
"""
1921
Init rabbitmq consumer
2022
:param host: rabbitmq host
2123
:param port: rabbitmq port
2224
"""
2325
self.queue = Default.QUEUE
2426
self.connection = pika.BlockingConnection(
25-
pika.ConnectionParameters(
26-
host=host,
27-
port=port,
28-
)
27+
pika.ConnectionParameters(host=host, port=port,)
2928
)
3029
self.channel = self.connection.channel()
3130
self.channel.queue_declare(queue=self.queue)
@@ -82,4 +81,4 @@ def __del__(self):
8281
try:
8382
self.connection.close()
8483
except:
85-
pass
84+
pass

src/queue/defaults.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ class DefaultValues:
77
RABBITMQ_HOST = str(environ.get("RABBITMQ_HOST", default="localhost"))
88
RABBITMQ_PORT = int(environ.get("RABBITMQ_PORT", default=5672))
99

10-
QUEUE = "case_queue"
10+
QUEUE = "case_queue"

src/queue/publisher.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,17 @@
1212

1313

1414
class Publisher:
15-
def __init__(self, host: str = Default.RABBITMQ_HOST, port: int = Default.RABBITMQ_PORT):
15+
def __init__(
16+
self, host: str = Default.RABBITMQ_HOST, port: int = Default.RABBITMQ_PORT
17+
):
1618
"""
1719
Init rabbitmq publisher
1820
:param host: rabbitmq host
1921
:param port: rabbitmq port
2022
"""
2123
self.queue = Default.QUEUE
2224
self.connection = pika.BlockingConnection(
23-
pika.ConnectionParameters(
24-
host=host,
25-
port=port,
26-
)
25+
pika.ConnectionParameters(host=host, port=port,)
2726
)
2827
self.channel = self.connection.channel()
2928
result = self.channel.queue_declare(queue="", exclusive=True)
@@ -76,4 +75,4 @@ def __del__(self):
7675
try:
7776
self.connection.close()
7877
except:
79-
pass
78+
pass

src/scripts/convert/email_generator/module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class Runner(BaseRunner):
5151
"""
5252
Class that generates different email addresses
5353
"""
54+
5455
required = ["username"]
5556

5657
def __init__(self, logger: str = __name__):

src/scripts/convert/phone_num_generator/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
runner = Runner()
99
result = runner.run(
1010
phone=argv[1] if len(argv) >= 2 else "+79131161111",
11-
region=argv[2] if len(argv) >= 3 else "ru"
11+
region=argv[2] if len(argv) >= 3 else "ru",
1212
)
1313
pprint(result)

src/scripts/convert/phone_num_generator/module.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Runner(OsintRunner):
1010
"""
1111
Class that generates different phone numbers
1212
"""
13+
1314
required = ["phone", "region"]
1415

1516
def __init__(self, logger: str = __name__):
@@ -33,9 +34,10 @@ def __gen_all(formatted_num: str) -> [str]:
3334
num_list.append(joined)
3435
phone_w_brackets = "{prefix}({code}){rest}".format(
3536
prefix=number_groups[0],
36-
code=number_groups[1][1:-1] if number_groups[1][0] == '(' and number_groups[1][-1] == ')' else
37-
number_groups[1],
38-
rest="".join(number_groups[2:])
37+
code=number_groups[1][1:-1]
38+
if number_groups[1][0] == "(" and number_groups[1][-1] == ")"
39+
else number_groups[1],
40+
rest="".join(number_groups[2:]),
3941
)
4042
num_list.append(phone_w_brackets)
4143
return num_list
@@ -53,15 +55,18 @@ def run(self, *args, **kwargs) -> ScriptResponse.success or ScriptResponse.error
5355
region = kwargs.get("region")
5456
parsed_num = parse(phone, region)
5557
except NumberParseException:
56-
return ScriptResponse.error(result=None, message="Not viable number or not international format")
58+
return ScriptResponse.error(
59+
result=None, message="Not viable number or not international format"
60+
)
5761
except Exception:
5862
return ScriptResponse.error(result=None, message="Something went wrong!")
5963
try:
6064
result = [
61-
phone for phone_format in [
65+
phone
66+
for phone_format in [
6267
PhoneNumberFormat.NATIONAL,
6368
PhoneNumberFormat.INTERNATIONAL,
64-
PhoneNumberFormat.E164
69+
PhoneNumberFormat.E164,
6570
]
6671
for phone in self.__gen_all(format_number(parsed_num, phone_format))
6772
]

src/scripts/convert/phone_num_generator/test_module.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55

66

77
class Test(unittest.TestCase):
8-
98
def setUp(self):
109
self.runner = module.Runner()
1110

1211
def test_num_1(self):
1312
runner = Runner()
1413
response = runner.run(phone="+442083661177", region=None)
15-
self.assertIn("020-8366-1177", response.get('result'))
14+
self.assertIn("020-8366-1177", response.get("result"))
1615

1716
def test_num_2(self):
1817
runner = Runner()
1918
response = runner.run(phone="8137777777", region="RU")
20-
self.assertIn("+7-813-777-77-77", response.get('result'))
19+
self.assertIn("+7-813-777-77-77", response.get("result"))
2120

2221

23-
if __name__ == '_main_':
22+
if __name__ == "_main_":
2423
unittest.main()

src/scripts/osint/check_nickname/module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class Runner(OsintRunner):
6767
"""
6868
Class that performs nickname check
6969
"""
70+
7071
required = ["username"]
7172

7273
def __init__(self, logger: str = __name__):

src/scripts/osint/check_nickname/test_module.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ def test_nicknames(self) -> None:
3232
response = self.runner.run(username="")
3333
self.assertEqual(response.get("status"), "success")
3434
for _ in range(5):
35-
nickname = "".join(choice(string.ascii_letters) for _ in range(randrange(5, 10)))
35+
nickname = "".join(
36+
choice(string.ascii_letters) for _ in range(randrange(5, 10))
37+
)
3638
response = self.runner.run(username=nickname)
3739
self.assertEqual(response.get("status"), "success")
3840

@@ -45,6 +47,8 @@ def test_special_nicknames(self) -> None:
4547
response = self.runner.run(username=None)
4648
self.assertEqual(response.get("status"), "error")
4749
for _ in range(5):
48-
nickname = "".join(choice(string.punctuation) for _ in range(randrange(3, 5)))
50+
nickname = "".join(
51+
choice(string.punctuation) for _ in range(randrange(3, 5))
52+
)
4953
response = self.runner.run(username=nickname)
5054
self.assertEqual(response.get("status"), "error")

src/scripts/osint/check_vk_reg/module.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class Runner(OsintRunner):
4343
"""
4444
Class that performs VK.com registration status (by phone number)
4545
"""
46+
4647
required = ["phone"]
4748

4849
def __init__(self, logger: str = __name__) -> None:
@@ -158,7 +159,11 @@ def __get_driver_path(self) -> str:
158159
path: str = str(
159160
Path(__file__).parent.parent.parent.parent
160161
/ "drivers"
161-
/ ("chromedriver_" + system + ".exe" if system == "windows" else "chromedriver_" + system)
162+
/ (
163+
"chromedriver_" + system + ".exe"
164+
if system == "windows"
165+
else "chromedriver_" + system
166+
)
162167
)
163168

164169
self.__set_execution_rights(path)

src/scripts/osint/email_verifier/module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Runner(OsintRunner):
1111
"""
1212
Class that performs email verification
1313
"""
14+
1415
required = ["email"]
1516

1617
def __init__(self, logger: str = __name__):

src/scripts/osint/extremism/module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Runner(OsintRunner):
1111
"""
1212
Class that performs Russian Extremists list check
1313
"""
14+
1415
required = ["fullname"]
1516

1617
def __init__(self, logger: str = __name__):

src/scripts/osint/region_check/module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Runner(OsintRunner):
1111
"""
1212
Class that performs region check by phone number
1313
"""
14+
1415
required = ["phone"]
1516

1617
def __init__(self, logger: str = __name__):

src/scripts/other/network_usage/module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Runner(ReconRunner):
1010
"""
1111
Simple example module to returh headers
1212
"""
13+
1314
required = ["hostname"]
1415

1516
def __init__(self, logger: str = __name__):

src/scripts/other/simple_example/module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Runner(BaseRunner):
99
"""
1010
Basic example
1111
"""
12+
1213
required = []
1314

1415
def __init__(self, logger: str = __name__):

src/scripts/other/user_greeting/module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Runner(OsintRunner):
99
"""
1010
Class that greets users
1111
"""
12+
1213
required = ["username"]
1314

1415
def __init__(self, logger: str = __name__):

src/scripts/recon/allowed_methods/module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class Runner(ReconRunner):
5656
"""
5757
Class that performs allowed methods check
5858
"""
59+
5960
required = ["url"]
6061

6162
def __init__(self, logger: str = __name__):

src/scripts/recon/cookie_checker/module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Runner(ReconRunner):
1111
"""
1212
Class that performs cookie flags checking.
1313
"""
14+
1415
required = ["url"]
1516

1617
def __init__(self, logger: str = __name__):

src/scripts/recon/get_host_status/module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Runner(ReconRunner):
1010
"""
1111
Class that performs host status check
1212
"""
13+
1314
required = ["url"]
1415

1516
def __init__(self, logger: str = __name__):

src/scripts/recon/get_title/module.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Runner(ReconRunner):
1111
"""
1212
Class that performs HTTP title checking
1313
"""
14+
1415
required = ["url"]
1516

1617
def __init__(self, logger: str = __name__):

src/scripts/recon/ip_info/__main__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
from src.core.utils.module import run_module
55
from .module import Runner
66

7-
result = run_module(
8-
Runner, args=argv, arg_name="ip", arg_default="8.8.8.8"
9-
)
7+
result = run_module(Runner, args=argv, arg_name="ip", arg_default="8.8.8.8")
108

119
pprint(result)

0 commit comments

Comments
 (0)