Skip to content

Commit 6152a15

Browse files
committed
refactor: small changes regarding logging and magic number
1 parent 6d637f7 commit 6152a15

4 files changed

Lines changed: 10 additions & 9 deletions

File tree

certleak/analyzers/tldanalyzer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def match(self, update):
3333
for tld in self.filtered_tlds:
3434
if extract_result.suffix == tld and not any(word in full_domain for word in self.blacklist):
3535
matches.append(full_domain)
36-
except Exception as e:
37-
self.logger.error("During matching of an update, the following exception occurred: %s", e)
36+
except Exception:
37+
self.logger.exception("During matching of an update, an exception occurred")
3838

3939
return set(matches)

certleak/analyzers/wildcardcertanalyzer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ def match(self, update):
2828
for full_domain in update.all_domains:
2929
try:
3030
extract_result = tldextract.extract(full_domain)
31-
except Exception as e:
32-
self.logger.error("During matching of an update, the following exception occurred: %s", e)
31+
except Exception:
32+
self.logger.exception("During matching of an update, an exception occurred")
3333
continue
3434

3535
if extract_result.subdomain == "*" and not any(word in full_domain for word in self.blacklist):

certleak/core/actionhandler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,5 @@ def _perform_action_wrapper(self, action, update, analyzer, matches):
7575
try:
7676
self.logger.debug("Performing action '%s' on update '%s' matched by analyzer '%s'!", action.name, update.all_domains, analyzer.identifier)
7777
action.perform(update, analyzer.identifier, matches)
78-
except Exception as e:
79-
self.logger.error("While performing the action '%s' the following exception occurred: '%s'", action.name, e)
78+
except Exception:
79+
self.logger.exception("While performing the action '%s' an exception occurred", action.name)

certleak/core/certstreamwrapper.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ def _fill_queue(self, message, context):
5353
try:
5454
msg = Message.from_dict(message)
5555
update = msg.update
56-
except Exception as e:
57-
self.logger.error("Something went wrong while de_jsoning: %s", e)
56+
except Exception:
57+
self.logger.exception("Something went wrong while de_jsoning")
5858
self.error_counter += 1
5959
return
6060
else:
@@ -65,7 +65,8 @@ def _fill_queue(self, message, context):
6565
self.processed_domains.add(domain)
6666

6767
time_passed = int(time.time()) - self.last_info
68-
if time_passed >= 60:
68+
minute_in_seconds = 60
69+
if time_passed >= minute_in_seconds:
6970
format_str = "Processed {0} updates ({1} unique domains) during the last {2} seconds. {3:.1f} domains/s, {4:.1f} certs/s"
7071
formatted_str = format_str.format(
7172
self.update_counter, len(self.processed_domains), time_passed, len(self.processed_domains) / time_passed, self.update_counter / time_passed

0 commit comments

Comments
 (0)