@@ -10,11 +10,9 @@ import {
1010 getCallExpressionIdentifier ,
1111 getCallExpressionArguments
1212} from "@nodesecure/estree-ast-utils" ;
13-
14- // Import Internal Dependencies
1513import { ProbeSignals } from "../ProbeRunner.js" ;
1614
17- function validateNode ( node , { tracer } ) {
15+ function validateNodeRequire ( node , { tracer } ) {
1816 const id = getCallExpressionIdentifier ( node ) ;
1917 if ( id === null ) {
2018 return [ false ] ;
@@ -24,19 +22,46 @@ function validateNode(node, { tracer }) {
2422
2523 return [
2624 data !== null && data . name === "require" ,
27- data ?. identifierOrMemberExpr ?? void 0
25+ id ?? void 0
26+ ] ;
27+ }
28+
29+ function validateNodeEvalRequire ( node ) {
30+ const id = getCallExpressionIdentifier ( node ) ;
31+
32+ if ( id !== "eval" ) {
33+ return [ false ] ;
34+ }
35+ if ( node . callee . type !== "CallExpression" ) {
36+ return [ false ] ;
37+ }
38+
39+ const args = getCallExpressionArguments ( node . callee ) ;
40+
41+ return [
42+ args . length > 0 && args . at ( 0 ) === "require" ,
43+ id
2844 ] ;
2945}
3046
47+ function teardown ( { analysis } ) {
48+ analysis . dependencyAutoWarning = false ;
49+ }
50+
51+
3152function main ( node , options ) {
32- const { analysis } = options ;
53+ const { analysis, data : calleeName } = options ;
3354 const { tracer } = analysis ;
3455
3556 if ( node . arguments . length === 0 ) {
3657 return ;
3758 }
3859 const arg = node . arguments . at ( 0 ) ;
3960
61+ if ( calleeName === "eval" ) {
62+ analysis . dependencyAutoWarning = true ;
63+ }
64+
4065 switch ( arg . type ) {
4166 // const foo = "http"; require(foo);
4267 case "Identifier" :
@@ -163,7 +188,7 @@ function walkRequireCallExpression(nodeToWalk, tracer) {
163188
164189export default {
165190 name : "isRequire" ,
166- validateNode,
191+ validateNode : [ validateNodeRequire , validateNodeEvalRequire ] ,
167192 main,
168193 breakOnMatch : true ,
169194 breakGroup : "import"
0 commit comments