Skip to content

Commit 2c542df

Browse files
authored
Merge pull request #2897 from mchammer01/js-migration-work
Code QL pre-migration tasks: update articles relating to CodeQL for JavaScript
2 parents ba67faf + 3558bb8 commit 2c542df

8 files changed

Lines changed: 58 additions & 44 deletions

File tree

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
AST class reference
2-
===================
1+
Abstract syntax tree classes for JavaScript and TypeScript
2+
==========================================================
3+
4+
CodeQL has a large selection of classes for working with JavaScript and TypeScript statements and expressions.
35

46
Statement classes
57
-----------------

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Data flow cheat sheet
2-
=====================
1+
Data flow cheat sheet for JavaScript
2+
====================================
33

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

66
Taint tracking path queries
77
---------------------------
@@ -39,7 +39,7 @@ See also: `Global data flow <https://help.semmle.com/QL/learn-ql/javascript/data
3939
DataFlow module
4040
---------------
4141

42-
Use data flow nodes to match program elements independently of syntax. See also: :doc:`Analyzing data flow in JavaScript/TypeScript <dataflow>`.
42+
Use data flow nodes to match program elements independently of syntax. See also: :doc:`Analyzing data flow in JavaScript and TypeScript <dataflow>`.
4343

4444
Predicates in the ``DataFlow::`` module:
4545

@@ -142,7 +142,7 @@ Files
142142
AST nodes
143143
---------
144144

145-
See also: :doc:`AST class reference <ast-class-reference>`.
145+
See also: :doc:`Abstract syntax tree classes for JavaScript and TypeScript <ast-class-reference>`.
146146

147147
Conversion between DataFlow and AST nodes:
148148

@@ -163,7 +163,7 @@ String matching
163163
Type tracking
164164
-------------
165165

166-
See also: :doc:`Type tracking tutorial <type-tracking>`.
166+
See also: :doc:`Using type tracking for API modeling <type-tracking>`.
167167

168168
Use the following template to define forward type tracking predicates:
169169

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
Analyzing data flow in JavaScript and TypeScript
22
================================================
33

4-
Overview
5-
--------
6-
74
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.
95

6+
Overview
7+
--------
8+
The various sections in this article describe how to utilize the libraries for local data flow, global data flow, and taint tracking.
109
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.
1110
While this is not a problematic pattern as such, it is typical of the kind of reasoning that is frequently used in security queries.
1211

@@ -470,7 +469,7 @@ What next?
470469
471470
- 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>`__.
472471
- Learn more about the query console in `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.
473-
- Learn about writing more precise data-flow analyses in :doc:`Advanced data-flow analysis using flow labels <flow-labels>`
472+
- Learn about writing more precise data-flow analyses in :doc:`Using flow labels for precise data flow analysis <flow-labels>`
474473
475474
Answers
476475
-------

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
Tutorial: Precise data-flow analysis using flow labels
2-
======================================================
1+
Using flow labels for precise data flow analysis
2+
================================================
3+
4+
You can associate flow labels with each value tracked by the flow analysis to determine whether the flow contains potential vulnerabilities.
5+
6+
Overview
7+
--------
38

49
You can use basic inter-procedural data-flow analysis and taint tracking as described in
5-
:doc:`Analyzing data flow in JavaScript/TypeScript <dataflow>` to check whether there is a path in
10+
:doc:`Analyzing data flow in JavaScript and TypeScript <dataflow>` to check whether there is a path in
611
the data-flow graph from some source node to a sink node that does not pass through any sanitizer
712
nodes. Another way of thinking about this is that it statically models the flow of data through the
813
program, and associates a flag with every data value telling us whether it might have come from a
@@ -390,9 +395,9 @@ tainted objects from partially tainted objects. The `Uncontrolled data used in p
390395
<https://lgtm.com/rules/1971530250>`_ query uses four flow labels to track whether a user-controlled
391396
string may be an absolute path and whether it may contain ``..`` components.
392397

393-
What next?
394-
----------
398+
Further reading
399+
---------------
395400

396-
- Learn about the standard CodeQL libraries used to write queries for JavaScript in :doc:`Introducing the JavaScript libraries <introduce-libraries-js>`.
401+
- Learn about the standard CodeQL libraries used to write queries for JavaScript in :doc:`CodeQL libraries for JavaScript <introduce-libraries-js>`.
397402
- 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>`__.
398403
- 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: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
Introducing the CodeQL libraries for JavaScript
2-
===============================================
1+
CodeQL libraries for JavaScript
2+
===============================
3+
4+
You can use the extensive libraries described in this article to analyze databases generated from JavaScript codebases. Using these libraries makes it easier for you to write queries.
35

46
Overview
57
--------
@@ -1026,9 +1028,9 @@ Alias nodes are represented by class `YAMLAliasNode <https://help.semmle.com/qld
10261028

10271029
Predicate ``YAMLMapping.maps(key, value)`` models the key-value relation represented by a mapping, taking merge keys into account.
10281030

1029-
What next?
1030-
----------
1031+
Further reading
1032+
---------------
10311033

