Skip to content

Commit 8b4bf1e

Browse files
committed
JS: Make API nodes and labels local
1 parent 90c3098 commit 8b4bf1e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

javascript/ql/lib/semmle/javascript/ApiGraphs.qll

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,7 @@ module API {
735735
*/
736736
cached
737737
private module Impl {
738+
overlay[local]
738739
cached
739740
newtype TApiNode =
740741
MkRoot() or
@@ -1600,6 +1601,7 @@ module API {
16001601
class NewNode extends InvokeNode, DataFlow::NewNode { }
16011602

16021603
/** Provides classes modeling the various edges (labels) in the API graph. */
1604+
overlay[local]
16031605
module Label {
16041606
/** A label in the API-graph */
16051607
class ApiLabel extends TLabel {
@@ -1638,6 +1640,7 @@ module API {
16381640
* This is to support code patterns where the property name is actually constant,
16391641
* but the property name has been factored into a library.
16401642
*/
1643+
overlay[global]
16411644
private string getAnIndirectPropName(DataFlow::PropRef ref) {
16421645
exists(DataFlow::Node pred |
16431646
FlowSteps::propertyFlowStep(pred, ref.getPropertyNameExpr().flow()) and
@@ -1648,16 +1651,19 @@ module API {
16481651
/**
16491652
* Gets unique result of `getAnIndirectPropName` if there is one.
16501653
*/
1654+
overlay[global]
16511655
private string getIndirectPropName(DataFlow::PropRef ref) {
16521656
result = unique(string s | s = getAnIndirectPropName(ref))
16531657
}
16541658

1659+
overlay[global]
16551660
pragma[nomagic]
16561661
private predicate isEnumeratedPropName(DataFlow::Node node) {
16571662
node.getAPredecessor*() instanceof EnumeratedPropName
16581663
}
16591664

16601665
/** Gets the `member` edge label for the given property reference. */
1666+
overlay[global]
16611667
ApiLabel memberFromRef(DataFlow::PropRef pr) {
16621668
exists(string pn | pn = pr.getPropertyName() or pn = getIndirectPropName(pr) |
16631669
result = member(pn) and
@@ -1724,9 +1730,17 @@ module API {
17241730
MkLabelInstance() or
17251731
MkLabelContent(DataFlow::Content content) or
17261732
MkLabelMember(string name) {
1727-
name instanceof PropertyName
1733+
name instanceof ContentPrivate::PropertyName
1734+
or
1735+
name = any(DataFlow::PropRef pr).getPropertyName()
1736+
or
1737+
AccessPath::isAssignedInUniqueFile(name)
1738+
or
1739+
exists(AccessPath::getAnAssignmentTo(_, name))
1740+
or
1741+
name = DataFlow::PseudoProperties::arrayLikeElement()
17281742
or
1729-
exists(Impl::MkTypeUse(_, name))
1743+
name = any(TypeAccess t).getIdentifier().getName()
17301744
} or
17311745
MkLabelParameter(int i) {
17321746
i =

0 commit comments

Comments
 (0)