From 51d9d8c96e26c7eb9a836397fd1bf25a0f0691b1 Mon Sep 17 00:00:00 2001 From: lhinds Date: Thu, 29 Mar 2018 14:14:50 +0100 Subject: [PATCH 1/2] PEP8 fixes --- anteater/main.py | 2 +- anteater/src/get_lists.py | 18 +++--- anteater/src/patch_scan.py | 85 ++++++++++++------------- anteater/src/project_scan.py | 119 ++++++++++++++--------------------- anteater/src/virus_total.py | 35 +++++------ docs/conf.py | 16 ++--- setup.py | 2 + utils/generate-sha256.py | 2 +- 8 files changed, 123 insertions(+), 156 deletions(-) diff --git a/anteater/main.py b/anteater/main.py index ff08cc7..83e76ff 100644 --- a/anteater/main.py +++ b/anteater/main.py @@ -87,7 +87,7 @@ def main(): arguments['--binaries'], arguments['--ips'], arguments['--urls']) elif arguments['']: prepare_project(arguments[''], arguments[''], - arguments['--binaries'], arguments['--ips'], arguments['--urls']) + arguments['--binaries'], arguments['--ips'], arguments['--urls']) if __name__ == "__main__": diff --git a/anteater/src/get_lists.py b/anteater/src/get_lists.py index 7108da0..96de9b3 100644 --- a/anteater/src/get_lists.py +++ b/anteater/src/get_lists.py @@ -44,20 +44,23 @@ logger.error('File not found: %s', ignore_list) sys.exit(0) + def unique(sequence): return list(set(sequence)) + def _remove_nullvalue(contents): """ Removes nullvalue placeholders required to prevent key errors""" if contents and len(contents) > 2 and 'nullvalue' in contents: contents.remove('nullvalue') + class GetLists(object): def __init__(self, *args): self.args = args self.loaded = False - def load_project_flag_list_file (self, project_exceptions, project): + def load_project_flag_list_file(self, project_exceptions, project): """ Loads project specific lists """ if self.loaded: return @@ -111,13 +114,12 @@ def load_project_ignore_list_file(self, project_exceptions, project): logger.info('%s not found in %s', project, ignore_list) logger.info('No project specific exceptions will be applied') - def binary_hash(self, project, patch_file): """ Gathers sha256 hashes from binary lists """ global il exception_file = None try: - project_exceptions = il.get('project_exceptions') # try needed + project_exceptions = il.get('project_exceptions') except KeyError: logger.info('project_exceptions missing in %s for %s', ignore_list, project) @@ -157,7 +159,7 @@ def file_audit_list(self, project): logger.error('Key Error processing file_names list values') try: project_list = set((fl['file_audits'][project]['file_names'])) - logger.info('Loaded %s specific file_audits entries', project) + logger.info('Loaded %s specific file_audits entries', project) except KeyError: logger.info('No project specific file_names section for project %s', project) @@ -172,7 +174,7 @@ def file_audit_list(self, project): file_names_proj_re = re.compile("") return file_names_re, file_names_proj_re - def file_content_list(self, project): + def file_content_list(self, project): """ gathers content strings """ project_list = False self.load_project_flag_list_file(il.get('project_exceptions'), project) @@ -188,7 +190,7 @@ def file_content_list(self, project): try: project_list = fl['file_audits'][project]['file_contents'] - logger.info('Loaded %s specific file_contents entries', project) + logger.info('Loaded %s specific file_contents entries', project) except KeyError: logger.info('No project specific file_contents section for project %s', project) @@ -228,9 +230,8 @@ def ignore_directories(self, project): return ignore_directories else: return ignore_directories - - def url_ignore(self, project): + def url_ignore(self, project): """ Gathers a list of URLs to ignore """ project_list = False try: @@ -258,7 +259,6 @@ def url_ignore(self, project): return url_ignore_re def ip_ignore(self, project): - """ Gathers a list of URLs to ignore """ project_list = False try: diff --git a/anteater/src/patch_scan.py b/anteater/src/patch_scan.py index aeb3104..7c224c9 100644 --- a/anteater/src/patch_scan.py +++ b/anteater/src/patch_scan.py @@ -38,7 +38,8 @@ hasher = hashlib.sha256() failure = False -def prepare_patchset(project, patchset, binaries, ips, urls): + +def prepare_patchset(project, patchset, binaries, ips, urls): """ Create black/white lists and default / project waivers and iterates over patchset file """ # Get Various Lists / Project Waivers @@ -63,9 +64,9 @@ def prepare_patchset(project, patchset, binaries, ips, urls): ignore_directories = lists.ignore_directories(project) if binaries or ips or urls: - try: + try: apikey = os.environ["VT_KEY"] - except KeyError: + except KeyError: logger.error("Please set your virustotal.com API key as an environment variable") sys.exit(1) try: @@ -104,7 +105,7 @@ def scan_patch(project, patch_file, binaries, ips, urls, file_audit_list, file_audit_project_list, flag_list, ignore_list, file_ignore, ignore_directories, url_ignore, ip_ignore, apikey): - """ + """ Scan actions for each commited file in patch set """ global failure @@ -120,17 +121,17 @@ def scan_patch(project, patch_file, binaries, ips, urls, file_audit_list, buf = afile.read() hasher.update(buf) sha256hash = hasher.hexdigest() - + if sha256hash in binary_hash: - + logger.info('Found matching file hash for: %s', patch_file) else: logger.info('sha256hash: %s', sha256hash) logger.error('Non Whitelisted Binary file: %s', patch_file) - - scan_binary(patch_file, project, sha256hash, apikey) + + scan_binary(patch_file, project, sha256hash, apikey) failure = True @@ -169,17 +170,16 @@ def scan_patch(project, patch_file, binaries, ips, urls, file_audit_list, ipaddr = re.findall(r'(?:\d{1,3}\.)+(?:\d{1,3})', line) if ipaddr: ipaddr = ipaddr[0] - if re.search(ip_ignore,ipaddr): + if re.search(ip_ignore, ipaddr): logger.info('%s is in IP ignore list.', ipaddr) else: try: ipaddress.ip_address(ipaddr).is_global scan_ipaddr(ipaddr, apikey) except: - pass # Ok to pass here, as this captures - # the odd string which is not an IP Address - - # Check for URLs and send for report to Virus Total + pass # Ok to pass here, as this captures the odd string which is not an IP Address + + # Check for URLs and send for report to Virus Total if urls: url = re.search("(?Phttps?://[^\s]+)", line) or re.search("(?Pwww[^\s]+)", line) if url: @@ -189,8 +189,7 @@ def scan_patch(project, patch_file, binaries, ips, urls, file_audit_list, else: scan_url(url, apikey) - - # Perform search within text files + # Perform search within text files for key, value in flag_list.items(): regex = value['regex'] desc = value['desc'] @@ -200,16 +199,12 @@ def scan_patch(project, patch_file, binaries, ips, urls, file_audit_list, logger.error('Flagged Content: %s', line.rstrip()) logger.error('Rationale: %s', desc.rstrip()) failure = True - with open(reports_dir + "contents_" + project + ".log", - "a") as gate_report: - gate_report.write('File contains violation: {0}\n'. - format(patch_file)) - gate_report.write('Flagged Content: {0}'. - format(line)) - gate_report.write('Matched Regular Exp: {0}\n'. - format(regex)) - gate_report.write('Rationale: {0}\n'. - format(desc.rstrip())) + with open(reports_dir + "contents_" + project + ".log", "a") as gate_report: + gate_report.write('File contains violation: {0}\n'.format(patch_file)) + gate_report.write('Flagged Content: {0}'.format(line)) + gate_report.write('Matched Regular Exp: {0}\n'.format(regex)) + gate_report.write('Rationale: {0}\n'.format(desc.rstrip())) + def scan_binary(patch_file, project, sha256hash, apikey): """ @@ -220,7 +215,7 @@ def scan_binary(patch_file, project, sha256hash, apikey): while True: binary_report = v_api.binary_report(sha256hash, apikey) response_code = binary_report['response_code'] - + # report does not exist, need to scan if response_code == 0: logger.info('Performing new scan of %s.', patch_file) @@ -240,42 +235,40 @@ def scan_binary(patch_file, project, sha256hash, apikey): positives = binary_report['positives'] if positives == 0: - negative_report(binary_report,sha256hash, project, patch_file) + negative_report(binary_report, sha256hash, project, patch_file) else: - positive_report(binary_report,sha256hash, project, patch_file) + positive_report(binary_report, sha256hash, project, patch_file) + -def negative_report(binary_report,sha256hash, project, patch_file): +def negative_report(binary_report, sha256hash, project, patch_file): """ If no match is made and file is clean """ report_url = binary_report['permalink'] - scan_date = binary_report['scan_date'] # build conditional + scan_date = binary_report['scan_date'] logger.info('File scan date for %s shows a clean status on: %s', patch_file, scan_date) logger.info('Full report avaliable here: %s', report_url) logger.info('The following sha256 hash can be used in your %s.yaml file to suppress this scan:', project) logger.info('%s', sha256hash) - with open(reports_dir + "binaries-" + project + ".log", - "a") as gate_report: - gate_report.write('Non Whitelisted Binary: {}\n'. - format(patch_file)) - gate_report.write('File scan date for {} shows a clean status on {}\n'. - format(patch_file, scan_date)) - gate_report.write('The following sha256 hash can be used in your {}.yaml file to suppress this scan:\n'. - format(project)) - gate_report.write('{}\n'. - format(sha256hash)) - -def positive_report(binary_report,sha256hash, project, patch_file): + with open(reports_dir + "binaries-" + project + ".log", "a") as gate_report: + gate_report.write('Non Whitelisted Binary: {}\n'.format(patch_file)) + gate_report.write('File scan date for {} shows a clean status on {}\n'.format(patch_file, scan_date)) + gate_report.write('The following sha256 hash can be used in your {}.yaml file to suppress this scan:\n'.format(project)) + gate_report.write('{}\n'.format(sha256hash)) + + +def positive_report(binary_report, sha256hash, project, patch_file): """ If a Positive match is found - """ + """ failure = True report_url = binary_report['permalink'] - scan_date = binary_report['scan_date'] # build conditional + scan_date = binary_report['scan_date'] logger.error("Virus Found!") logger.info('File scan date for %s shows a infected status on: %s', patch_file, scan_date) logger.info('Full report avaliable here: %s', report_url) + def scan_ipaddr(ipaddr, apikey): """ If an IP Address is found, scan it @@ -295,6 +288,7 @@ def scan_ipaddr(ipaddr, apikey): else: logger.info('%s has no record of resolving to malicious urls', ipaddr) + def scan_url(url, apikey): """ If URL is found, scan it @@ -331,7 +325,8 @@ def scan_url(url, apikey): logger.info("%s is recorded as a clean", url) except: pass - + + def process_failure(): """ If any scan operations register a failure, sys.exit(1) is called diff --git a/anteater/src/project_scan.py b/anteater/src/project_scan.py index a52ce53..9e8dcf2 100644 --- a/anteater/src/project_scan.py +++ b/anteater/src/project_scan.py @@ -37,6 +37,7 @@ ignore_dirs = ['.git', 'examples', anteater_files] hasher = hashlib.sha256() + def prepare_project(project, project_dir, binaries, ips, urls): """ Generates blacklists / whitelists @@ -66,15 +67,15 @@ def prepare_project(project, project_dir, binaries, ips, urls): hashlist = get_lists.GetLists() if binaries or ips or urls: - try: + try: apikey = os.environ["VT_KEY"] - except KeyError: + except KeyError: logger.error("Please set your virustotal.com API key as an environment variable") sys.exit(1) try: vt_rate_type = config.get('config', 'vt_rate_type') except six.moves.configparser.NoSectionError: - logger.error("A config section is required for vt_rate_type with a public | private option ") + logger.error("A config section is required for vt_rate_type with a public | private option") sys.exit(1) patten = re.compile(r'\bpublic\b|\bprivate\b') @@ -84,7 +85,7 @@ def prepare_project(project, project_dir, binaries, ips, urls): # Perform rudimentary scans scan_file(project, project_dir, binaries, ips, urls, file_audit_list, - file_audit_project_list, flag_list, ignore_list, hashlist, + file_audit_project_list, flag_list, ignore_list, hashlist, file_ignore, ignore_directories, url_ignore, ip_ignore, apikey) @@ -118,7 +119,7 @@ def scan_file(project, project_dir, binaries, ips, urls, file_audit_list, # Check if Binary is whitelisted if is_binary(full_path) and binaries: - + split_path = full_path.split(project + '/', 1)[-1] binary_hash = hashlist.binary_hash(project, split_path) with open(full_path, 'rb') as afile: @@ -127,14 +128,12 @@ def scan_file(project, project_dir, binaries, ips, urls, file_audit_list, hasher.update(buf) sha256hash = hasher.hexdigest() if sha256hash in binary_hash: - logger.info('Found matching file hash for: %s', - full_path) - logger.info('No further action needed for: %s', - full_path) + logger.info('Found matching file hash for: %s', full_path) + logger.info('No further action needed for: %s', full_path) else: logger.info('Non Whitelisted Binary file: %s', full_path) - scan_binary(full_path, split_path, project, sha256hash, apikey) - + scan_binary(full_path, split_path, project, sha256hash, apikey) + else: if not items.endswith(tuple(file_ignore)) and not is_binary(full_path): try: @@ -149,16 +148,15 @@ def scan_file(project, project_dir, binaries, ips, urls, file_audit_list, ipaddr = re.findall(r'(?:\d{1,3}\.)+(?:\d{1,3})', line) if ipaddr: ipaddr = ipaddr[0] - if re.search(ip_ignore,ipaddr): + if re.search(ip_ignore, ipaddr): logger.info('%s is in IP ignore list.', ipaddr) else: try: ipaddress.ip_address(ipaddr).is_global scan_ipaddr(ipaddr, line, project, split_path, apikey) except: - pass # Ok to pass here, as this captures - # the odd string which is not an IP Address - + pass # Ok to pass here, as this captures the odd string which is nt an IP Address + # Check for URLs and send for report to Virus Total if urls: url = re.search("(?Phttps?://[^\s]+)", line) or re.search("(?Pwww[^\s]+)", line) @@ -167,36 +165,23 @@ def scan_file(project, project_dir, binaries, ips, urls, file_audit_list, if re.search(url_ignore, url): logger.info('%s is in URL ignore list.', url) else: - scan_url(url, line, project, split_path, apikey) + scan_url(url, line, project, split_path, apikey) # Check flagged content in files - for key, value in flag_list.items(): regex = value['regex'] desc = value['desc'] - if re.search(regex, line) and not re.search( - ignore_list, line): - logger.error('File contains violation: %s', - full_path) - logger.error('Flagged Content: %s', - line.rstrip()) + if re.search(regex, line) and not re.search(ignore_list, line): + logger.error('File contains violation: %s', full_path) + logger.error('Flagged Content: %s', line.rstrip()) logger.error('Matched Regular Exp: %s', regex) logger.error('Rationale: %s', desc.rstrip()) - with open(reports_dir + "contents-" + project - + ".log", "a") \ - as gate_report: - gate_report. \ - write('File contains violation: {0}\n'. - format(full_path)) - gate_report. \ - write('Flagged Content: {0}'. - format(line)) - gate_report. \ - write('Matched Regular Exp: {0}'. - format(regex)) - gate_report. \ - write('Rationale: {0}\n'. - format(desc.rstrip())) + with open(reports_dir + "contents-" + project + ".log", "a") as gate_report: + gate_report.write('File contains violation: {0}\n'.format(full_path)) + gate_report.write('Flagged Content: {0}'.format(line)) + gate_report.write('Matched Regular Exp: {0}'.format(regex)) + gate_report.write('Rationale: {0}\n'.format(desc.rstrip())) + def scan_binary(full_path, split_path, project, sha256hash, apikey): """ @@ -207,7 +192,7 @@ def scan_binary(full_path, split_path, project, sha256hash, apikey): while True: binary_report = v_api.binary_report(sha256hash, apikey) response_code = binary_report['response_code'] - + # report does not exist, need to scan if response_code == 0: logger.info('Performing new scan of %s.', split_path) @@ -227,48 +212,42 @@ def scan_binary(full_path, split_path, project, sha256hash, apikey): positives = binary_report['positives'] if positives == 0: - negative_report(binary_report,sha256hash, split_path, project, full_path) + negative_report(binary_report, sha256hash, split_path, project, full_path) else: - positive_report(binary_report,sha256hash, split_path, project, full_path) + positive_report(binary_report, sha256hash, split_path, project, full_path) -def negative_report(binary_report,sha256hash, split_path, project, full_path): + +def negative_report(binary_report, sha256hash, split_path, project, full_path): """ If no match is made and file is clean """ report_url = binary_report['permalink'] - scan_date = binary_report['scan_date'] # build conditional + scan_date = binary_report['scan_date'] logger.info('File scan date for %s shows a clean status on: %s', split_path, scan_date) logger.info('Full report avaliable here: %s', report_url) logger.info('The following sha256 hash can be used in your %s.yaml file to suppress this scan:', project) logger.info('%s:', sha256hash) - with open(reports_dir + "binaries-" + project + ".log", - "a") as gate_report: - gate_report.write('Non Whitelisted Binary: {}\n'. - format(full_path)) - gate_report.write('File scan date for {} shows a clean status on {}\n'. - format(split_path, scan_date)) - gate_report.write('The following sha256 hash can be used in your {}.yaml file to suppress this scan:\n'. - format(project)) - gate_report.write('{}\n'. - format(sha256hash)) - -def positive_report(binary_report,sha256hash, split_path, project, full_path): + with open(reports_dir + "binaries-" + project + ".log", "a") as gate_report: + gate_report.write('Non Whitelisted Binary: {}\n'.format(full_path)) + gate_report.write('File scan date for {} shows a clean status on {}\n'.format(split_path, scan_date)) + gate_report.write('The following sha256 hash can be used in your {}.yaml file to suppress this scan:\n'.format(project)) + gate_report.write('{}\n'.format(sha256hash)) + + +def positive_report(binary_report, sha256hash, split_path, project, full_path): """ If a Positive match is found - """ + """ report_url = binary_report['permalink'] - scan_date = binary_report['scan_date'] # build conditional + scan_date = binary_report['scan_date'] logger.error("Virus Found!") logger.info('File scan date for %s shows a infected status on: %s', split_path, scan_date) logger.info('Full report avaliable here: %s', report_url) - with open(reports_dir + "binaries-" + project + ".log", - "a") as gate_report: - gate_report.write('Virus Found!: {}\n'. - format(full_path)) - gate_report.write('File scan date for {} shows a infected status on: {}\n'. - format(split_path, scan_date)) - gate_report.write('Full report avaliable here: {}\n'. - format(report_url)) + with open(reports_dir + "binaries-" + project + ".log", "a") as gate_report: + gate_report.write('Virus Found!: {}\n'.format(full_path)) + gate_report.write('File scan date for {} shows a infected status on: {}\n'.format(split_path, scan_date)) + gate_report.write('Full report avaliable here: {}\n'.format(report_url)) + def scan_ipaddr(ipaddr, line, project, split_path, apikey): """ @@ -283,21 +262,20 @@ def scan_ipaddr(ipaddr, line, project, split_path, apikey): response_code = scan_ip['response_code'] verbose_msg = scan_ip['verbose_msg'] urls = scan_ip['detected_urls'] - with open(reports_dir + "ips-" + project + ".log", - "a") as gate_report: + with open(reports_dir + "ips-" + project + ".log", "a") as gate_report: if urls: logger.error('%s has been known to resolve to the following malicious urls:', ipaddr) - gate_report.write('{} has been known to resolve to the following malicious urls:\n'. - format(ipaddr)) + gate_report.write('{} has been known to resolve to the following malicious urls:\n'.format(ipaddr)) for url in urls: logger.info('%s on date: %s', url['url'], url['scan_date']) gate_report.write('{} on {}\n'.format(url['url'], url['scan_date'])) sleep(0.2) else: - logger.info('No malicious DNS history found for: %s',ipaddr) + logger.info('No malicious DNS history found for: %s', ipaddr) gate_report.write('No malicious DNS history found for: {}\n'.format(ipaddr)) + def scan_url(url, line, project, split_path, apikey): """ If URL is found, scan it @@ -333,7 +311,6 @@ def scan_url(url, line, project, split_path, apikey): with open(reports_dir + "urls-" + project + ".log", "a") as gate_report: logger.error("%s is recorded as a %s by %s", url, results['result'], site) gate_report.write('{} is recorded as a {} by {}\n'.format(url, results['result'], site)) - if not printed: printed = True with open(reports_dir + "urls-" + project + ".log", "a") as gate_report: diff --git a/anteater/src/virus_total.py b/anteater/src/virus_total.py index b588e6a..f43eac5 100644 --- a/anteater/src/virus_total.py +++ b/anteater/src/virus_total.py @@ -1,3 +1,4 @@ +# noinspection PyInterpreter import json import logging import os @@ -11,10 +12,12 @@ from pylimit import PyRateLimit import six.moves.configparser + class VirusTotal(): def __init__(self, *args): self.logger = logging.getLogger(__name__) self.base_url = 'https://www.virustotal.com/vtapi/v2/' + self.headers = {"Accept-Encoding": "gzip, deflate", "User-Agent": "Anteater"} self.HTTP_OK = 200 self.HTTP_BAD = 400 self.HTTP_FORBIDDEN = 403 @@ -25,7 +28,7 @@ def __init__(self, *args): self.config = six.moves.configparser.SafeConfigParser() self.config.read('anteater.conf') - try: # might be better to move this to its own class + try: conn = redis.StrictRedis( host='localhost', port=6379, @@ -35,7 +38,7 @@ def __init__(self, *args): except Exception as ex: self.logger.error('Error: %s', ex) exit('Failed to connect, terminating.') - + self.limit = PyRateLimit() try: @@ -50,9 +53,9 @@ def __init__(self, *args): sys.exit(1) if vt_rate_type == 'public': - self.limit.create(21,1) + self.limit.create(21, 1) elif vt_rate_type == 'private': - self.limit.create(1,1) + self.limit.create(1, 1) def rate_limit(self): """ @@ -63,12 +66,11 @@ def rate_limit(self): while True: is_rate_limited = self.limit.is_rate_limited(uuid) if is_rate_limited: - time.sleep(0.3) # save hammering the shit out of redis + time.sleep(0.3) # save hammering redis if not rate_limited_msg: self.logger.info('Rate limit active..please wait...') rate_limited_msg = True - - + if not is_rate_limited: self.logger.info('Rate limit clear.') self.limit.attempt(uuid) @@ -101,11 +103,7 @@ def rescan_file(self, filename, sha256hash, apikey): 'apikey': apikey, 'resource': sha256hash } - - headers = { - "Accept-Encoding": "gzip, deflate", - "User-Agent" : "gzip, lhinds" # set this to a config value! - } + rate_limit_clear = self.rate_limit() if rate_limit_clear: response = requests.post(url, params=params) @@ -127,7 +125,7 @@ def binary_report(self, sha256sum, apikey): if rate_limit_clear: response = requests.post(url, data=params) - + if response.status_code == self.HTTP_OK: json_response = response.json() response_code = json_response['response_code'] @@ -136,7 +134,6 @@ def binary_report(self, sha256sum, apikey): time.sleep(20) else: self.logger.warning("retrieve report: %s, HTTP code: %d", os.path.basename(filename), response.status_code) - def send_ip(self, ipaddr, apikey): """ @@ -160,20 +157,16 @@ def url_report(self, scan_url, apikey): """ Send URLS for list of past malicous associations """ - headers = { - "Accept-Encoding": "gzip, deflate", - "User-Agent" : "gzip, My Python requests library example client or username" - } url = self.base_url + "url/report" - params = {"apikey": apikey, 'resource':scan_url} + params = {"apikey": apikey, 'resource': scan_url} rate_limit_clear = self.rate_limit() if rate_limit_clear: - response = requests.post(url, params=params, headers=headers) + response = requests.post(url, params=params, headers=self.headers) if response.status_code == self.HTTP_OK: json_response = response.json() return json_response elif response.status_code == self.HTTP_RATE_EXCEEDED: - time.sleep(20) + time.sleep(20) else: self.logger.error("sent: %s, HTTP: %d", scan_url, response.status_code) time.sleep(self.public_api_sleep_time) diff --git a/docs/conf.py b/docs/conf.py index 67342f8..25c26cc 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -199,21 +199,21 @@ # -- Options for LaTeX output -------------------------------------------------- latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -# 'papersize': 'letterpaper', + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', -# The font size ('10pt', '11pt' or '12pt'). -# 'pointsize': '10pt', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', -# Additional stuff for the LaTeX preamble. -# 'preamble': '', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'user_guide.tex', u'anteater Documentation', - u'Luke Hinds', 'manual'), + ('index', 'user_guide.tex', u'anteater Documentation', + u'Luke Hinds', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of diff --git a/setup.py b/setup.py index be835e2..5c99406 100755 --- a/setup.py +++ b/setup.py @@ -44,6 +44,7 @@ def find_version(fname): raise RuntimeError('Cannot find version information') return version + __version__ = find_version("anteater/main.py") @@ -52,6 +53,7 @@ def read(fname): content = fp.read() return content + setup( name='anteater', version="0.22", diff --git a/utils/generate-sha256.py b/utils/generate-sha256.py index c63153c..89ecf59 100644 --- a/utils/generate-sha256.py +++ b/utils/generate-sha256.py @@ -37,4 +37,4 @@ split_path = full_path.split(args.project + '/', 1)[-1] print(" {}:".format(split_path)) sum = hasher.hexdigest() - print(" - {}".format(sum)) \ No newline at end of file + print(" - {}".format(sum)) From 28b08d7f7924b2fceb102de3a48811f4f4bff32e Mon Sep 17 00:00:00 2001 From: lhinds Date: Thu, 29 Mar 2018 14:43:00 +0100 Subject: [PATCH 2/2] Fixing gate failures --- tests/test_docopt.py | 2 ++ tox.ini | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/test_docopt.py b/tests/test_docopt.py index b99fc2f..8d728e7 100644 --- a/tests/test_docopt.py +++ b/tests/test_docopt.py @@ -4,6 +4,7 @@ from anteater.main import __doc__ as doc + class TestClient(unittest.TestCase): def testArgs(self): cmd = '--ips --urls --binaries --project test --patchset /home/user/repo/patchset' @@ -11,5 +12,6 @@ def testArgs(self): self.assertEqual(args[''], 'test') self.assertEqual(args[''], '/home/user/repo/patchset') + if __name__ == "__main__": unittest.main() diff --git a/tox.ini b/tox.ini index 84e473c..23975cc 100644 --- a/tox.ini +++ b/tox.ini @@ -4,8 +4,12 @@ envlist = py36 [testenv] commands = py.test - pycodestyle --ignore E501,E722 --exclude buildroot,tests,.git,build,.tox,.eggs . + pycodestyle deps = pytest pycodestyle + +[pycodestyle] +ignore = E501,E722 +exclude=.venv,.git,.tox,build,dist,docs,*lib/python*,*egg,tools,vendor,.update-venv,*.ini,*.po,*.pot,tests/testproject