From 4db2d1425e0959cbb95bc31bdd92115f401fad9c Mon Sep 17 00:00:00 2001 From: Jay Townsend Date: Thu, 12 Sep 2019 22:27:03 +0100 Subject: [PATCH] flake8 changes/ lgtm fixes --- setup.cfg | 2 +- theHarvester/__main__.py | 5 ++--- theHarvester/discovery/dnssearch.py | 15 +++++++-------- theHarvester/discovery/duckduckgosearch.py | 2 -- theHarvester/discovery/port_scanner.py | 1 - theHarvester/lib/__init__.py | 2 +- theHarvester/lib/reportgraph.py | 4 ++-- 7 files changed, 13 insertions(+), 18 deletions(-) diff --git a/setup.cfg b/setup.cfg index a60079ab..265accca 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,3 +1,3 @@ [flake8] ignore = E501, F405, F403, E402 -exclude = theHarvester/discovery/DNS/*,theHarvester/discovery/IPy.py,theHarvester/discovery/s3_scanner.py,theHarvester/discovery/dnssearch.py \ No newline at end of file +exclude = theHarvester/discovery/IPy.py,theHarvester/discovery/s3_scanner.py \ No newline at end of file diff --git a/theHarvester/__main__.py b/theHarvester/__main__.py index 6ec5c4df..70005bbe 100644 --- a/theHarvester/__main__.py +++ b/theHarvester/__main__.py @@ -692,9 +692,8 @@ def entry_point(): start() except KeyboardInterrupt: print('\n\n\033[93m[!] ctrl+c detected from user, quitting.\n\n \033[0m') - except Exception: - import traceback - print(traceback.print_exc()) + except Exception as error_entry_point: + print(error_entry_point) sys.exit(1) diff --git a/theHarvester/discovery/dnssearch.py b/theHarvester/discovery/dnssearch.py index fff3c208..50d459fb 100644 --- a/theHarvester/discovery/dnssearch.py +++ b/theHarvester/discovery/dnssearch.py @@ -1,9 +1,9 @@ -import os import sys import dns.resolver # TODO: need big focus on performance and results parsing, now does the basic. - + + class DnsForce: def __init__(self, domain, dnsserver, verbose=False): @@ -13,7 +13,7 @@ def __init__(self, domain, dnsserver, verbose=False): self.verbose = verbose try: f = open(self.file, 'r') - except BaseException: + except Exception: print('Error opening DNS dictionary file.') sys.exit() self.list = f.readlines() @@ -28,17 +28,16 @@ def run(self, host): try: answer = dns.resolver.query(hostname, 'A') print(answer.canonical_name) - return answer.canonical_name # TODO: need rework all this results - + return answer.canonical_name # TODO: need rework all this results + except Exception: pass - + def process(self): results = [] for x in self.list: host = self.run(x) if host is not None: - #print(' : ' + host.split(':')[1]) + # print(' : ' + host.split(':')[1]) results.append(host) return results - \ No newline at end of file diff --git a/theHarvester/discovery/duckduckgosearch.py b/theHarvester/discovery/duckduckgosearch.py index fc0daf7f..96d1cc5b 100644 --- a/theHarvester/discovery/duckduckgosearch.py +++ b/theHarvester/discovery/duckduckgosearch.py @@ -77,8 +77,6 @@ def crawl(self, text): return tmp except Exception as e: print(f'Exception occurred: {e}') - import traceback as t - print(t.print_exc()) return [] def get_emails(self): diff --git a/theHarvester/discovery/port_scanner.py b/theHarvester/discovery/port_scanner.py index 6ecf9352..de76f976 100644 --- a/theHarvester/discovery/port_scanner.py +++ b/theHarvester/discovery/port_scanner.py @@ -23,7 +23,6 @@ def port_scanner(self, host, ports): connect.close() except Exception as e: print(e) - pass self.lock.release() return openports diff --git a/theHarvester/lib/__init__.py b/theHarvester/lib/__init__.py index 24fa6550..8fc0aea3 100644 --- a/theHarvester/lib/__init__.py +++ b/theHarvester/lib/__init__.py @@ -1 +1 @@ -__all__ = ['markup', 'graphs', 'hostchecker'] +__all__ = ['hostchecker'] diff --git a/theHarvester/lib/reportgraph.py b/theHarvester/lib/reportgraph.py index 7c73cbb1..60a2f03e 100644 --- a/theHarvester/lib/reportgraph.py +++ b/theHarvester/lib/reportgraph.py @@ -6,8 +6,8 @@ try: db = stash.stash_manager() db.do_init() -except Exception: - pass +except Exception as error: + print(f'{error}') class GraphGenerator: