Skip to content

ClamAV Antivirus API Server API Endpoints (AWS)

After starting the EC2 instance, you can access the API Server using its IP address and the port 8080. For instance, if the IP address is 172.31.39.37, you can perform file scans on the S3 bucket by making requests to http://172.31.39.37:8080/api/clamav/scan/s3/object.

The virus scan API Server is configured to listen on the local address 127.0.0.1:3000. To initiate a virus scan, you can send an HTTP request to http://127.0.0.1:3000/api/clamav/scan/s3/object if the request originates from within the virus scan API server.

Terminal window
curl -d '{"stream": true, "bucket": "elm-bucket-virus-scan", "key": "test/virus_test.txt"}' -H 'Content-Type: application/json' http://172.31.39.37:8080/api/clamav/scan/s3/object

The following parameters are used in the request:

This parameter controls how the server handles the file download process. When set to false, the server downloads the entire file into memory before saving it to disk. Conversely, when set to true, the server streams the file directly to disk in smaller chunks. Streaming is particularly beneficial when dealing with large files, as it reduces the memory required for the download process. This approach enables more efficient resource utilization and allows the server to handle files that might otherwise exceed available memory capacity.

This parameter specifies the name of the S3 bucket from which the file should be retrieved.

This parameter represents the key of the file within the S3 bucket. It identifies the specific file that should be downloaded and scanned.

A json format string will be returned. The possible return codes are 0, 1, 2, and 99.

Terminal window
{"code":0,"message":"OK"}

For example, when Eicar-Signature is identified, the response would be

Terminal window
{"code":1,"message":"Eicar-Signature FOUND"}

For example, when having file access error, the response would be

Terminal window
{"code":2,"message":"Can't access file /tmp/test/file"}

For example, when the IAM role is not properly set, the response would be

Terminal window
{"code":99,"message":"no credentials in the property bag"}

You can perform file scans on local files by making requests to http://172.31.39.37:8080/api/clamav/scan/file.

Terminal window
curl -d '{"file": "/tmp/test.txt"}' -H 'Content-Type: application/json' http://172.31.39.37:8080/api/clamav/scan/file