File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
test/query-tests/Performance/ReDoS/lib/sublib Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ DataFlow::ParameterNode getALibraryInputParameter() {
1616 )
1717}
1818
19+ private import NodeModuleResolutionImpl as NodeModule
20+
1921/**
2022 * Gets a value exported by the main module from a named `package.json` file.
2123 */
@@ -77,11 +79,18 @@ private DataFlow::Node getAValueExportedByPackage() {
7779 // ....
7880 // }));
7981 // ```
82+ // Such files are not recognized as modules, so we manually use `NodeModule::resolveMainModule` to resolve the file against a `package.json` file.
8083 exists ( ImmediatelyInvokedFunctionExpr func , DataFlow:: ParameterNode prev , int i |
8184 prev .getName ( ) = "factory" and
8285 func .getParameter ( i ) = prev .getParameter ( ) and
8386 result = func .getInvocation ( ) .getArgument ( i ) .flow ( ) .getAFunctionValue ( ) .getAReturn ( ) and
84- DataFlow:: globalVarRef ( "define" ) .getACall ( ) .getArgument ( 1 ) = prev .getALocalUse ( )
87+ DataFlow:: globalVarRef ( "define" ) .getACall ( ) .getArgument ( 1 ) = prev .getALocalUse ( ) and
88+ func .getFile ( ) =
89+ min ( int j , File f |
90+ f = NodeModule:: resolveMainModule ( any ( PackageJSON pack | exists ( pack .getPackageName ( ) ) ) , j )
91+ |
92+ f order by j
93+ )
8594 )
8695 or
8796 // the exported value is a call to a unique callee
Original file line number Diff line number Diff line change 11{
22 "name" : " my-sub-lib" ,
33 "version" : " 0.0.7" ,
4- "main" : " ./my-file .js"
4+ "main" : " ./factory .js"
55}
You can’t perform that action at this time.
0 commit comments