Skip to content

Commit 6924a88

Browse files
authored
Merge pull request github#1917 from jf205/recent-changes-122
docs: port some recent changes to rc/1.22 branch
2 parents 1bd0c69 + 4a6ee7f commit 6924a88

File tree

130 files changed

+2409
-923
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+2409
-923
lines changed

docs/language/README.rst

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ The QL language documentation currently consists of the following Sphinx project
2121
- ``ql-handbook``–a user-friendly guide to the QL language
2222
- ``ql-spec``–formal descriptions of the QL language and QLDoc comments
2323
- ``support``–the languages and frameworks currently supported in QL analysis
24-
- ``training``–QL for variant analysis training material
25-
- ``ql-training-rst``–QL for variant analysis slide shows
24+
- ``ql-training``–source files for the QL training and variant analysis examples slide decks
2625

2726
Each project contains:
2827

@@ -37,8 +36,8 @@ This directory also contains any other files, such as templates and stylesheets,
3736
that are used by multiple projects.
3837
Images used in the QL documentation are located in the ``images`` directory.
3938

40-
The ``ql-training-rst`` project contains the source files, themes, and static files
41-
used to generate the QL training presentations.
39+
The ``ql-training`` project contains the source files, themes, and static files
40+
used to generate the QL training and variant analysis presentations.
4241
It uses a different configuration from the other projects, and is built using an
4342
extension specifically designed for HTML slide shows.
4443
For more information, see
@@ -48,9 +47,12 @@ For more information, see
4847
Building and previewing the QL language documentation
4948
*****************************************************
5049

51-
To build and preview the QL documentation locally, you need to install Sphinx.
50+
To build and preview the QL documentation and QL training presentations locally, you need to
51+
install Sphinx 1.7.9. More recent versions of Sphinx do not work with hieroglyph,
52+
the Sphinx extension that we use to generate HTML slides, as explained below.
5253
For installation options, see https://github.com/sphinx-doc/sphinx.
5354

55+
5456
Using ``sphinx-build``
5557
----------------------
5658

@@ -69,11 +71,13 @@ For example, to generate the HTML output for a project in the
6971
7072
Add the ``-W`` flag to turn *warnings* into *errors* during the build process.
7173
You can use errors reported during the build to debug problems in your source
72-
code, such as broken internal links and malformed tables.
74+
code, such as broken internal links and malformed tables. You can also check
75+
external links using Sphinx's `external link builder
76+
<http://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.linkcheck.CheckExternalLinksBuilder>`__.
7377

7478
Add the ``-a`` flag to regenerate all output files. By default, only files that
7579
have changed are rebuilt.
76-
80+
7781
Using the reStructuredText Extension for Visual Studio Code
7882
-----------------------------------------------------------
7983

@@ -95,8 +99,10 @@ After installing hieroglyph, you can build the QL training presentations by runn
9599
sphinx-build -b slides . <slides-output>
96100
97101
generates html slide shows in the ``<slides-output>`` directory when run from
98-
the ``ql-training-rst`` source directory.
102+
the ``ql-training`` source directory.
99103

104+
For more information about creating slides for QL training and variant analysis
105+
examples, see the `template slide deck <https://github.com/Semmle/ql/blob/master/docs/language/ql-training/template.rst>`__.
100106

101107
Viewing the current version of the QL language documentation
102108
************************************************************

docs/language/global-sphinx-files/_templates/layout.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<div class="linkcontainer">
6161
<div class="linkbar">
6262
<a href="https://help.semmle.com/QL/learn-ql/" target="_blank">Learn QL</a>
63-
<a href="https://help.semmle.com/QL/ql-training/training-index.html" target="_blank">QL training</a>
63+
<a href="https://help.semmle.com/QL/learn-ql/ql-training.html" target="_blank">QL for variant analysis</a>
6464
<a href="https://help.semmle.com/QL/ql-tools.html" target="_blank">QL tools</a>
6565
<a href="https://help.semmle.com/QL/ql-explore-queries.html" target="_blank">Queries</a>
6666
<a href="https://help.semmle.com/QL/ql-reference-topics.html" target="_blank">Reference</a>

docs/language/learn-ql/cpp/introduce-libraries-cpp.rst

Lines changed: 502 additions & 1 deletion
Large diffs are not rendered by default.

docs/language/learn-ql/index.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ QL queries are easy to write and share–visit the topics below and `our open so
1010
You can also try out QL in the `query console <https://lgtm.com/query>`__ on `LGTM.com <https://lgtm.com>`__.
1111
Here, you can write QL code to query open source projects directly, without having to download snapshots and libraries.
1212

13+
.. _getting-started:
14+
1315
Getting started
1416
***************
1517

@@ -22,6 +24,18 @@ If you are new to QL, start by looking at the following topics:
2224
about-ql
2325
beginner/ql-tutorials
2426

27+
QL training and variant analysis examples
28+
******************************************
29+
30+
To start learning how to use QL in variant analysis for a specific language, see:
31+
32+
.. toctree::
33+
:maxdepth: -1
34+
35+
ql-training
36+
37+
.. _writing-ql-queries:
38+
2539
Writing QL queries
2640
******************
2741

