Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work on support for VirusTotal v3 API #23

Closed
dbrennand opened this issue Oct 30, 2020 · 1 comment
Closed

Work on support for VirusTotal v3 API #23

dbrennand opened this issue Oct 30, 2020 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@dbrennand
Copy link
Owner

dbrennand commented Oct 30, 2020

VirusTotal now has a 3rd version of their API.

This issue is open to track adding this functionality for this API version to virustotal-python.

Work on this can be found in the redesign branch.

@dbrennand dbrennand added the enhancement New feature or request label Oct 30, 2020
@dbrennand dbrennand self-assigned this Oct 30, 2020
@dbrennand
Copy link
Owner Author

dbrennand commented Nov 1, 2020

Looking at version 3 (v3) of the VirusTotal API. It is vastly different in terms of functionality and endpoints. Due to this, I think a new design for virustotal-python is required to maintain compatibility with both the v2 and v3 APIs.

Currently, virustotal-python is designed around making it as easy as possible for the user to use. This means the user doesn't have to worry about what the request method is for a specific endpoint and only about what they need to provide to it.
If I was to stick with the current design and implement it for the v3 version of the API, there would be hundreds of lines of code which would make the library bloated and more difficult to maintain longer term. Therefore, a new design is needed.

I think a design similar to what has been implemented in TwitterAPI might be a better approach. With this design, support could be maintained for the existing v2 API and the newer v3 API. However, there are potential disadvantages with this design. One disadvantage being that the library would loose that design around:

making it as easy as possible for the user

As the user would have to be more aware of what method to use, the endpoint/resource URL and parameters. However, it would be much easier to implement functionality for v3 while still maintaining v2 functionality, as well as reducing the amount of code written. In addition, this new design provides an opportunity to add some additional features.

I have been looking into using the design and I think it is the best approach.

A number of aspects need to be re-factored:

  • Re-factor examples for new design.
  • Maintain backwards compatibility of the response returned.
  • Re-write tests.
  • Implement checking for API_KEY via environment variable.
  • Add support for request timeout.

@dbrennand dbrennand pinned this issue Nov 1, 2020
dbrennand added a commit that referenced this issue Nov 21, 2020
* Add v3 progress checklist.

* Add EOF. Fix a spelling mistake. Add 0.1.0 changelog (Will probably add to this more later).

* Bump description and version.

* Add new parameter to file_scan.

* Add username to LICENSE.

* Fix license in file.
Remove ImportError print.
Add API_VERSION parameter and docstring to __init__
Adjust headers for each API version.
Raise exception when API_VERSION is invalid.
file_scan: Update docstring, added new parameter upload_url, added support for v3 API.
Add new method file_upload_url.

* Move comment up to beginning of if state for clarity.

* Remove proxies from individual make_request calls. Add inside make_request.
Add file_id method.
add file_id_analyse method.

* Remove checklist.

* Add progress on re-write for v3 API support with backwards compatibility.
See issue #23

* Move check on API_KEY before self.API_KEY.

* Add link to v2 docs for error().

* Rename backwards_compatibility to COMPATIBILITY_ENABLED.
Move to init method of Virustotal class.

* Fix for issue where API_KEY is needed in query parameters. Might find something better soon.
Fix mistake with BASEURL being BASE_URL.

* Make requests response object @Property and fix naming causing AttributeError.

* Add more @Property.

* Remove truthy check.

* Add VirustotalError exception class.
Alter wording to retrieve.
Add data and object_type properties. Usage with v3 API endpoints.
Simplify response_code property.
Replace json parameter with data in request().
Make method the last parameter in request().
Add docstring raises for validate_response().

* Add testing file to ignore.

* Replace examples.py as oldexamples.py

* Add some new examples.

* Fix docstring :returns:. Fix return type hint.

* Update packages in lock file.

* Update requirements.txt with only nessasary packages.

* Push progress on new README.

* Add spacing to NOTES.

* Add link to file in NOTE.

* Push example with timeout and proxies.

* Add examples to README.
Add API key image.

* Add word.

* Add comment about MAX with v2 API.

* Add useful comments to examples.

* Add examples for providing an API key via an environment variable.

* Add example about retrieving info about a domain.

* Edit changelog.
Remove WIP.

* Add correct documentation for examples.

* Add domain_info example.

* Add start of comment.py example.

* Add example for use with environment variable.

* Alter file ID. A more interesting file.

* Add json to request().
Fix docstring for data.
Add docstring for json.

* FIX: json.decoder.JSONDecodeError when user attempts to run json() and no JSON is present.

* Alter to empty dict instead of None in case the user runs .data instead of .json().

* Add comments examples for v3 and v3.

* Fix raises docstring.

* Add graphs examples.

* Add meta, cursor and links.

* Add ip examples.

* Add missing example for v2.

* Add search and metadata endpoint examples.

* Add example of using a cursor.

* Progress on new tests.

* Add progress on tests.

* Add final tests.
Remove skips.
All tests pass.

* Add section on how to run tests.

* Add NOTE about how links are not retrieve from objects.

* Alter word.

* Add comment and catch for AttributeError which can occur.

* Remove "as err"

* Add missing class name.

* Add correct variable for example.

* Alter wording slightly.

* Alter wording in docstring.

* Alter wording slightly in sentence.

* Fixes to some wording. Added some comments to examples.

* Capitalise URL_ID.

* Fix example variable.

* Alter comments.

* Alter wording.

* Move comment down.

* Edit example description.
Remove repeated code.

* Alter comment and print.

* Alter example description.

* Alter description.

* Alter description again.

* Alter description back.

* Alter keywords and description.

* Alter file description.

* Remove fullstops.

* Fix class docstring.

* Fix docstrings.

* Add example to comment.

* Move v2 and v3 examples around.

* Move v2 example above v3 example.

* Add link to PR for 0.1.0.

* Alter wording slightly in CHANGELOG for 0.1.0
@dbrennand dbrennand unpinned this issue Feb 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant