Closed xvisionbelgium closed 1 year ago
What is a value set for APP_FORM_KEY
in your .env
(or in your environemnt) and how do you make a POST call to CRA?
Have you run npm install
in your CRA directory as stated in the README?
Yes, did the following Cloned the repo Npm install Npm start
.env file is the following
NODE_ENV=production
APP_PORT=3000 APP_FORM_KEY=FILES APP_MORGAN_LOG_FORMAT=combined APP_MAX_FILE_SIZE=26214400 APP_MAX_FILES_NUMBER=4
CLAMD_IP=127.0.0.1 CLAMD_PORT=3310 CLAMD_TIMEOUT=30000 You can also start clamav-rest-api by cloning the repo and run commands listed below: npm install npm install -D # if you want to run tests or examples
npm start
From: benzino77 @.> Sent: Wednesday, January 25, 2023 2:42 PM To: benzino77/clamav-rest-api @.> Cc: Johan Hamelinck (XV) @.>; Author @.> Subject: Re: [benzino77/clamav-rest-api] TypeError: req.files.hasOwnProperty is not a function (Issue #44)
Have you run npm install in your CRA directory as stated in the READMEhttps://github.com/benzino77/clamav-rest-api#how-to-start-clamav-rest-api?
— Reply to this email directly, view it on GitHubhttps://github.com/benzino77/clamav-rest-api/issues/44#issuecomment-1403639239, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIWYDZ7DETMQP77PGP7LSIDWUEUSFANCNFSM6AAAAAAUGI7J4M. You are receiving this because you authored the thread.Message ID: @.**@.>>
If I comment out the test in the code, the scanning works file
From: benzino77 @.> Sent: Wednesday, January 25, 2023 2:38 PM To: benzino77/clamav-rest-api @.> Cc: Johan Hamelinck (XV) @.>; Author @.> Subject: Re: [benzino77/clamav-rest-api] TypeError: req.files.hasOwnProperty is not a function (Issue #44)
What is a value set for APP_FORM_KEY in your .env (or in your environemnt) and how do you make a POST call to CRA?
— Reply to this email directly, view it on GitHubhttps://github.com/benzino77/clamav-rest-api/issues/44#issuecomment-1403635174, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIWYDZY6FDJ7Y5A4CVVV7YTWUEUFBANCNFSM6AAAAAAUGI7J4M. You are receiving this because you authored the thread.Message ID: @.**@.>>
Which line/lines do you comment out?
/ const hasProperKey = req.files.hasOwnProperty(process.env.APP_FORM_KEY); if (!hasProperKey || passedFilesLength > 1) { return invalidFormKeyError; } /
In checkParams.js
From: benzino77 @.> Sent: Wednesday, January 25, 2023 2:50 PM To: benzino77/clamav-rest-api @.> Cc: Johan Hamelinck (XV) @.>; Author @.> Subject: Re: [benzino77/clamav-rest-api] TypeError: req.files.hasOwnProperty is not a function (Issue #44)
Which line/lines do you comment out?
— Reply to this email directly, view it on GitHubhttps://github.com/benzino77/clamav-rest-api/issues/44#issuecomment-1403655327, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIWYDZ7QPDAIVEFZ2TACO23WUEVR3ANCNFSM6AAAAAAUGI7J4M. You are receiving this because you authored the thread.Message ID: @.**@.>>
Hi
APP_FORM_KEY is FILES as default I’ve debugged (with console.write) the values and they seem correct
From: benzino77 @.> Sent: Wednesday, January 25, 2023 2:38 PM To: benzino77/clamav-rest-api @.> Cc: Johan Hamelinck (XV) @.>; Author @.> Subject: Re: [benzino77/clamav-rest-api] TypeError: req.files.hasOwnProperty is not a function (Issue #44)
What is a value set for APP_FORM_KEY in your .env (or in your environemnt) and how do you make a POST call to CRA?
— Reply to this email directly, view it on GitHubhttps://github.com/benzino77/clamav-rest-api/issues/44#issuecomment-1403635174, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIWYDZY6FDJ7Y5A4CVVV7YTWUEUFBANCNFSM6AAAAAAUGI7J4M. You are receiving this because you authored the thread.Message ID: @.**@.>>
How do you make a POST call to CRA?
I‘m testing with Postman
@.***
From: benzino77 @.> Sent: Wednesday, January 25, 2023 2:54 PM To: benzino77/clamav-rest-api @.> Cc: Johan Hamelinck (XV) @.>; Author @.> Subject: Re: [benzino77/clamav-rest-api] TypeError: req.files.hasOwnProperty is not a function (Issue #44)
How do you make a POST call to CRA?
— Reply to this email directly, view it on GitHubhttps://github.com/benzino77/clamav-rest-api/issues/44#issuecomment-1403659543, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIWYDZ6DSGUUAUUUY4VKLXTWUEV55ANCNFSM6AAAAAAUGI7J4M. You are receiving this because you authored the thread.Message ID: @.**@.>>
How do you set Postman "Body tab"
Seems that my screenshot that I’ve added came not through… Set up like described in your README.md
Screenshot : https://1drv.ms/u/s!AiMpBVIUzr5T33OmZ1pfAcvJGErK?e=AbaZE9
From: benzino77 @.> Sent: Wednesday, January 25, 2023 3:01 PM To: benzino77/clamav-rest-api @.> Cc: Johan Hamelinck (XV) @.>; Author @.> Subject: Re: [benzino77/clamav-rest-api] TypeError: req.files.hasOwnProperty is not a function (Issue #44)
How do you set Postman "Body tab"
— Reply to this email directly, view it on GitHubhttps://github.com/benzino77/clamav-rest-api/issues/44#issuecomment-1403668769, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIWYDZ24OB4KG5G2H6Q6YHDWUEWYZANCNFSM6AAAAAAUGI7J4M. You are receiving this because you authored the thread.Message ID: @.**@.>>
If I dump req.files object ( console.write(req.files) )
From: benzino77 @.> Sent: Wednesday, January 25, 2023 3:01 PM To: benzino77/clamav-rest-api @.> Cc: Johan Hamelinck (XV) @.>; Author @.> Subject: Re: [benzino77/clamav-rest-api] TypeError: req.files.hasOwnProperty is not a function (Issue #44)
How do you set Postman "Body tab"
— Reply to this email directly, view it on GitHubhttps://github.com/benzino77/clamav-rest-api/issues/44#issuecomment-1403668769, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIWYDZ24OB4KG5G2H6Q6YHDWUEWYZANCNFSM6AAAAAAUGI7J4M. You are receiving this because you authored the thread.Message ID: @.**@.>>
That is strange. I cannot reproduce your problem. Try to delete node_modules
directory (or do a fresh clone of the repo) run npm install
and try again.
Hint: do not upgrade express-filesupload
package.
Tried it… same problem
From: benzino77 @.> Sent: Wednesday, January 25, 2023 5:15 PM To: benzino77/clamav-rest-api @.> Cc: Johan Hamelinck (XV) @.>; Author @.> Subject: Re: [benzino77/clamav-rest-api] TypeError: req.files.hasOwnProperty is not a function (Issue #44)
That is strange. I cannot reproduce your problem. Try to delete node_modules directory (or do a fresh clone of the repo) run npm install and try again. [Screenshot from 2023-01-25 17-07-16]https://user-images.githubusercontent.com/15658235/214615920-e1c92d9a-f132-4ac9-bdd4-cce1c59adb45.png
— Reply to this email directly, view it on GitHubhttps://github.com/benzino77/clamav-rest-api/issues/44#issuecomment-1403865378, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIWYDZ2UQ3JY5NTYJIIEDQLWUFGO3ANCNFSM6AAAAAAUGI7J4M. You are receiving this because you authored the thread.Message ID: @.**@.>>
This seems to do the trick… forced it to v1.1.9 But now I got a extra vulnerability warning…
From: benzino77 @.> Sent: Wednesday, January 25, 2023 5:44 PM To: benzino77/clamav-rest-api @.> Cc: Johan Hamelinck (XV) @.>; Author @.> Subject: Re: [benzino77/clamav-rest-api] TypeError: req.files.hasOwnProperty is not a function (Issue #44)
Hint: do not upgrade express-filesupload package.
— Reply to this email directly, view it on GitHubhttps://github.com/benzino77/clamav-rest-api/issues/44#issuecomment-1403910152, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIWYDZ5UQC3P4F6CIGXSZATWUFJ6PANCNFSM6AAAAAAUGI7J4M. You are receiving this because you authored the thread.Message ID: @.**@.>>
If you are using CRA as it is, you don't have to "force" anything. That is what package*.json
files are for. To install proper versions of libraries for a project.
It breaks if express-fileupload is 1.3.0 or higher 1.2.1 works fine
From: benzino77 @.> Sent: Wednesday, January 25, 2023 6:02 PM To: benzino77/clamav-rest-api @.> Cc: Johan Hamelinck (XV) @.>; Author @.> Subject: Re: [benzino77/clamav-rest-api] TypeError: req.files.hasOwnProperty is not a function (Issue #44)
If you are using CRA as it is, you don't have to "force" anything. That is what package*.json files are for. To install proper versions of libraries for a project.
— Reply to this email directly, view it on GitHubhttps://github.com/benzino77/clamav-rest-api/issues/44#issuecomment-1403936385, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AIWYDZ7CQTP32KJMHRLQ4YTWUFL6ZANCNFSM6AAAAAAUGI7J4M. You are receiving this because you authored the thread.Message ID: @.**@.>>
You can pull the latest version of CRA which is using latest express-fileupload
.
Environment : NodeJS v16.18.1 on CentOS 7
We are getting the error when postng a file. Any idea how to fix this ?
/home/xvision/node/clamav-rest-api/src/utils/checkParams.js:20 const hasProperKey = req.files.hasOwnProperty(process.env.APP_FORM_KEY);
TypeError: req.files.hasOwnProperty is not a function at checkParams (/home/xvision/node/clamav-rest-api/src/utils/checkParams.js:20:34) at /home/xvision/node/clamav-rest-api/src/routes/scan.js:10:24 at Layer.handle [as handle_request] (/home/xvision/node/clamav-rest-api/node_modules/express/lib/router/layer.js:95:5) at next (/home/xvision/node/clamav-rest-api/node_modules/express/lib/router/route.js:144:13) at Route.dispatch (/home/xvision/node/clamav-rest-api/node_modules/express/lib/router/route.js:114:3) at Layer.handle [as handle_request] (/home/xvision/node/clamav-rest-api/node_modules/express/lib/router/layer.js:95:5) at /home/xvision/node/clamav-rest-api/node_modules/express/lib/router/index.js:284:15 at Function.process_params (/home/xvision/node/clamav-rest-api/node_modules/express/lib/router/index.js:346:12) at next (/home/xvision/node/clamav-rest-api/node_modules/express/lib/router/index.js:280:10) at Function.handle (/home/xvision/node/clamav-rest-api/node_modules/express/lib/router/index.js:175:3)