@@ -408,11 +408,13 @@ module NodeJSLib {
408
408
409
409
/**
410
410
* Holds if the `i`th parameter of method `methodName` of the Node.js
411
- * `fs` module might represent a file path.
411
+ * `fs` module or the `fs-extra` module might represent a file path.
412
412
*
413
- * We determine this by looking for an externs declaration for
413
+ * For `fs`, we determine this by looking for an externs declaration for
414
414
* `fs.methodName` where the `i`th parameter's name is `filename` or
415
415
* `path` or a variation thereof.
416
+ *
417
+ * For `fs-extra`, we use a manually maintained list.
416
418
*/
417
419
private predicate fsFileParam ( string methodName , int i ) {
418
420
exists ( ExternalMemberDecl decl , Function f , JSDocParamTag p , string n |
@@ -423,6 +425,47 @@ module NodeJSLib {
423
425
|
424
426
n = "filename" or n .regexpMatch ( "(old|new|src|dst|)path" )
425
427
)
428
+ or
429
+ fsExtraExtensionFileParam ( methodName , i )
430
+ }
431
+
432
+ /**
433
+ * Holds if `methodName` is a function defined in the `fs-extra` library
434
+ * as an extension to node.js' `fs` module and parameter `i` of of the
435
+ * method might represent a file path.
436
+ */
437
+ private predicate fsExtraExtensionFileParam ( string methodName , int i ) {
438
+ methodName = [ "copy" , "copySync" , "copyFile" ] and i = [ 0 , 1 ]
439
+ or
440
+ methodName = [ "move" , "moveSync" ] and i = [ 0 , 1 ]
441
+ or
442
+ methodName = [ "createFile" , "createFileSync" ] and i = 0
443
+ or
444
+ methodName = [ "createSymLink" , "createSymlinkSync" ] and i = [ 0 , 1 ]
445
+ or
446
+ methodName = [ "ensureDir" , "ensureDirSync" ] and i = 0
447
+ or
448
+ methodName = [ "mkdirs" , "mkdirp" , "mkdirsSync" , "mkdirpSync" ] and i = 0
449
+ or
450
+ methodName = [ "outputFile" , "outputFileSync" ] and i = 0
451
+ or
452
+ methodName = [ "readJson" , "readJSON" , "readJsonSync" , "readJSONSync" ] and i = 0
453
+ or
454
+ methodName = [ "remove" , "removeSync" ] and i = 0
455
+ or
456
+ methodName =
457
+ [ "outputJSON" , "outputJson" , "writeJSON" , "writeJson" , "writeJSONSync" , "writeJsonSync" ] and
458
+ i = 0
459
+ or
460
+ methodName = [ "ensureFile" , "ensureFileSync" ] and i = 0
461
+ or
462
+ methodName = [ "ensureLink" , "createLink" , "ensureLinkSync" , "createLinkSync" ] and i = [ 0 , 1 ]
463
+ or
464
+ methodName = [ "ensureSymlink" , "ensureSymlinkSync" ] and i = [ 0 , 1 ]
465
+ or
466
+ methodName = [ "emptyDir" , "emptyDirSync" ] and i = 0
467
+ or
468
+ methodName = [ "pathExists" , "pathExistsSync" ] and i = 0
426
469
}
427
470
428
471
/**
0 commit comments