Skip to content

Commit 81adf38

Browse files
author
Sebastian Wagner
committed
STY: flake8 fixes everywhere
1 parent 835e38d commit 81adf38

File tree

10 files changed

+17
-17
lines changed

10 files changed

+17
-17
lines changed

contrib/eventdb/apply_mapping_eventdb.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ def eventdb_apply(malware_name_column, malware_family_column, host, port,
5555

5656
cur.execute('SELECT DISTINCT "classification.identifier", "malware.name" FROM {table} '
5757
'WHERE "classification.taxonomy" = \'malicious code\' {where}'
58-
''.format(table=table, where=where))
58+
''.format(table=table, where=where))
5959
if dry_run:
60-
execute = lambda x, y: print(cur.mogrify(x, y).decode())
60+
execute = lambda x, y: print(cur.mogrify(x, y).decode()) # noqa: E731
6161
else:
6262
execute = cur.execute
6363
for (identifier, malware_name) in cur.fetchall():
@@ -76,7 +76,7 @@ def eventdb_apply(malware_name_column, malware_family_column, host, port,
7676
'AND "classification.identifier" IS DISTINCT FROM %s AND '
7777
'"classification.taxonomy" = \'malicious code\' {where}'
7878
''.format(table=table, where=where),
79-
(rule[1], malware_name, rule[1]))
79+
(rule[1], malware_name, rule[1]))
8080
break
8181
else:
8282
print('missing mapping for', repr(malware_name))

contrib/malware_name_mapping/download_mapping.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
URL_MALPEDIA = 'https://raw.githubusercontent.com/certtools/malware_name_mapping/master/malpedia.csv'
2020
URL_MISP = 'https://raw.githubusercontent.com/MISP/misp-galaxy/main/clusters/threat-actor.json'
2121

22-
REGEX_FROM_HUMAN = re.compile(r"((?P<res1>[a-z])(?=[A-Z])|" # "fooBar"
23-
r"(?P<res2>.)(\\ )(?=[^\]])|" # "foo bar" but not "foo[-_ ]?bar"
24-
r"(?P<res3>[^\[-])\\-(?=[^-]))") # "foo-bar" but not "foo[-_ ]?bar"
22+
REGEX_FROM_HUMAN = re.compile(r"((?P<res1>[a-z])(?=[A-Z])|" # "fooBar"
23+
r"(?P<res2>.)(\\ )(?=[^\]])|" # "foo bar" but not "foo[-_ ]?bar"
24+
r"(?P<res3>[^\[-])\\-(?=[^-]))") # "foo-bar" but not "foo[-_ ]?bar"
2525
IDENTIFIER_FROM_HUMAN = re.compile(r"[^a-z0-9]+")
2626

2727

@@ -75,7 +75,7 @@ def generate_regex_from_human(*values):
7575
return "^(%s)$" % "|".join(newvalues)
7676

7777

78-
def download(url: str=URL, add_default=False, params=None, include_malpedia=False,
78+
def download(url: str = URL, add_default=False, params=None, include_malpedia=False,
7979
include_misp=False, mwnmp_ignore_adware=False):
8080
download = requests.get(url)
8181
download.raise_for_status()
@@ -96,7 +96,7 @@ def download(url: str=URL, add_default=False, params=None, include_malpedia=Fals
9696
names = [actor["value"]] + actor.get("meta", {}).get("synonyms", [])
9797
identifier = ("%s-generic"
9898
"" % IDENTIFIER_FROM_HUMAN.sub("-",
99-
actor["value"].lower()))
99+
actor["value"].lower()))
100100
rule_name = "misp-threat-actors-%s" % identifier
101101

102102
rules.append(generate_rule(generate_regex_from_human(*names),

contrib/malware_name_mapping/test_download_mapping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_download_add_default_constant(self):
6969
'then': {'classification.identifier': 'constant'}}]
7070
)
7171

72-
maxDiff=None
72+
maxDiff = None
7373

7474

7575
class TestParser(unittest.TestCase):

contrib/systemd/systemd.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/python3
22
# -*- coding: utf-8 -*-
3+
# flake8: noqa
34
import collections
45
import grp
56
import json

intelmq/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .version import __version__, __version_info__
1+
from .version import __version__, __version_info__ # noqa: F401
22
import os
33

44

intelmq/bin/intelmqctl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import pkg_resources
2424
from termstyle import green
2525

26-
from intelmq import (BOTS_FILE, DEFAULT_LOGGING_LEVEL, DEFAULTS_CONF_FILE,
26+
from intelmq import (BOTS_FILE, DEFAULT_LOGGING_LEVEL, DEFAULTS_CONF_FILE, # noqa: F401
2727
HARMONIZATION_CONF_FILE, PIPELINE_CONF_FILE,
2828
RUNTIME_CONF_FILE, VAR_RUN_PATH, STATE_FILE_PATH,
2929
DEFAULT_LOGGING_PATH, __version_info__,

intelmq/bots/collectors/github_api/collector_github_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def github_api(self, api_path: str, **kwargs) -> dict:
4848
raise ValueError(response.json()['message'])
4949
else:
5050
return response.json()
51-
except requests.RequestException as e:
51+
except requests.RequestException:
5252
raise ValueError("Unknown repository {!r}.".format(api_path))
5353

5454
@staticmethod

intelmq/bots/collectors/github_api/collector_github_contents_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def init(self):
3030
if hasattr(self.parameters, 'regex'):
3131
try:
3232
re.compile(getattr(self.parameters, 'regex'))
33-
except Exception as e:
33+
except Exception:
3434
raise InvalidArgument('regex', expected='string', got=getattr(self.parameters, 'regex'))
3535
else:
3636
raise InvalidArgument('regex', expected='string', got=None)

intelmq/lib/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def assertLoglineEqual(self, line_no: int, message: str, levelname: str = "ERROR
415415
fields = utils.parse_logline(logline)
416416

417417
self.assertEqual(self.bot_id, fields["bot_id"],
418-
"bot_id %s didn't match %s"
418+
"bot_id {!r} didn't match {!r}."
419419
"".format(self.bot_id, fields["bot_id"]))
420420

421421
self.assertEqual(levelname, fields["log_level"])
@@ -436,7 +436,7 @@ def assertLoglineMatches(self, line_no: int, pattern: str, levelname: str = "ERR
436436
fields = utils.parse_logline(logline)
437437

438438
self.assertEqual(self.bot_id, fields["bot_id"],
439-
"bot_id %s didn't match %s"
439+
"bot_id {!r} didn't match {!r}."
440440
"".format(self.bot_id, fields["bot_id"]))
441441

442442
self.assertEqual(levelname, fields["log_level"])

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# -*- coding: utf-8 -*-
33
import json
44
import os
5-
import sys
65

76
from setuptools import find_packages, setup
87

@@ -31,7 +30,7 @@
3130

3231
setup(
3332
name='intelmq',
34-
version=__version__,
33+
version=__version__, # noqa: F821
3534
maintainer='Sebastian Wagner',
3635
maintainer_email='[email protected]',
3736
python_requires='>=3.5',

0 commit comments

Comments
 (0)