Skip to content

Commit 3337eaf

Browse files
author
Shati Patel
committed
Docs: Update JavaScript/TypeScript
1 parent d94b0ca commit 3337eaf

File tree

8 files changed

+89
-87
lines changed

8 files changed

+89
-87
lines changed

docs/language/learn-ql/javascript/ast-class-reference.rst

Lines changed: 12 additions & 12 deletions
Large diffs are not rendered by default.

docs/language/learn-ql/javascript/dataflow-cheat-sheet.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
Data flow cheat sheet
22
=====================
33

4-
This page describes parts of the JavaScript QL libraries commonly used for variant analysis and in data flow queries.
4+
This page describes parts of the JavaScript libraries commonly used for variant analysis and in data flow queries.
55

66
Taint tracking path queries
77
---------------------------
88

99
Use the following template to create a taint tracking path query:
1010

11-
.. code-block:: ql
11+
.. code-block:: ql
1212
1313
/**
1414
* @kind path-problem
@@ -134,10 +134,10 @@ Files
134134

135135
- `File <https://help.semmle.com/qldoc/javascript/semmle/javascript/Files.qll/type.Files$File.html>`__,
136136
`Folder <https://help.semmle.com/qldoc/javascript/semmle/javascript/Files.qll/type.Files$Folder.html>`__ extends
137-
`Container <https://help.semmle.com/qldoc/javascript/semmle/javascript/Files.qll/type.Files$Container.html>`__ -- file or folder in the snapshot
137+
`Container <https://help.semmle.com/qldoc/javascript/semmle/javascript/Files.qll/type.Files$Container.html>`__ -- file or folder in the database
138138

139139
- `getBaseName <https://help.semmle.com/qldoc/javascript/semmle/javascript/Files.qll/predicate.Files$Container$getBaseName.0.html>`__ -- the name of the file or folder
140-
- `getRelativePath <https://help.semmle.com/qldoc/javascript/semmle/javascript/Files.qll/predicate.Files$Container$getRelativePath.0.html>`__ -- path relative to the snapshot root
140+
- `getRelativePath <https://help.semmle.com/qldoc/javascript/semmle/javascript/Files.qll/predicate.Files$Container$getRelativePath.0.html>`__ -- path relative to the database root
141141

142142
AST nodes
143143
---------

docs/language/learn-ql/javascript/dataflow.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ Analyzing data flow in JavaScript and TypeScript
44
Overview
55
--------
66

7-
This topic describes how data flow analysis is implemented in the QL libraries for JavaScript/TypeScript and includes examples to help you write your own data flow queries.
8-
The following sections describe how to utilize the QL libraries for local data flow, global data flow, and taint tracking.
7+
This topic describes how data flow analysis is implemented in the CodeQL libraries for JavaScript/TypeScript and includes examples to help you write your own data flow queries.
8+
The following sections describe how to utilize the libraries for local data flow, global data flow, and taint tracking.
99

1010
As our running example, we will develop a query that identifies command-line arguments that are passed as a file path to the standard Node.js ``readFile`` function.
1111
While this is not a problematic pattern as such, it is typical of the kind of reasoning that is frequently used in security queries.
1212

13-
For a more general introduction to modeling data flow in QL, see :doc:`Introduction to data flow analysis in QL <../intro-to-data-flow>`.
13+
For a more general introduction to modeling data flow, see :doc:`Introduction to data flow analysis with CodeQL <../intro-to-data-flow>`.
1414

1515
Data flow nodes
1616
---------------
@@ -174,7 +174,7 @@ There are two points worth making about the source node API:
174174
2. Strings are not source nodes and cannot be tracked using this API. You can, however, use the ``mayHaveStringValue`` predicate on class ``DataFlow::Node``
175175
to reason about the possible string values flowing into a data flow node.
176176

177-
For a full description of the ``DataFlow::SourceNode`` API, see the `QL JavaScript standard library <https://help.semmle.com/qldoc/javascript/semmle/javascript/dataflow/Sources.qll/type.Sources$SourceNode.html>`__.
177+
For a full description of the ``DataFlow::SourceNode`` API, see the `JavaScript standard library <https://help.semmle.com/qldoc/javascript/semmle/javascript/dataflow/Sources.qll/type.Sources$SourceNode.html>`__.
178178

179179
Exercises
180180
~~~~~~~~~

docs/language/learn-ql/javascript/flow-labels.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,6 @@ string may be an absolute path and whether it may contain ``..`` components.
393393
What next?
394394
----------
395395

396-
- Learn about the QL standard libraries used to write queries for JavaScript in :doc:`Introducing the JavaScript libraries <introduce-libraries-js>`.
396+
- Learn about the standard CodeQL libraries used to write queries for JavaScript in :doc:`Introducing the JavaScript libraries <introduce-libraries-js>`.
397397
- Find out more about QL in the `QL language handbook <https://help.semmle.com/QL/ql-handbook/index.html>`__ and `QL language specification <https://help.semmle.com/QL/ql-spec/language.html>`__.
398398
- Learn more about the query console in `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.

docs/language/learn-ql/javascript/introduce-libraries-js.rst

Lines changed: 39 additions & 39 deletions
Large diffs are not rendered by default.

docs/language/learn-ql/javascript/introduce-libraries-ts.rst

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
Introducing the QL libraries for TypeScript
2-
===========================================
1+
Introducing the CodeQL libraries for TypeScript
2+
===============================================
33

44
Overview
55
--------
66

7-
Support for analyzing TypeScript code is bundled with the JavaScript QL libraries, so you can include the full TypeScript library by importing the ``javascript.qll`` module:
7+
Support for analyzing TypeScript code is bundled with the CodeQL libraries for JavaScript, so you can include the full TypeScript library by importing the ``javascript.qll`` module:
88

99
.. code-block:: ql
1010
1111
import javascript
1212
13-
The :doc:`QL library introduction for JavaScript <introduce-libraries-js>` covers most of this library, and is also relevant for TypeScript analysis. This document supplements the JavaScript QL documentation with the TypeScript-specific classes and predicates.
13+
The :doc:`CodeQL library introduction for JavaScript <introduce-libraries-js>` covers most of this library, and is also relevant for TypeScript analysis. This document supplements the JavaScript documentation with the TypeScript-specific classes and predicates.
1414

1515
Syntax
1616
------
@@ -124,7 +124,7 @@ Select expressions that cast a value to a type parameter:
124124
Classes and interfaces
125125
~~~~~~~~~~~~~~~~~~~~~~
126126

127-
The QL class `ClassOrInterface <https://help.semmle.com/qldoc/javascript/semmle/javascript/Classes.qll/type.Classes$ClassOrInterface.html>`__ is a common supertype of classes and interfaces, and provides some TypeScript-specific member predicates:
127+
The CodeQL class `ClassOrInterface <https://help.semmle.com/qldoc/javascript/semmle/javascript/Classes.qll/type.Classes$ClassOrInterface.html>`__ is a common supertype of classes and interfaces, and provides some TypeScript-specific member predicates:
128128

129129
- ``ClassOrInterface.isAbstract()`` holds if this is an interface or a class with the ``abstract`` modifier.
130130
- ``ClassOrInterface.getASuperInterface()`` gets a type from the ``implements`` clause of a class or from the ``extends`` clause of an interface.
@@ -134,7 +134,7 @@ The QL class `ClassOrInterface <https://help.semmle.com/qldoc/javascript/semmle/
134134

135135
Note that the superclass of a class is an expression, not a type annotation. If the superclass has type arguments, it will be an expression of kind `ExpressionWithTypeArguments <https://help.semmle.com/qldoc/javascript/semmle/javascript/TypeScript.qll/type.TypeScript$ExpressionWithTypeArguments.html>`__.
136136

137-
Also see the documentation for classes in the `Introduction to the QL libraries for JavaScript <introduce-libraries-js#classes>`__.
137+
Also see the documentation for classes in the `Introduction to the CodeQL libraries for JavaScript <introduce-libraries-js#classes>`__.
138138

139139
To select the type references to a class or an interface, use ``getTypeName()``.
140140

@@ -175,6 +175,8 @@ Ambient nodes are mostly ignored by control flow and data flow analysis. The out
175175
Static type information
176176
-----------------------
177177

178+
.. TODO: Remove link to QL command-line tools below?
179+
178180
Static type information and global name binding is available for projects with "full" TypeScript extraction enabled. This option is enabled by default for projects on LGTM.com. If you are using the `QL command-line tools <https://help.semmle.com/wiki/display/SD/QL+command-line+tools>`__, you must enable it by passing ``--typescript-full`` to the JavaScript extractor. For further information on customizing calls to the extractor, see `Customizing JavaScript extraction <https://help.semmle.com/wiki/display/SD/Customizing+JavaScript+extraction>`__.
179181

180182
**Note:** Without full extraction, the classes and predicates described in this section are empty.
@@ -262,7 +264,7 @@ Additionally, ``Type`` has the following subclasses which overlap partially with
262264
Canonical names and named types
263265
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
264266

265-
``CanonicalName`` is a QL class representing a qualified name relative to a root scope, such as a module or the global scope. It typically represents an entity such as a type, namespace, variable, or function. ``TypeName`` and ``Namespace`` are subclasses of this class.
267+
``CanonicalName`` is a CodeQL class representing a qualified name relative to a root scope, such as a module or the global scope. It typically represents an entity such as a type, namespace, variable, or function. ``TypeName`` and ``Namespace`` are subclasses of this class.
266268

267269
Canonical names can be recognized using the ``hasQualifiedName`` predicate:
268270

@@ -274,7 +276,7 @@ For convenience, this predicate is also available on other classes, such as ``Ty
274276
Function types
275277
~~~~~~~~~~~~~~
276278

277-
There is no QL class for function types, as any type with a call or construct signature is usable as a function. The type ``CallSignatureType`` represents such a signature (with or without the ``new`` keyword).
279+
There is no CodeQL class for function types, as any type with a call or construct signature is usable as a function. The type ``CallSignatureType`` represents such a signature (with or without the ``new`` keyword).
278280

279281
Signatures can be obtained in several ways:
280282

@@ -353,7 +355,7 @@ TypeScript also allows you to import types and namespaces, and give them local n
353355
354356
The local name ``B`` is represented as a `LocalTypeName <https://help.semmle.com/qldoc/javascript/semmle/javascript/TypeScript.qll/type.TypeScript$LocalTypeName.html>`__ named ``B``, restricted to just the file containing the import. An import statement can also introduce a `Variable <https://help.semmle.com/qldoc/javascript/semmle/javascript/Variables.qll/type.Variables$Variable.html>`__ and a `LocalNamespaceName <https://help.semmle.com/qldoc/javascript/semmle/javascript/TypeScript.qll/type.TypeScript$LocalNamespaceName.html>`__.
355357

356-
The following table shows the relevant QL classes for working with each kind of name. The classes are described in more detail below.
358+
The following table shows the relevant classes for working with each kind of name. The classes are described in more detail below.
357359

358360
+-----------+------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
359361
| Kind | Local alias | Canonical name | Definition | Access |
@@ -419,7 +421,7 @@ Find imported names that are used as both a type and a value:
419421
Namespace names
420422
~~~~~~~~~~~~~~~
421423

422-
Namespaces are represented by the QL classes `Namespace <https://help.semmle.com/qldoc/javascript/semmle/javascript/CanonicalNames.qll/type.CanonicalNames$Namespace.html>`__ and `LocalNamespaceName <https://help.semmle.com/qldoc/javascript/semmle/javascript/TypeScript.qll/type.TypeScript$LocalNamespaceName.html>`__. The `NamespaceDefinition <https://help.semmle.com/qldoc/javascript/semmle/javascript/TypeScript.qll/type.TypeScript$NamespaceDefinition.html>`__ class represents a syntactic definition of a namespace, which includes ordinary namespace declarations as well as enum declarations.
424+
Namespaces are represented by the classes `Namespace <https://help.semmle.com/qldoc/javascript/semmle/javascript/CanonicalNames.qll/type.CanonicalNames$Namespace.html>`__ and `LocalNamespaceName <https://help.semmle.com/qldoc/javascript/semmle/javascript/TypeScript.qll/type.TypeScript$LocalNamespaceName.html>`__. The `NamespaceDefinition <https://help.semmle.com/qldoc/javascript/semmle/javascript/TypeScript.qll/type.TypeScript$NamespaceDefinition.html>`__ class represents a syntactic definition of a namespace, which includes ordinary namespace declarations as well as enum declarations.
423425

424426
Note that these classes deal exclusively with namespaces referenced from inside type annotations, not through expressions.
425427

@@ -443,6 +445,6 @@ A `LocalNamespaceName <https://help.semmle.com/qldoc/javascript/semmle/javascrip
443445
What next?
444446
----------
445447

446-
- Learn about the QL standard libraries used to write queries for JavaScript in :doc:`Introducing the Javacript libraries <introduce-libraries-js>`.
448+
- Learn about the standard CodeQL libraries used to write queries for JavaScript in :doc:`Introducing the JavaScript libraries <introduce-libraries-js>`.
447449
- Find out more about QL in the `QL language handbook <https://help.semmle.com/QL/ql-handbook/index.html>`__ and `QL language specification <https://help.semmle.com/QL/ql-spec/language.html>`__.
448450
- Learn more about the query console in `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
QL for JavaScript
2-
=================
1+
CodeQL for JavaScript
2+
=====================
33

44
.. toctree::
55
:glob:
@@ -13,25 +13,25 @@ QL for JavaScript
1313
ast-class-reference
1414
dataflow-cheat-sheet
1515

16-
These documents provide an overview of the QL JavaScript and TypeScript standard libraries and show examples of how to use them.
16+
These documents provide an overview of the CodeQL libraries for JavaScript and TypeScript and show examples of how to use them.
1717

18-
- `Basic JavaScript QL query <https://lgtm.com/help/lgtm/console/ql-javascript-basic-example>`__ describes how to write and run queries using LGTM.
18+
- `Basic JavaScript query <https://lgtm.com/help/lgtm/console/ql-javascript-basic-example>`__ describes how to write and run queries using LGTM.
1919

20-
- :doc:`Introducing the QL libraries for JavaScript <introduce-libraries-js>`: an overview of the standard libraries used to write queries for JavaScript code. There is an extensive QL library for analyzing JavaScript code. This tutorial briefly summarizes the most important QL classes and predicates provided by this library.
20+
- :doc:`Introducing the CodeQL libraries for JavaScript <introduce-libraries-js>` introduces the standard libraries used to write queries for JavaScript code. There is an extensive CodeQL library for analyzing JavaScript code. This tutorial briefly summarizes the most important classes and predicates provided by this library.
2121

22-
- :doc:`Introducing the QL libraries for TypeScript <introduce-libraries-ts>`: an overview of the standard libraries used to write queries for TypeScript code.
22+
- :doc:`Introducing the CodeQL libraries for TypeScript <introduce-libraries-ts>` introduces the standard libraries used to write queries for TypeScript code.
2323

24-
- :doc:`Analyzing data flow in JavaScript/TypeScript <dataflow>`: demonstrates how to write queries using the standard QL for JavaScript/TypeScript data flow and taint tracking libraries.
24+
- :doc:`Analyzing data flow in JavaScript/TypeScript <dataflow>` demonstrates how to write queries using the standard data flow and taint tracking libraries for JavaScript/TypeScript.
2525

26-
- :doc:`Advanced data-flow analysis using flow labels <flow-labels>`: shows a more advanced example of data flow analysis using flow labels.
26+
- :doc:`Advanced data-flow analysis using flow labels <flow-labels>` shows a more advanced example of data flow analysis using flow labels.
2727

28-
- :doc:`AST class reference <ast-class-reference>`: an overview of all AST classes in the QL standard library for JavaScript.
28+
- :doc:`AST class reference <ast-class-reference>` gives an overview of all AST classes in the standard CodeQL library for JavaScript.
2929

30-
- :doc:`Data flow cheat sheet <dataflow-cheat-sheet>`: bits of QL commonly used for variant analysis and in data flow queries.
30+
- :doc:`Data flow cheat sheet <dataflow-cheat-sheet>` lists parts of the CodeQL libraries that are commonly used for variant analysis and in data flow queries.
3131

3232
Other resources
3333
---------------
3434

35-
- For examples of how to query common JavaScript elements, see the `JavaScript QL cookbook <https://help.semmle.com/wiki/display/CBJS>`__
36-
- For the queries used in LGTM, display a `JavaScript query <https://lgtm.com/search?q=language%3Ajavascript&t=rules>`__ and click **Open in query console** to see the QL code used to find alerts.
37-
- For more information about the JavaScript QL library see the `QL library for JavaScript <https://help.semmle.com/qldoc/javascript/>`__.
35+
- For examples of how to query common JavaScript elements, see the `JavaScript cookbook <https://help.semmle.com/wiki/display/CBJS>`__.
36+
- For the queries used in LGTM, display a `JavaScript query <https://lgtm.com/search?q=language%3Ajavascript&t=rules>`__ and click **Open in query console** to see the code used to find alerts.
37+
- For more information about the library for JavaScript see the `CodeQL library for JavaScript <https://help.semmle.com/qldoc/javascript/>`__.

docs/language/learn-ql/javascript/type-tracking.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Tutorial: API modelling using type tracking
22
===========================================
33

4-
This tutorial demonstrates how to build a simple model of the Firebase API in QL
5-
using the JavaScript type-tracking library.
4+
This tutorial demonstrates how to build a simple model of the Firebase API
5+
using the CodeQL type-tracking library for JavaScript.
66

77
The type-tracking library makes it possible to track values through properties and function calls,
88
usually to recognize method calls and properties accessed on a specific type of object.
@@ -89,7 +89,7 @@ For instance, ``firebaseSetterCall()`` fails to find anything in this example:
8989
var ref = getDatabase().ref("forecast");
9090
ref.set("Rain");
9191
92-
Notice that the QL predicate ``firebaseDatabase()`` still finds the call to ``firebase.database()``,
92+
Notice that the predicate ``firebaseDatabase()`` still finds the call to ``firebase.database()``,
9393
but not the ``getDatabase()`` call.
9494
This means ``firebaseRef()`` has no result, which in turn means ``firebaseSetterCall()`` has no result.
9595

0 commit comments

Comments
 (0)