mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 09:34:39 +00:00
(ids) obey configured output filename is source is different
This commit is contained in:
parent
0d7e02e714
commit
585e1b1032
@ -62,18 +62,19 @@ class Downloader(object):
|
||||
output.append(line)
|
||||
return '\n'.join(output)
|
||||
|
||||
def download(self, proto, url, input_filter):
|
||||
def download(self, proto, url, filename, input_filter):
|
||||
""" download ruleset file
|
||||
:param proto: protocol (http,https)
|
||||
:param url: download url
|
||||
:param filename: target filename
|
||||
:param input_filter: filter to use on received data before save
|
||||
"""
|
||||
if proto in ('http', 'https'):
|
||||
frm_url = url.replace('//', '/').replace(':/', '://')
|
||||
req = requests.get(url=frm_url)
|
||||
if req.status_code == 200:
|
||||
target_filename = ('%s/%s' % (self._target_dir, frm_url.split('/')[-1])).replace('//', '/')
|
||||
try:
|
||||
target_filename = '%s/%s' % (self._target_dir, filename)
|
||||
save_data = self.filter(req.text, input_filter)
|
||||
open(target_filename, 'wb').write(save_data)
|
||||
except IOError:
|
||||
|
||||
@ -62,6 +62,7 @@ if __name__ == '__main__':
|
||||
else:
|
||||
enabled_rulefiles[section.strip()]['filter'] = ""
|
||||
|
||||
|
||||
# download / remove rules
|
||||
md = metadata.Metadata()
|
||||
dl = downloader.Downloader(target_dir=rule_source_directory)
|
||||
@ -77,4 +78,5 @@ if __name__ == '__main__':
|
||||
pass
|
||||
else:
|
||||
input_filter = enabled_rulefiles[rule['filename']]['filter']
|
||||
dl.download(proto=download_proto, url=rule['url'], input_filter=input_filter)
|
||||
dl.download(proto=download_proto, url=rule['url'],
|
||||
filename=rule['filename'], input_filter=input_filter)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user