0

nodejsには以下のコードがあります

int i = _.get(req.body, "i")
res.send(i);

checkmarx が上記のコードを見つけると、サニタイズして検証する必要があると表示されます。この問題を解決する方法を教えてください。

前もって感謝します

4

2 に答える 2

0
int i = _.get(req.body, "i") res.send(i);
Issue : 
Here you are setting your response fetching value from request body, which embeds untrusted data in the generated output with send. This untrusted data is embedded straight into the output without proper sanitization.

Solution :
Sanitize request body attributes before setting it to response
requestSanitizer.setOptions({
    body :{
        name : [validator.escape,validator.ltrim],
        test : [validator.ltrim]
    }
});

you must first import these packages : 
var requestSanitizer = require('request-sanitizer')();
var validator = requestSanitizer.validator;

and then finally set requestSanitizer  as an additional param to API call
于 2021-02-17T05:11:56.000 に答える