benzino77 / clamav-rest-api

ClamAV REST API. Scan files using simple POST request.
MIT License
127 stars 44 forks source link

Testing Endpoints /version works /scan doesn't #58

Closed ChadCarroll closed 5 months ago

ChadCarroll commented 5 months ago

Running inside of Kubernetes. The pods are running and I'm able to access the endpoint to retrieve the version but I'm unable scan a file.

Working

http --form GET http://clamav-rest-service.default.svc.cluster.local:3000/api/v1/version HTTP/1.1 200 OK Access-Control-Allow-Origin: * Connection: keep-alive Content-Length: 83 Content-Type: application/json; charset=utf-8 Date: Sun, 16 Jun 2024 23:17:38 GMT ETag: W/"53-ih6cCd8a32HdUVUvezFSoGXOtCE" Keep-Alive: timeout=5 X-Powered-By: Express

{ "data": { "version": "ClamAV 1.3.1/27308/Sun Jun 16 08:28:55 2024\n" }, "success": true }

Not working

http --form POST http://clamav-rest-service.default.svc.cluster.local:3000/api/v1/scan FILES@/tmp/testfile.txt HTTP/1.1 400 Bad Request Access-Control-Allow-Origin: * Connection: keep-alive Content-Length: 79 Content-Type: application/json; charset=utf-8 Date: Sun, 16 Jun 2024 23:21:47 GMT ETag: W/"4f-PIl2ikdI5Iaf4TJBR0V5ATKtLss" Keep-Alive: timeout=5 X-Powered-By: Express

{ "data": { "error": "The request should have only undefined key" }, "success": false }

cat /tmp/testfile.txt This is a test file for ClamAV scanning.

env from clamav pod

$ env KUBERNETES_PORT=tcp://10.96.0.1:443 KUBERNETES_SERVICE_PORT=443 CLAMAV_REST_SERVICE_SERVICE_PORT=3000 CLAMAV_REST_SERVICE_PORT=tcp://10.108.68.111:3000 CLAMAV_SERVICE_PORT_3310_TCP_ADDR=10.103.127.244 API_GATEWAY_SERVICE_PORT=80 API_GATEWAY_PORT=tcp://10.106.133.31:80 NODE_VERSION=18.20.3 HOSTNAME=clamav-rest-6fd98596c6-gmlmk CLAMAV_SERVICE_PORT_3310_TCP_PORT=3310 YARN_VERSION=1.22.19 CLAMD_HOST=clamav-service CLAMAV_SERVICE_PORT_3310_TCP_PROTO=tcp HOME=/home/node OLDPWD=/ API_GATEWAY_PORT_80_TCP_ADDR=10.106.133.31 CLAMAV_SERVICE_SERVICE_HOST=10.103.127.244 API_GATEWAY_PORT_80_TCP_PORT=80 CLAMD_PORT=3310 API_GATEWAY_PORT_80_TCP_PROTO=tcp CLAMAV_SERVICE_PORT_3310_TCP=tcp://10.103.127.244:3310 CLAMAV_SERVICE_PORT=tcp://10.103.127.244:3310 CLAMAV_SERVICE_SERVICE_PORT=3310 TERM=xterm KUBERNETES_PORT_443_TCP_ADDR=10.96.0.1 CLAMAV_REST_SERVICE_PORT_3000_TCP_ADDR=10.108.68.111 API_GATEWAY_PORT_80_TCP=tcp://10.106.133.31:80 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin KUBERNETES_PORT_443_TCP_PORT=443 CLAMAV_REST_SERVICE_PORT_3000_TCP_PORT=3000 KUBERNETES_PORT_443_TCP_PROTO=tcp CLAMAV_REST_SERVICE_PORT_3000_TCP_PROTO=tcp KUBERNETES_SERVICE_PORT_HTTPS=443 KUBERNETES_PORT_443_TCP=tcp://10.96.0.1:443 CLAMAV_REST_SERVICE_PORT_3000_TCP=tcp://10.108.68.111:3000 CLAMAV_REST_SERVICE_SERVICE_HOST=10.108.68.111 KUBERNETES_SERVICE_HOST=10.96.0.1 PWD=/tmp API_GATEWAY_SERVICE_HOST=10.106.133.31

benzino77 commented 5 months ago

Can you provide env information from CRA pod?

ChadCarroll commented 5 months ago

Something was definitely with my env. I redeployed using the example yml you provided and it's working now. Thank you!