-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from arizon-dread/scan-v2
- Loading branch information
Showing
16 changed files
with
254 additions
and
729 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ src | |
*.swp | ||
clamrest | ||
pyenv | ||
__debug* | ||
.vscode | ||
clamav-rest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,12 @@ This is a two in one docker image which runs the open source virus scanner ClamA | |
|
||
# Updates | ||
|
||
As of October 21 2024, freshclam notifies the correct `.clamd.conf` so that `clamd` is notified about updates and the correct version is returned now. | ||
2025-01-08: [PR 50](https://github.com/ajilach/clamav-rest/pull/50) integrated which now provides a new `/v2` endpoint returning more scan result information: status, description, http status and a list of scanned files. See the PR for more details. The old `/scan` endpoint is now considered deprecated. Also, a file size scan limit has been added which can be configured through the `MAX_FILE_SIZE` environment variable. | ||
|
||
2024-10-21: freshclam notifies the correct `.clamd.conf` so that `clamd` is notified about updates and the correct version is returned now. | ||
This is an additional fix to the latest fix from October 15 2024 which was not working. Thanks to [christianbumann](https://github.com/christianbumann) and [arizon-dread](https://github.com/arizon-dread). | ||
|
||
As of October 15 2024, ClamAV was thought to handle database updates correctly thanks to [christianbumann](https://github.com/christianbumann). It turned out that this was not the case. | ||
2024-10-15: ClamAV was thought to handle database updates correctly thanks to [christianbumann](https://github.com/christianbumann). It turned out that this was not the case. | ||
|
||
As of May 2024, the releases are built for multiple architectures thanks to efforts from [kcirtapfromspace](https://github.com/kcirtapfromspace) and support non-root read-only deployments thanks to [robaca](https://github.com/robaca). | ||
|
||
|
@@ -59,37 +61,40 @@ docker run -p 9000:9000 -p 9443:9443 -itd --name clamav-rest ajilaag/clamav-rest | |
|
||
Test that service detects common test virus signature: | ||
|
||
**HTTP** | ||
**HTTP:** | ||
|
||
```bash | ||
$ curl -i -F "[email protected]" http://localhost:9000/scan | ||
$ curl -i -F "[email protected]" http://localhost:9000/v2/scan | ||
HTTP/1.1 100 Continue | ||
|
||
HTTP/1.1 406 Not Acceptable | ||
Content-Type: application/json; charset=utf-8 | ||
Date: Mon, 28 Aug 2017 20:22:34 GMT | ||
Content-Length: 56 | ||
|
||
{ "Status": "FOUND", "Description": "Eicar-Test-Signature" } | ||
[{ "Status": "FOUND", "Description": "Eicar-Test-Signature","FileName":"eicar.com.txt"}] | ||
``` | ||
|
||
**HTTPS** | ||
**HTTPS:** | ||
|
||
```bash | ||
$ curl -i -k -F "[email protected]" https://localhost:9443/scan | ||
$ curl -i -k -F "[email protected]" https://localhost:9443/v2/scan | ||
HTTP/1.1 100 Continue | ||
|
||
HTTP/1.1 406 Not Acceptable | ||
Content-Type: application/json; charset=utf-8 | ||
Date: Mon, 28 Aug 2017 20:22:34 GMT | ||
Content-Length: 56 | ||
|
||
{ "Status": "FOUND", "Description": "Eicar-Test-Signature" } | ||
[{ "Status": "FOUND", "Description": "Eicar-Test-Signature","FileName":"eicar.com.txt"}] | ||
``` | ||
|
||
Test that service returns 200 for clean file: | ||
|
||
**HTTP** | ||
**HTTP:** | ||
|
||
```bash | ||
$ curl -i -F "[email protected]" http://localhost:9000/scan | ||
$ curl -i -F "[email protected]" http://localhost:9000/v2/scan | ||
|
||
HTTP/1.1 100 Continue | ||
|
||
|
@@ -98,11 +103,12 @@ Content-Type: application/json; charset=utf-8 | |
Date: Mon, 28 Aug 2017 20:23:16 GMT | ||
Content-Length: 33 | ||
|
||
{ "Status": "OK", "Description": "" } | ||
[{ "Status": "OK", "Description": "","FileName":"clamrest.go"}] | ||
``` | ||
**HTTPS** | ||
**HTTPS:** | ||
|
||
```bash | ||
$ curl -i -k -F "[email protected]" https://localhost:9443/scan | ||
$ curl -i -k -F "[email protected]" https://localhost:9443/v2/scan | ||
|
||
HTTP/1.1 100 Continue | ||
|
||
|
@@ -111,14 +117,16 @@ Content-Type: application/json; charset=utf-8 | |
Date: Mon, 28 Aug 2017 20:23:16 GMT | ||
Content-Length: 33 | ||
|
||
{ "Status": "OK", "Description": "" } | ||
[{ "Status": "OK", "Description": "","FileName":"clamrest.go"}] | ||
``` | ||
|
||
## Status Codes | ||
- 200 - clean file = no KNOWN infections | ||
- 400 - ClamAV returned general error for file | ||
- 406 - INFECTED | ||
- 412 - unable to parse file | ||
- 413 - request entity too large, the file exceeds the scannable limit. Set MAX_FILE_SIZE to scan larger files | ||
- 422 - filename is missing in MimePart | ||
- 501 - unknown request | ||
|
||
# Configuration | ||
|
@@ -172,24 +180,28 @@ clamscan --database=/clamav/data --version | |
|
||
[Prometheus metrics](https://prometheus.io/docs/guides/go-application/) were implemented, which can be retrieved as follows | ||
|
||
**HTTP**: | ||
**HTTP:** | ||
curl http://localhost:9000/metrics | ||
|
||
**HTTPS:** | ||
curl https://localhost:9443/metrics | ||
|
||
# Developing | ||
# Development | ||
|
||
Source Code can be found here: https://github.com/ajilach/clamav-rest | ||
Source code can be found here: https://github.com/ajilach/clamav-rest | ||
|
||
Build golang (linux) binary and docker image: | ||
|
||
```bash | ||
# env GOOS=linux GOARCH=amd64 go build | ||
docker build . -t clamav-go-rest | ||
docker run -p 9000:9000 -p 9443:9443 -itd --name clamav-rest clamav-go-rest | ||
docker build . -t clamav-rest | ||
docker run -p 9000:9000 -p 9443:9443 -itd --name clamav-rest clamav-rest | ||
``` | ||
|
||
# History | ||
|
||
This work is based on the awesome work done by [o20ne/clamav-rest](https://github.com/o20ne/clamav-rest) which is based on [niilo/clamav-rest](https://github.com/niilo/clamav-rest) which is based on the original code from [osterzel/clamav-rest](https://github.com/osterzel/clamav-rest). | ||
|
||
# References | ||
|
||
* https://www.clamav.net | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.