Skip to content

Commit 8b4b578

Browse files
author
Max Schaefer
committed
JavaScript: Add utility predicate getBasePortal(i).
This iterates the existing `getBasePortal()` predicate `i` times.
1 parent bb9c888 commit 8b4b578

File tree

1 file changed

+14
-0
lines changed
  • javascript/ql/src/semmle/javascript/dataflow

1 file changed

+14
-0
lines changed

javascript/ql/src/semmle/javascript/dataflow/Portals.qll

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,20 @@ class Portal extends TPortal {
9696
cached
9797
ReturnPortal getReturn() { result.getBasePortal() = this }
9898

99+
/**
100+
* Gets the `i`th base portal of this portal.
101+
*
102+
* The `0`th base portal is the portal itself, the `n+1`st base portal is the `n`th base portal
103+
* of the portal `p` of which this is a member, instance, parameter, or return portal.
104+
*/
105+
cached
106+
Portal getBasePortal(int i) {
107+
i = 0 and
108+
result = this
109+
or
110+
result = this.(CompoundPortal).getBasePortal().getBasePortal(i - 1)
111+
}
112+
99113
/**
100114
* Gets a textual representation of this portal.
101115
*

0 commit comments

Comments
 (0)