attachmentav-sdk-python
A virus scan SDK for Python. Scan files for viruses, trojans, and other kinds of malware with attachmentAV.
Getting started
First, install the module.
pip install attachmentav-virus-malware-scan-sdk
Second, get an API key by subscribing to the attachmentAV API (SaaS).
Third, send a scan request. Make sure to replace the <API_KEY_PLACEHOLDER> placeholder and <API_ENDPOINT_PLACEHOLDER> with the API endpoint.
API endpoints (SaaS)
https://eu.developer.attachmentav.com/v1/(Europe)https://us.developer.attachmentav.com/v1/(United States of America)https://canada.developer.attachmentav.com/v1/(Canada)https://india.developer.attachmentav.com/v1/(India)https://australia.developer.attachmentav.com/v1/(Australia)
API endpoint (Self-hosted on AWS)
When following the setup guide, you specified the ApiKeys parameter for the CloudFormation stack. Replace <API_KEY_PLACEHOLDER> with one of those keys and <API_ENDPOINT_PLACEHOLDER> with the API endpoint.
Example, replace attachmentav.yourcompany.com with the domain name of your attachmentAV API installation:
https://attachmentav.yourcompany.com/api/v1.
import attachmentav
configuration = attachmentav.Configuration()
configuration.api_key['apiKeyAuth'] = "<API_KEY_PLACEHOLDER>"
configuration.host = "<API_ENDPOINT_PLACEHOLDER>"
with attachmentav.ApiClient(configuration) as api_client:
api_instance = attachmentav.AttachmentAVApi(api_client)
with open("/path/to/file", "rb") as file:
file_content = file.read()
scan_result = api_instance.scan_sync_binary_post(file_content)
print(scan_result)
The request returns a scan result similar to the following example.
{"status":"clean","size":"1024","realfiletype":"..."}
What is attachmentAV?
attachmentAV offers antivirus for SaaS and cloud platforms. Scan your files and attachments stored in the cloud for viruses, worms, and trojans. attachmentAV detects malware in real-time. Supports Amazon S3, Atlassian, Cloudflare R2, Salesforce, WordPress, and more.
The attachmentAV Virus and Malware Scan API provides a REST API that allows you to integrate malware scans into your application. The solution comes in two variants:
- attachmentAV Virus Scan API (SaaS): Get started quickly with a fully managed service.
- attachmentAV Virus Scan API (self-hosted on AWS): Deploy the production-ready API on AWS.
attachmentAV raises the bar for information security. Our solution is ISO 27001 certified and GDPR compliant. We are establishing, implementing, maintaining, and continually improving an information security management system (ISMS). Sensitive data is encrypted in transit as well as at rest and deleted immediately after processing. More than 1,000 customers trust our malware protection technology.
Install SDK
pip install attachmentav-virus-malware-scan-sdk
Configure SDK
Configure SDK (SaaS)
An active subscription and API key are required. Replace <API_KEY_PLACEHOLDER> with the API key and <API_ENDPOINT_PLACEHOLDER> with the API endpoint. The API endpoint (region) must match with the region selected for the subscription. The default is Europe.
https://eu.developer.attachmentav.com/v1/(Europe)https://us.developer.attachmentav.com/v1/(United States of America)https://canada.developer.attachmentav.com/v1/(Canada)https://india.developer.attachmentav.com/v1/(India)https://australia.developer.attachmentav.com/v1/(Australia)
import attachmentav
configuration = attachmentav.Configuration()
configuration.api_key['apiKeyAuth'] = "<API_KEY_PLACEHOLDER>"
configuration.host = "<API_ENDPOINT_PLACEHOLDER>"
with attachmentav.ApiClient(configuration) as api_client:
api_instance = attachmentav.AttachmentAVApi(api_client)
Configure SDK (self-hosted on AWS)
When following the setup guide, you specified the ApiKeys parameter for the CloudFormation stack.Replace <API_KEY_PLACEHOLDER> with one of those keys and <API_ENDPOINT_PLACEHOLDER> with the API endpoint.
Example, replace attachmentav.yourcompany.com with the domain name of your attachmentAV API installation:
https://attachmentav.yourcompany.com/api/v1.
import attachmentav
configuration = attachmentav.Configuration()
configuration.access_token = "<API_KEY_PLACEHOLDER>"
configuration.host = "<API_ENDPOINT_PLACEHOLDER>"
with attachmentav.ApiClient(configuration) as api_client:
api_instance = attachmentav.AttachmentAVApi(api_client)
Examples
Sync Scan: File
Send a file to the attachmentAV Virus Scan API and process the scan result.
See ScanResult for details.
The maximum file size is 10 MB. The request timeout is 60 seconds.
with open("/path/to/file", "rb") as file:
file_content = file.read()
scan_result = api_instance.scan_sync_binary_post(file_content)
print(scan_result)
Find full example here
Sync Scan: Download
Send a URL to the attachmentAV Virus Scan API. attachmentAV will download the file and return the scan result immediately.
See SyncDownloadScanRequest and ScanResult for details.
The maximum file size is 10 MB. The request timeout is 60 seconds.
sync_download_scan_request = attachmentav.SyncDownloadScanRequest(
download_url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
)
scan_result = api_instance.scan_sync_download_post(sync_download_scan_request)
print(scan_result)
Find full example here
Sync Scan: S3
Send an S3 bucket name and object key to the attachmentAV Virus Scan API. attachmentAV will download the file and return the scan result immediately.
See SyncS3ScanRequest and ScanResult for details.
The maximum file size is 10 MB. The request timeout is 60 seconds.
A bucket policy is required to grant attachmentAV access to private S3 objects.
sync_s3_scan_request = attachmentav.SyncS3ScanRequest(
bucket = "<BUCKET_NAME_PLACEHOLDER>",
key = "<OBJECT_KEY_PLACEHOLDER>"
)
scan_result = api_instance.scan_sync_s3_post(sync_s3_scan_request)
print(scan_result)
Find full example here
Async Scan: Download (callback)
Send a URL to the attachmentAV Virus Scan API. attachmentAV will send the scan result to the callback URL. See callback URL for details.
See AsyncDownloadScanRequest for details.
The maximum file size is 5 GB. The request timeout is 29 seconds; the asynchronous scan job is not affected by this limit.
Not supported by attachmentAV Virus Scan API (Self-hosted on AWS) yet. Contact hello@attachmentav.com to let us know, in case you need this feature.
async_download_scan_request = attachmentav.AsyncDownloadScanRequest(
download_url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
callback_url = "https://api.yourcompany.com/attachmentav/callback"
)
api_instance.scan_async_download_post(async_download_scan_request)
print("Async download submitted")
Find full example here
Async Scan: Download (polling)
Send a URL to the attachmentAV Virus Scan API. attachmentAV will download the file and store the scan result for 24 hours.
See AsyncDownloadScanRequest for details.
The maximum file size is 5 GB. The request timeout is 29 seconds; the asynchronous scan job is not affected by this limit.
Not supported by attachmentAV Virus Scan API (Self-hosted on AWS) yet. Contact hello@attachmentav.com to let us know, in case you need this feature.
trace_id = str(uuid.uuid4())
async_download_scan_request = attachmentav.AsyncDownloadScanRequest(
download_url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
trace_id = trace_id
)
api_instance.scan_async_download_post(async_download_scan_request)
print("Async download submitted.")
# wait some time...
scan_result = api_instance.scan_async_result_get(trace_id)
print(scan_result)
Find full example here
Async Scan: S3 (callback)
Send an S3 bucket name and object key to the attachmentAV Virus Scan API. attachmentAV will send the scan result to the callback URL. See callback URL for details.
See AsyncS3ScanRequest for details.
The maximum file size is 5 GB. The request timeout is 29 seconds; the asynchronous scan job is not affected by this limit.
A bucket policy is required to grant attachmentAV access to private S3 objects.
Not supported by attachmentAV Virus Scan API (Self-hosted on AWS) yet. Contact hello@attachmentav.com to let us know, in case you need this feature.
async_s3_scan_request = attachmentav.AsyncS3ScanRequest(
bucket = "<BUCKET_NAME_PLACEHOLDER>",
key = "<OBJECT_KEY_PLACEHOLDER>",
callback_url = "https://api.yourcompany.com/attachmentav/callback"
)
api_instance.scan_async_s3_post(async_s3_scan_request)
print("Async S3 submitted")
Find full example here
Async Scan: S3 (polling)
Send an S3 bucket name and object key to the attachmentAV Virus Scan API. attachmentAV will download the file and store the scan result for 24 hours.
See AsyncS3ScanRequest for details.
The maximum file size is 5 GB. The request timeout is 29 seconds; the asynchronous scan job is not affected by this limit.
A bucket policy is required to grant attachmentAV access to private S3 objects.
Not supported by attachmentAV Virus Scan API (Self-hosted on AWS) yet. Contact hello@attachmentav.com to let us know, in case you need this feature.
trace_id = str(uuid.uuid4())
async_s3_scan_request = attachmentav.AsyncS3ScanRequest(
bucket = "<BUCKET_NAME_PLACEHOLDER>",
key = "<OBJECT_KEY_PLACEHOLDER>",
trace_id = trace_id
)
api_instance.scan_async_s3_post(async_s3_scan_request)
print("Async S3 submitted. ")
# wait some time...
scan_result = api_instance.scan_async_result_get(trace_id)
print(scan_result)
Find full example here
List callback failures
List callback failures that prevent attachmentAV from invoking the defined callback_url. Sorted by time in descending order (youngest failure is returned first). Callback failures are stored for 30 days.
See CallbackFailures for details.
Not supported by attachmentAV Virus Scan API (Self-hosted on AWS).
callback_failures = api_instance.callback_failures_get('https://api.yourcompany.com/attachmentav/callback')
print(callback_failures)
Find full example here
Usage
Get remaining credits and quota.
See Usage for details.
Not supported by attachmentAV Virus Scan API (Self-hosted on AWS).
usage_result = api_instance.usage_get()
print(usage_result)
Find full example here
Who am I
Get information abour yourself.
See Whoami for details.
Not supported by attachmentAV Virus Scan API (Self-hosted on AWS).
whoami_result = api_instance.whoami_get()
print(whoami_result)
Find full example here
Model
For more details about the data model, please refer to the following pages.
- AsyncDownloadScanRequest
- AsyncS3ScanRequest
- AttachmentAVApi
- ScanResult
- SyncDownloadScanRequest
- SyncS3ScanRequest
- Usage
- Whoami
Need help?
Do you need any help to get started with attachmentAV? hello@attachmentav.com.
Metadata
Release files for attachmentav-virus-malware-scan-sdk 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| attachmentav_virus_malware_scan_sdk-0.5.0.tar.gz | 32.4 kB | Without provenance | Details for attachmentav_virus_malware_scan_sdk-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| attachmentav_virus_malware_scan_sdk-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for attachmentav_virus_malware_scan_sdk-0.5.0-py3-none-any.whl |
Total release size: 74.3 kB
Release files / attachmentav_virus_malware_scan_sdk-0.5.0.tar.gz
| Download URL | attachmentav_virus_malware_scan_sdk-0.5.0.tar.gz |
|---|---|
| Size | 32.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c01fee5c5481196ea3d492be4ca24a76b2ad582bf82214886843bf82c9682e2
|
|
BLAKE2b-256 checksum How to use checksums |
eb7ca91eb7b106d01585f1425d00c8b5c55cc7a982f28c5f78dd285a08f4dd08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / attachmentav_virus_malware_scan_sdk-0.5.0-py3-none-any.whl
| Download URL | attachmentav_virus_malware_scan_sdk-0.5.0-py3-none-any.whl |
|---|---|
| Size | 41.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b82e226bebf09d6d39510305d941a700807f2bdaae3f89730ece4f2ccac942b2
|
|
BLAKE2b-256 checksum How to use checksums |
e37c2db9368fc29f18f2efba73f388384f48ce4164ef80d01515b52103b4474f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for attachmentav-virus-malware-scan-sdk 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.