ClamAV Antivirus API Server API Endpoints (AWS)
Scan S3 objects
Section titled “Scan S3 objects”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.
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/objectParameter Meanings
Section titled “Parameter Meanings”The following parameters are used in the request:
stream
Section titled “stream”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.
bucket
Section titled “bucket”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.
Response
Section titled “Response”A json format string will be returned. The possible return codes are 0, 1, 2, and 99.
{"code":0,"message":"OK"}Infected
Section titled “Infected”For example, when Eicar-Signature is identified, the response would be
{"code":1,"message":"Eicar-Signature FOUND"}Scan Errors
Section titled “Scan Errors”For example, when having file access error, the response would be
{"code":2,"message":"Can't access file /tmp/test/file"}Other Errors
Section titled “Other Errors”For example, when the IAM role is not properly set, the response would be
{"code":99,"message":"no credentials in the property bag"}Scan local files
Section titled “Scan local files”You can perform file scans on local files by making requests to http://172.31.39.37:8080/api/clamav/scan/file.
curl -d '{"file": "/tmp/test.txt"}' -H 'Content-Type: application/json' http://172.31.39.37:8080/api/clamav/scan/file