NodeSecure / js-x-ray

JavaScript & Node.js open-source SAST scanner. A static analyser for detecting most common malicious patterns 🔬.
MIT License
229 stars 26 forks source link

Report.isOneLineRequire should be true if single line LogicalExpression assignment #205

Closed jean-michelet closed 9 months ago

jean-michelet commented 9 months ago

EDIT: After exchanges with @fraxken, we need to check the LogicalExpression (left, right) and ConditionalExpression (consequent, alternate).


This pull request addresses issue #168.

I added an AST check to ensure that files containing only one line and composed of a LogicalExpression assignation, typically an export: module.exports = require('fs') || require('constants'), are considered as not minified.