JS: handle deeper access paths in Closure::moduleImport

This commit is contained in:
Asger F
2019-02-25 12:31:18 +00:00
parent 2f6496f6bd
commit 7d14429dce
3 changed files with 18 additions and 2 deletions

View File

@@ -223,9 +223,15 @@ module Closure {
or
exists(DataFlow::SourceNode base, string basePath, string prop |
basePath = getClosureNamespaceFromSourceNode(base) and
isClosureNamespace(basePath) and
node = base.getAPropertyRead(prop) and
result = basePath + "." + prop
result = basePath + "." + prop and
// ensure finiteness
(
isClosureNamespace(basePath)
or
// direct access, no indirection
node.(DataFlow::PropRead).getBase() = base
)
)
or
// Associate an access path with the immediate RHS of a store on a closure namespace.

View File

@@ -0,0 +1 @@
| tests/nestedAccess.js:5:1:5:12 | fooBar.x.y.z |

View File

@@ -1,9 +1,16 @@
| foo.bar | tests/nestedAccess.js:3:14:3:36 | goog.re ... o.bar') |
| foo.bar.x | tests/nestedAccess.js:5:1:5:8 | fooBar.x |
| foo.bar.x | tests/nestedAccess.js:10:9:10:11 | z.x |
| foo.bar.x.y | tests/nestedAccess.js:5:1:5:10 | fooBar.x.y |
| foo.bar.x.y.z | tests/nestedAccess.js:5:1:5:12 | fooBar.x.y.z |
| goog | tests/es6Module.js:1:1:1:4 | goog |
| goog | tests/es6ModuleDefault.js:1:1:1:4 | goog |
| goog | tests/globalModule.js:1:1:1:4 | goog |
| goog | tests/globalModuleDefault.js:1:1:1:4 | goog |
| goog | tests/googModule.js:1:1:1:4 | goog |
| goog | tests/googModuleDefault.js:1:1:1:4 | goog |
| goog | tests/nestedAccess.js:1:1:1:4 | goog |
| goog | tests/nestedAccess.js:3:14:3:17 | goog |
| goog | tests/requireFromEs6.js:3:20:3:23 | goog |
| goog | tests/requireFromEs6.js:4:27:4:30 | goog |
| goog | tests/requireFromEs6.js:6:17:6:20 | goog |
@@ -29,12 +36,14 @@
| goog.declareModuleId | tests/es6ModuleDefault.js:1:1:1:20 | goog.declareModuleId |
| goog.module | tests/googModule.js:1:1:1:11 | goog.module |
| goog.module | tests/googModuleDefault.js:1:1:1:11 | goog.module |
| goog.module | tests/nestedAccess.js:1:1:1:11 | goog.module |
| goog.module | tests/requireFromGoogModule.js:1:1:1:11 | goog.module |
| goog.module | tests/uri.js:1:1:1:11 | goog.module |
| goog.net | tests/uri.js:3:11:3:34 | goog.re ... g.net') |
| goog.net.Uri | tests/uri.js:5:5:5:11 | net.Uri |
| goog.provide | tests/globalModule.js:1:1:1:12 | goog.provide |
| goog.provide | tests/globalModuleDefault.js:1:1:1:12 | goog.provide |
| goog.require | tests/nestedAccess.js:3:14:3:25 | goog.require |
| goog.require | tests/requireFromEs6.js:3:20:3:31 | goog.require |
| goog.require | tests/requireFromEs6.js:4:27:4:38 | goog.require |
| goog.require | tests/requireFromEs6.js:6:17:6:28 | goog.require |