docs/language/learn-ql/python/introduce-libraries-python.rst

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ The QL Python library incorporates a large number of classes, each class corresp
2020

2121
- **Syntactic** - classes that represent entities in the Python source code.
2222
- **Control flow** - classes that represent entities from the control flow graphs.
23-
- **Data flow** - classes that assist in performing data flow analyses on Python source code.
24-
- **Type inference** - classes that represent the inferred types of entities in the Python source code.
23+
- **Type inference** - classes that represent the inferred values and types of entities in the Python source code.
24+
- **Taint tracking** - classes that represent the source, sinks and kinds of taint used to implement taint-tracking queries.
2525

2626
Syntactic classes
2727
~~~~~~~~~~~~~~~~~
@@ -289,41 +289,52 @@ The classes in the control-flow part of the library are:
289289
- `ControlFlowNode <https://help.semmle.com/qldoc/python/semmle/python/Flow.qll/type.Flow$ControlFlowNode.html>`__ – A control-flow node. There is a one-to-many relation between AST nodes and control-flow nodes.
290290
- `BasicBlock <https://help.semmle.com/qldoc/python/semmle/python/Flow.qll/type.Flow$BasicBlock.html>`__ – A non branching list of control-flow nodes.
291291

292-
Data flow
293-
~~~~~~~~~
294-
295-
The ``SsaVariable`` class represents `static single assignment form <http://en.wikipedia.org/wiki/Static_single_assignment_form>`__ variables (SSA variables). There is a one-to-many relation between variables and SSA variables. The ``SsaVariable`` class provides an accurate and fast means of tracking data flow from definition to use; the ``SsaVariable`` class is an important element for building data flow analyses, including type inference.
296292

297293
Type-inference classes
298294
----------------------
299295

300-
The QL library for Python also supplies some classes for accessing the inferred types of values. The classes ``Object`` and ``ClassObject`` allow you to query the possible classes that an expression may have at runtime. For example, which ``ClassObjects`` are iterable can be determined using the query:
296+
The QL library for Python also supplies some classes for accessing the inferred types of values. The classes ``Value`` and ``ClassValue`` allow you to query the possible classes that an expression may have at runtime. For example, which ``ClassValue``\ s are iterable can be determined using the query:
301297

302-
**Find iterable ``ClassObjects``**
298+
**Find iterable "ClassValue"s**
303299

304300
.. code-block:: ql
305301
306302
import python
307303
308-
from ClassObject cls
304+
from ClassValue cls
309305
where cls.hasAttribute("__iter__")
310306
select cls
311307
312-
➤ `See this in the query console <https://lgtm.com/query/688180005/>`__ This query returns a list of classes for the projects analyzed. If you want to include the results for `builtin classes <http://docs.python.org/library/stdtypes.html>`__, which do not have any Python source code, show the non-source results.
308+
➤ `See this in the query console <https://lgtm.com/query/5151030165280978402/>`__ This query returns a list of classes for the projects analyzed. If you want to include the results for `builtin classes <http://docs.python.org/library/stdtypes.html>`__, which do not have any Python source code, show the non-source results.
313309

314310
Summary
315311
~~~~~~~
316312

317-
- `Object <https://help.semmle.com/qldoc/python/semmle/python/types/Object.qll/type.Object$Object.html>`__
313+
- `Value <https://help.semmle.com/qldoc/python/semmle/python/objects/ObjectAPI.qll/type.ObjectAPI$Value.html>`__
318314

319-
- ``ClassObject``
320-
- ``FunctionObject``
321-
- ``ModuleObject``
315+
- ``ClassValue``
316+
- ``CallableValue``
317+
- ``ModuleValue``
322318

323319
These classes are explained in more detail in :doc:`Tutorial: Points-to analysis and type inference <pointsto-type-infer>`.
324320

321+
Taint-tracking classes
322+
----------------------
323+
324+
The QL library for Python also supplies classes to specify taint-tracking analyses. The ``Configuration`` class can be overrridden to specify a taint-tracking analysis, by specifying source, sinks, sanitizers and additional flow steps. For those analyses that require additional types of taint to be tracked the ``TaintKind`` class can be overridden.
325+
326+
327+
Summary
328+
~~~~~~~
329+
330+
- `TaintKind <https://help.semmle.com/qldoc/python/semmle/python/security/TaintTracking.qll/type.TaintTracking$TaintKind.html>`__
331+
- `Configuration <https://help.semmle.com/qldoc/python/semmle/python/security/TaintTracking.qll/type.TaintTracking$TaintTracking$Configuration.html>`__
332+
333+
These classes are explained in more detail in :doc:`Tutorial: Taint tracking and data flow analysis in Python <taint-tracking>`.
334+
335+
325336
What next?
326337
----------
327338

