Scan Google Cloud Storage objects
After starting the 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 GCS bucket by making requests to http://172.31.39.37:8080/api/clamav/scan/gcs/object.
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/gcs/object
Parameter Meanings
The following parameters are used in the request:
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
This parameter specifies the name of the S3 bucket from which the file should be retrieved.
key
This parameter represents the key of the file within the S3 bucket. It identifies the specific file that should be downloaded and scanned.
Response
A json format string will be returned. The possible return codes are 0, 1, 2, and 99.
Clean
{"code":0,"message":"OK"}
Infected
For example, when Eicar-Signature is identified, the response would be
{"code":1,"message":"Eicar-Signature FOUND"}
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
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
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