1032-
- Learn about the standard CodeQL libraries used to write queries for TypeScript in :doc:`Introducing the TypeScript libraries <introduce-libraries-ts>`.
1034+
- Learn about the standard CodeQL libraries used to write queries for TypeScript in :doc:`CodeQL libraries for TypeScript <introduce-libraries-ts>`.
10331035
- 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>`__.
10341036
- 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-ts.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
Introducing the CodeQL libraries for TypeScript
2-
===============================================
1+
CodeQL libraries for TypeScript
2+
===============================
3+
4+
You can use libraries to analyze databases generated from TypeScript codebases. Using these libraries makes it easier for you to write queries.
35

46
Overview
57
--------
@@ -10,7 +12,7 @@ Support for analyzing TypeScript code is bundled with the CodeQL libraries for J
1012
1113
import javascript
1214
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.
15+
:doc:`CodeQL libraries 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.
1416

1517
Syntax
1618
------
@@ -134,7 +136,7 @@ The CodeQL class `ClassOrInterface <https://help.semmle.com/qldoc/javascript/sem
134136

135137
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>`__.
136138

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

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

@@ -444,9 +446,9 @@ A `LocalNamespaceName <https://help.semmle.com/qldoc/javascript/semmle/javascrip
444446
- ``LocalNamespaceName.getADeclaration()`` gets an identifier that declares this local name.
445447
- ``LocalNamespaceName.getNamespace()`` gets the namespace to which this name refers.
446448

447-
What next?
448-
----------
449+
Further reading
450+
---------------
449451

450-
- Learn about the standard CodeQL libraries used to write queries for JavaScript in :doc:`Introducing the JavaScript libraries <introduce-libraries-js>`.
452+
- Learn about the standard CodeQL libraries used to write queries for JavaScript in :doc:`CodeQL libraries for JavaScript <introduce-libraries-js>`.
451453
- 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>`__.
452-
- Learn more about the query console in `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.
454+
- Learn more about the query console in `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
CodeQL for JavaScript
22
=====================
33

4+
Experiment and learn how to write effective and efficient queries for CodeQL databases generated from JavaScript codebases.
5+
46
.. toctree::
57
:glob:
68
:hidden:
@@ -17,19 +19,19 @@ These documents provide an overview of the CodeQL libraries for JavaScript and T
1719

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

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.
22+
- :doc:`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.
2123

22-
- :doc:`Introducing the CodeQL libraries for TypeScript <introduce-libraries-ts>` introduces the standard libraries used to write queries for TypeScript code.
24+
- :doc:`CodeQL libraries for TypeScript <introduce-libraries-ts>` introduces the standard libraries used to write queries for TypeScript code.
2325

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.
26+
- :doc:`Analyzing data flow in JavaScript and TypeScript <dataflow>` demonstrates how to write queries using the standard data flow and taint tracking libraries for JavaScript/TypeScript.
2527

26-
- :doc:`Advanced data-flow analysis using flow labels <flow-labels>` shows a more advanced example of data flow analysis using flow labels.
28+
- :doc:`Using flow labels for precise data flow analysis <flow-labels>` shows a more advanced example of data flow analysis using flow labels.
2729

28-
- :doc:`AST class reference <ast-class-reference>` gives an overview of all AST classes in the standard CodeQL library for JavaScript.
30+
- :doc:`Abstract syntax tree classes for JavaScript and TypeScript <ast-class-reference>` gives an overview of all AST classes in the standard CodeQL library for JavaScript.
2931

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.
32+
- :doc:`Data flow cheat sheet for JavaScript <dataflow-cheat-sheet>` lists parts of the CodeQL libraries that are commonly used for variant analysis and in data flow queries.
3133

32-
Other resources
34+
Further reading
3335
---------------
3436

3537
- For examples of how to query common JavaScript elements, see the `JavaScript cookbook <https://help.semmle.com/wiki/display/CBJS>`__.

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
Tutorial: API modelling using type tracking
2-
===========================================
1+
Using type tracking for API modeling
2+
====================================
33

4-
This tutorial demonstrates how to build a simple model of the Firebase API
4+
You can track data through an API by creating a model
55
using the CodeQL type-tracking library for JavaScript.
66

7+
Overview
8+
--------
79
The type-tracking library makes it possible to track values through properties and function calls,
810
usually to recognize method calls and properties accessed on a specific type of object.
911

@@ -489,7 +491,7 @@ Prefer type tracking when:
489491
Prefer data-flow configurations when:
490492

491493
- Tracking user-controlled data -- use `taint tracking <https://help.semmle.com/QL/learn-ql/javascript/dataflow.html#using-global-taint-tracking>`__.
492-
- Differentiating between different kinds of user-controlled data -- use :doc:`flow labels <flow-labels>`.
494+
- Differentiating between different kinds of user-controlled data -- see :doc:`Using flow labels for precise data flow analysis <flow-labels>`.
493495
- Tracking transformations of a value through generic utility functions.
494496
- Tracking values through string manipulation.
495497
- Generating a path from source to sink -- see :doc:`constructing path queries <../writing-queries/path-queries>`.
@@ -522,4 +524,4 @@ What next?
522524

523525
- 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>`__.
524526
- Learn more about the query console in `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.
525-
- Learn about writing precise data-flow analyses in :doc:`Advanced data-flow analysis using flow labels <flow-labels>`.
527+
- Learn about writing precise data-flow analyses in :doc:`Using flow labels for precise data flow analysis <flow-labels>`.

0 commit comments

Comments
 (0)