328-
- Experiment with the worked examples in the QL for Python tutorial topics: :doc:`Functions <functions>`, :doc:`Statements and expressions <statements-expressions>`, :doc:`Control flow <control-flow>` and :doc:`Points-to analysis and type inference <pointsto-type-infer>`.
339+
- Experiment with the worked examples in the QL for Python tutorial topics: :doc:`Functions <functions>`, :doc:`Statements and expressions <statements-expressions>`, :doc:`Control flow <control-flow>`, :doc:`Points-to analysis and type inference <pointsto-type-infer>` and :doc:`Taint tracking and data flow analysis in Python <taint-tracking>`.
329340
- 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/QLLanguageSpecification.html>`__.

docs/language/learn-ql/python/statements-expressions.rst

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,10 @@ Each kind of Python expression has its own class. Here is the full class hierarc
101101
- ``BoolExpr`` – Short circuit logical operations, ``x and y``, ``x or y``
102102
- ``Bytes`` – A bytes literal, ``b"x"`` or (in Python 2) ``"x"``
103103
- ``Call`` – A function call, ``f(arg)``
104-
- ``ClassExpr`` – An artificial expression representing the right hand side a ``ClassDef`` assignment
105104
- ``Compare`` – A comparison operation, ``0 < x < 10``
106105
- ``Dict`` – A dictionary literal, ``{'a': 2}``
107106
- ``DictComp`` – A dictionary comprehension, ``{k: v for ...}``
108107
- ``Ellipsis`` – An ellipsis expression, ``...``
109-
- ``FunctionExpr`` – An artificial expression representing the right hand side a ``FunctionDef`` assignment
110108
- ``GeneratorExp`` – A generator expression
111109
- ``IfExp`` – A conditional expression, ``x if cond else y``
112110
- ``ImportExpr`` – An artificial expression representing the module imported
@@ -255,9 +253,9 @@ checks that the value of the attribute (the expression to the left of the dot in
255253
Class and function definitions
256254
------------------------------
257255

258-
As Python is a dynamically typed language, class, and function definitions are executable statements. This means that a class statement is both a statement and a scope containing statements. To represent this cleanly the class definition is broken into a number of parts. At runtime, when a class definition is executed a class object is created and then assigned to a variable of the same name in the scope enclosing the class. This class is created from a code-object representing the source code for the body of the class. To represent this the ``ClassDef`` class (which represents a ``class`` statement) subclasses ``Assign``. The right hand side of the ``ClassDef`` is a ``ClassExpr`` representing the creation of the class. The ``Class`` class, which represents the body of the class, can be accessed via the ``ClassExpr.getInnerScope()``
256+
As Python is a dynamically typed language, class, and function definitions are executable statements. This means that a class statement is both a statement and a scope containing statements. To represent this cleanly the class definition is broken into a number of parts. At runtime, when a class definition is executed a class object is created and then assigned to a variable of the same name in the scope enclosing the class. This class is created from a code-object representing the source code for the body of the class. To represent this the ``ClassDef`` class (which represents a ``class`` statement) subclasses ``Assign``. The ``Class`` class, which represents the body of the class, can be accessed via the ``ClassDef.getDefinedClass()``
259257

260-
``FunctionDef``, ``FunctionExpr`` and ``Function`` are handled similarly.
258+
``FunctionDef``, ``Function`` are handled similarly.
261259

262260
Here is the relevant part of the class hierarchy:
263261

@@ -268,12 +266,6 @@ Here is the relevant part of the class hierarchy:
268266
- ``ClassDef``
269267
- ``FunctionDef``
270268

271-
- ``Expr``
272-
273-
- ``ClassExp``
274-
275-
- ``FunctionExpr``
276-
277269
- ``Scope``
278270

279271
- ``Class``
@@ -283,4 +275,4 @@ What next?
283275
----------
284276

285277
- Experiment with the worked examples in the QL for Python tutorial topics: :doc:`Control flow <control-flow>`, :doc:`Points-to analysis and type inference <pointsto-type-infer>`.
286-
- 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/QLLanguageSpecification.html>`__.
278+
- 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/QLLanguageSpecification.html>`__.

docs/language/learn-ql/python/taint-tracking.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ The sink is defined by using a custom ``TaintTracking::Sink`` class.
9696
class UnsafeSink extends TaintTracking::Sink {
9797
9898
UnsafeSink() {
99-
exists(FunctionObject unsafe |
99+
exists(FunctionValue unsafe |
100100
unsafe.getName() = "unsafe" and
101101
unsafe.getACall().(CallNode).getAnArg() = this
102102
)
@@ -172,7 +172,7 @@ Thus, our example query becomes:
172172
class UnsafeSink extends TaintTracking::Sink {
173173
174174
UnsafeSink() {
175-
exists(FunctionObject unsafe |
175+
exists(FunctionValue unsafe |
176176
unsafe.getName() = "unsafe" and
177177
unsafe.getACall().(CallNode).getAnArg() = this
178178
)
@@ -255,4 +255,4 @@ What next?
255255
----------
256256

257257
- Experiment with the worked examples in the QL for Python tutorial topics: :doc:`Control flow <control-flow>`, and :doc:`Points-to analysis and type inference <pointsto-type-infer>`.
258-
- 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/QLLanguageSpecification.html>`__.
258+
- 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/QLLanguageSpecification.html>`__.

0 commit comments

Comments
 (0)