Skip to main content

An extension of vt-py supporting local file cache

Project description

cached-virustotal-api

A cached extension of the official Python client for VirusTotal.

Usage

Create the CachedClient like so:

from kfinny.cachedvt import CachedClient

client = CachedClient(<apikey>, cache_dir=<some folder>)

The folder does not need to exist, but if it does, it should be empty or a prior cache from this library. The cache is sqlite database created by DiskCache.

The client may be used just as it is documented by the vt-py project. The codebase "adds" a single function to the client API, yield_file_report and can take a list of hashes.

# yield_file_report
hashes = [<list of md5,sha1,sha256 hashes>]

for obj in client.yield_file_report(hashes):
    assert(obj.type == 'file')
    print(f'{obj.md5} : {obj.sha1} : {obj.sha256}')

Files not found on VirusTotal are not returned, but they are cached, since the whole point of this library is to conserve quota.

>>> hits, misses = client.cache.stats()
>>> reports = list(client.yield_file_report('abcd'*16))
>>> reports
[]
>>> _hits, _misses = client.cache.stats()
>>> assert(_misses - misses == 1)
>>>

Prior Versions

A previous version of this code worked with the virustotal-api last tested using this commit 551b87a.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kfinny.cachedvt-3.1.0.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file kfinny.cachedvt-3.1.0.tar.gz.

File metadata

  • Download URL: kfinny.cachedvt-3.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.3

File hashes

Hashes for kfinny.cachedvt-3.1.0.tar.gz
Algorithm Hash digest
SHA256 79d5163428c7fc84e23f0a0493d4ff649493a3b95aef53cc373d74f0dcd9b067
MD5 caa1897539270ba8d8ee93c28c513569
BLAKE2b-256 afdd84096bdc14ea5f0a3a30a3141ca1f0f48a48ad56c17fc2e93b960c2673f4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page