Conversation
Added installation instructions for Ubuntu 16.04
| if self.config.pretend or self.config.do_not_report: | ||
| logger.info("NOT reporting resource to virustotal") |
There was a problem hiding this comment.
Added new parameter do-not-report in config if it helps to save some calls to VT
|
First of all: thank you for your contribution. I'm somewhat reluctant to merge this PR as it sounds to me that this is a violation of the Virustotal ToS although i couldn't find anything that explicitly forbids multiple accounts (and thus, multiple API keys). Anyway: before merging, please:
I'll leave some comments in diff too. |
| for api_key in self.config.apikeys: | ||
| use_api_key = self.memcached.get(api_key) | ||
| if not use_api_key: | ||
| response = requests.post(self.config.api_url, { |
There was a problem hiding this comment.
Please reformat these arguments to be more compliant with the python style guide.
| for api_key in self.config.apikeys: | ||
| use_api_key = self.memcached.get(api_key) | ||
| if not use_api_key: | ||
| response = requests.post(self.config.report_url, data={ |
There was a problem hiding this comment.
Please reformat these arguments to be more compliant with the python style guide.
| ])) | ||
|
|
||
| def api_call_check(self, checksums): | ||
| for api_key in self.config.apikeys: |
There was a problem hiding this comment.
Please split up the loop over self.config.apikeys and the actual API call and invert the expression in line 495.
| logger.info("No more API Keys available") | ||
| return False | ||
|
|
||
| def api_call_report(self, files): |
There was a problem hiding this comment.
This is basically the same as api_call_check (except for the url and the arguments), isn't it?
Please refactor it to not duplicate everything.
| 'User-Agent': 'amavisvt/%s (+https://ercpe.de/projects/amavisvt)' % VERSION | ||
| }) | ||
| response.raise_for_status() | ||
| if response.status_code == 204: |
There was a problem hiding this comment.
I wonder if it is safe to hard code 204 here. I would expect that every api call counts against the API limit, no matter what the response code is.
| response = requests.post(self.config.api_url, { | ||
| #Call VT API for checksums | ||
| response = self.api_call_check(send_checksums) | ||
| """response = requests.post(self.config.api_url, { |
There was a problem hiding this comment.
Why is this block of code a multi-line string?
There was a problem hiding this comment.
Sorry, I'm very new to python. I thought it was fine for commenting.
There was a problem hiding this comment.
This way you're effectively creating a string which gets thrown away right away. The proper way to comment out code is with the hash sign:
# i'm a comment
However, if the code isn't used anymore, remove it.
| 'file': (resource.filename, open(resource.path, 'rb')), | ||
| } | ||
| response = requests.post(self.config.report_url, data={ | ||
| """response = requests.post(self.config.report_url, data={ |
Hello!
I added a feature in which you can use multiple API keys, with temporary disabling it in memcached in case limit is reached.