diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 55d94dc..3dec949 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,6 @@ - id: name-tests-test - id: requirements-txt-fixer - id: flake8 - - repo: git://github.com/asottile/reorder_python_imports sha: 3d86483455ab5bd06cc1069fdd5ac57be5463f10 hooks: diff --git a/combine/baler.py b/combine/baler.py index 7b1faa7..b0857c8 100755 --- a/combine/baler.py +++ b/combine/baler.py @@ -186,7 +186,7 @@ def bale_CRITs_indicator(base_url, data, indicator_que): logger.info("don't yet know what to do with: %s[%s]" % (indicator['indicator_type'], indicator['indicator'])) -def bale_CRITs(harvest, filename): +def bale_CRITs(harvest): """ taking the output from combine and pushing it to the CRITs web API""" # checking the minimum requirements for parameters # it would be nice to have some metadata on the feeds that can be imported in the intel library: diff --git a/combine/winnower.py b/combine/winnower.py index 72592f6..7753bcf 100755 --- a/combine/winnower.py +++ b/combine/winnower.py @@ -29,13 +29,13 @@ def load_gi_org(filename): + # no return function because gi_org is scoped to the module + # ugly hack with open(filename, 'rb') as f: org_reader = csv.DictReader(f, fieldnames=['start', 'end', 'org']) for row in org_reader: gi_org[row['start']] = (IPRange(row['start'], row['end']), unicode(row['org'], errors='replace')) - return gi_org - def org_by_addr(address): as_num = None @@ -52,7 +52,6 @@ def maxhits(dns_records): hmax = 0 hostname = None for record in dns_records: - # logger.info("examining %s" % record) if record['count'] > hmax: hmax = record['count'] hostname = record['rrname'].rstrip('.') @@ -119,12 +118,18 @@ def reserved(address): def is_ipv4(address): - if re.match('(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$', address): + if re.match(r'(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$', address): return True else: return False +def is_fqdn(address): + if re.match(r'(?=^.{4,255}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?