From 5ae72f61c755ede06683c6249cb42cbb058917de Mon Sep 17 00:00:00 2001 From: Peter McKee Date: Tue, 24 Sep 2024 21:24:16 -0400 Subject: [PATCH] Resolve false postive in S5693 for multer storage engine init --- packages/jsts/src/rules/S5693/rule.ts | 4 ++++ packages/jsts/src/rules/S5693/unit.test.ts | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/packages/jsts/src/rules/S5693/rule.ts b/packages/jsts/src/rules/S5693/rule.ts index 9c8b22c5701..fe296992c56 100644 --- a/packages/jsts/src/rules/S5693/rule.ts +++ b/packages/jsts/src/rules/S5693/rule.ts @@ -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; diff --git a/packages/jsts/src/rules/S5693/unit.test.ts b/packages/jsts/src/rules/S5693/unit.test.ts index 3e077ed634d..f8c625d8090 100644 --- a/packages/jsts/src/rules/S5693/unit.test.ts +++ b/packages/jsts/src/rules/S5693/unit.test.ts @@ -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, },