File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
docs/language/learn-ql/javascript Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,49 @@ String matching
160160- x.\ `regexpMatch <https://help.semmle.com/qldoc/javascript/predicate.string$regexpMatch.1.html >`__\ ("(?i).*escape.*") -- holds if x contains
161161 "escape" (case insensitive)
162162
163+ Type tracking
164+ -------------
165+
166+ See also: :doc: `Type tracking tutorial <type-tracking >`.
167+
168+ Use the following template to define forward type tracking predicates:
169+
170+ .. code-block :: ql
171+
172+ import DataFlow
173+
174+ SourceNode myType(TypeTracker t) {
175+ t.start() and
176+ result = /* SourceNode to track */
177+ or
178+ exists(TypeTracker t2 |
179+ result = myType(t2).track(t2, t)
180+ )
181+ }
182+
183+ SourceNode myType() {
184+ result = myType(TypeTracker::end())
185+ }
186+
187+ Use the following template to define backward type tracking predicates:
188+
189+ .. code-block :: ql
190+
191+ import DataFlow
192+
193+ SourceNode myType(TypeBackTracker t) {
194+ t.start() and
195+ result = (/* argument to track */).getALocalSource()
196+ or
197+ exists(TypeBackTracker t2 |
198+ result = myType(t2).backtrack(t2, t)
199+ )
200+ }
201+
202+ SourceNode myType() {
203+ result = myType(TypeBackTracker::end())
204+ }
205+
163206 Troubleshooting
164207---------------
165208
You can’t perform that action at this time.
0 commit comments