File tree 1 file changed +3
-9
lines changed
javascript/ql/lib/semmle/javascript
1 file changed +3
-9
lines changed Original file line number Diff line number Diff line change 6
6
7
7
import javascript
8
8
private import semmle.javascript.internal.CachedStages
9
+ private import semmle.javascript.internal.paths.PackageJsonEx
9
10
10
11
/**
11
12
* Gets a parameter that is a library input to a top-level package.
@@ -126,19 +127,12 @@ private DataFlow::Node getAValueExportedByPackage() {
126
127
// ....
127
128
// }));
128
129
// ```
129
- // Such files are not recognized as modules, so we manually use `NodeModule::resolveMainModule ` to resolve the file against a `package.json` file.
130
+ // Such files are not recognized as modules, so we manually use `PackageJsonEx ` to resolve the file against a `package.json` file.
130
131
exists ( ImmediatelyInvokedFunctionExpr func , DataFlow:: ParameterNode factory , int i |
131
132
factory .getName ( ) = "factory" and
132
133
func .getParameter ( i ) = factory .getParameter ( ) and
133
134
DataFlow:: globalVarRef ( "define" ) .getACall ( ) .getAnArgument ( ) = factory .getALocalUse ( ) and
134
- func .getFile ( ) =
135
- min ( int j , File f |
136
- f =
137
- NodeModule:: resolveMainModule ( any ( PackageJson pack | exists ( pack .getPackageName ( ) ) ) , j ,
138
- "." )
139
- |
140
- f order by j
141
- )
135
+ func .getFile ( ) = any ( PackageJsonEx pack ) .getMainFileOrBestGuess ( )
142
136
|
143
137
result = func .getInvocation ( ) .getArgument ( i ) .flow ( ) .getAFunctionValue ( ) .getAReturn ( )
144
138
or
You can’t perform that action at this time.
0 commit comments