Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix S5693: Resolve false positive for multer storage engine init #4886

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/jsts/src/rules/S5693/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ function checkFormidable(context: Rule.RuleContext, callExpression: estree.CallE
}

function checkMulter(context: Rule.RuleContext, callExpression: estree.CallExpression) {
if (callExpression.callee.type === 'MemberExpression') {
return;
}

if (callExpression.arguments.length === 0) {
report(context, callExpression.callee);
return;
Expand Down
8 changes: 8 additions & 0 deletions packages/jsts/src/rules/S5693/unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ ruleTester.run('Allowing requests with excessive content length is security-sens
code: `
const multer = require('multer');
const upload = multer(options);
const storage = multer.diskStorage({
destination: function (req, file, cb) {
cb(null, '/tmp/my-uploads')
},
filename: function (req, file, cb) {
cb(null, file.fieldname)
}
});
`,
options,
},
Expand Down