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() {
16
16
)
17
17
}
18
18
19
+ private import NodeModuleResolutionImpl as NodeModule
20
+
19
21
/**
20
22
* Gets a value exported by the main module from a named `package.json` file.
21
23
*/
@@ -77,11 +79,18 @@ private DataFlow::Node getAValueExportedByPackage() {
77
79
// ....
78
80
// }));
79
81
// ```
82
+ // Such files are not recognized as modules, so we manually use `NodeModule::resolveMainModule` to resolve the file against a `package.json` file.
80
83
exists ( ImmediatelyInvokedFunctionExpr func , DataFlow:: ParameterNode prev , int i |
81
84
prev .getName ( ) = "factory" and
82
85
func .getParameter ( i ) = prev .getParameter ( ) and
83
86
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
+ )
85
94
)
86
95
or
87
96
// the exported value is a call to a unique callee
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " my-sub-lib" ,
3
3
"version" : " 0.0.7" ,
4
- "main" : " ./my-file .js"
4
+ "main" : " ./factory .js"
5
5
}
You can’t perform that action at this time.
0 commit comments