Skip to content

Commit 5d1d7ea

Browse files
authored
Merge pull request #2257 from jf205/codeql-training-material
docs: update terminology in training material
2 parents d9beb54 + 2e7bd4d commit 5d1d7ea

25 files changed

+178
-428
lines changed
Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
QL training and variant analysis examples
2-
#########################################
1+
CodeQL training and variant analysis examples
2+
=============================================
33

4-
QL and variant analysis
5-
=======================
4+
CodeQL and variant analysis
5+
---------------------------
66

77
`Variant analysis <https://semmle.com/variant-analysis>`__ is the process of using a known vulnerability as a seed to find similar problems in your code. Security engineers typically perform variant analysis to identify possible vulnerabilities and to ensure that these threats are properly fixed across multiple code bases.
88

9-
`QL <https://semmle.com/ql>`__ is Semmle's variant analysis engine, and it is also the technology that underpins LGTM, Semmle's community driven security analysis platform. Together, QL and LGTM provide continuous monitoring and scalable variant analysis for your projects, even if you don’t have your own team of dedicated security engineers. You can read more about using QL and LGTM in variant analysis in the `Semmle blog <https://blog.semmle.com/tags/variant-analysis>`__.
9+
`CodeQL <https://semmle.com/ql>`__ is the code analysis engine that underpins LGTM, Semmle's community driven security analysis platform. Together, CodeQL and LGTM provide continuous monitoring and scalable variant analysis for your projects, even if you don’t have your own team of dedicated security engineers. You can read more about using CodeQL and LGTM in variant analysis in the `Semmle blog <https://blog.semmle.com/tags/variant-analysis>`__.
1010

11-
The QL language is easy to learn, and exploring code using QL is the most efficient way to perform variant analysis.
11+
CodeQL is easy to learn, and exploring code using CodeQL is the most efficient way to perform variant analysis.
1212

13-
Learning QL for variant analysis
14-
================================
13+
Learning CodeQL for variant analysis
14+
------------------------------------
1515

16-
Start learning how to use QL in variant analysis for a specific language by looking at the topics below. Each topic links to a short presentation on the QL language, QL libraries, or an example variant discovered using QL.
16+
Start learning how to use CodeQL in variant analysis for a specific language by looking at the topics below. Each topic links to a short presentation on CodeQL, its libraries, or an example variant discovered using CodeQL.
1717

1818
.. |arrow-l| unicode:: U+2190
1919

@@ -24,43 +24,43 @@ Start learning how to use QL in variant analysis for a specific language by look
2424
When you have selected a presentation, use |arrow-r| and |arrow-l| to navigate between slides.
2525
Press **p** to view the additional notes on slides that have an information icon |info| in the top right corner, and press **f** to enter full-screen mode.
2626

27-
The presentations contain a number of QL query examples.
27+
The presentations contain a number of query examples.
2828
We recommend that you download `QL for Eclipse <https://help.semmle.com/ql-for-eclipse/Content/WebHelp/home-page.html>`__ and import the example snapshot for each presentation so that you can find the bugs mentioned in the slides.
2929

3030

3131
.. pull-quote::
3232

3333
Information
3434

35-
The presentations listed below are used in QL language and variant analysis training sessions run by Semmle engineers.
35+
The presentations listed below are used in CodeQL and variant analysis training sessions run by Semmle engineers.
3636
Therefore, be aware that the slides are designed to be presented by an instructor.
3737
If you are using the slides without an instructor, please use the additional notes to help guide you through the examples.
3838

39-
QL and variant analysis for C/C++
40-
---------------------------------
39+
CodeQL and variant analysis for C/C++
40+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4141

42-
- `Introduction to variant analysis: QL for C/C++ <../ql-training/cpp/intro-ql-cpp.html>`__–an introduction to variant analysis and QL for C/C++ programmers.
42+
- `Introduction to variant analysis: CodeQL for C/C++ <../ql-training/cpp/intro-ql-cpp.html>`__–an introduction to variant analysis and CodeQL for C/C++ programmers.
4343
- `Example: Bad overflow guard <../ql-training/cpp/bad-overflow-guard.html>`__–an example of iterative query development to find bad overflow guards in a C++ project.
44-
- `Program representation: QL for C/C++ <../ql-training/cpp/program-representation-cpp.html>`__–information on how QL analysis represents C/C++ programs.
45-
- `Introduction to local data flow <../ql-training/cpp/data-flow-cpp.html>`__–an introduction to analyzing local data flow in C/C++ using QL, including an example demonstrating how to develop a query to find a real CVE.
44+
- `Program representation: CodeQL for C/C++ <../ql-training/cpp/program-representation-cpp.html>`__–information on how CodeQL analysis represents C/C++ programs.
45+
- `Introduction to local data flow <../ql-training/cpp/data-flow-cpp.html>`__–an introduction to analyzing local data flow in C/C++ using CodeQL, including an example demonstrating how to develop a query to find a real CVE.
4646
- `Exercise: snprintf overflow <../ql-training/cpp/snprintf.html>`__–an example demonstrating how to develop a data flow query.
47-
- `Introduction to global data flow <../ql-training/cpp/global-data-flow-cpp.html>`__–an introduction to analyzing global data flow in C/C++ using QL.
48-
- `Analyzing control flow: QL for C/C++ <../ql-training/cpp/control-flow-cpp.html>`__–an introduction to analyzing control flow in C/C++ using QL.
47+
- `Introduction to global data flow <../ql-training/cpp/global-data-flow-cpp.html>`__–an introduction to analyzing global data flow in C/C++ using CodeQL.
48+
- `Analyzing control flow: CodeQL for C/C++ <../ql-training/cpp/control-flow-cpp.html>`__–an introduction to analyzing control flow in C/C++ using CodeQL.
4949

50-
QL and variant analysis for Java
51-
--------------------------------
50+
CodeQL and variant analysis for Java
51+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5252

53-
- `Introduction to variant analysis: QL for Java <../ql-training/java/intro-ql-java.html>`__–an introduction to variant analysis and QL for Java programmers.
53+
- `Introduction to variant analysis: CodeQL for Java <../ql-training/java/intro-ql-java.html>`__–an introduction to variant analysis and CodeQL for Java programmers.
5454
- `Example: Query injection <../ql-training/java/query-injection-java.html>`__–an example of iterative query development to find unsanitized SPARQL injections in a Java project.
55-
- `Program representation: QL for Java <../ql-training/java/program-representation-java.html>`__–information on how QL analysis represents Java programs.
56-
- `Introduction to local data flow <../ql-training/java/data-flow-java.html>`__–an introduction to analyzing local data flow in Java using QL, including an example demonstrating how to develop a query to find a real CVE.
55+
- `Program representation: CodeQL for Java <../ql-training/java/program-representation-java.html>`__–information on how CodeQL analysis represents Java programs.
56+
- `Introduction to local data flow <../ql-training/java/data-flow-java.html>`__–an introduction to analyzing local data flow in Java using CodeQL, including an example demonstrating how to develop a query to find a real CVE.
5757
- `Exercise: Apache Struts <../ql-training/java/apache-struts-java.html>`__–an example demonstrating how to develop a data flow query.
58-
- `Introduction to global data flow <../ql-training/java/global-data-flow-java.html>`__–an introduction to analyzing global data flow in Java using QL.
58+
- `Introduction to global data flow <../ql-training/java/global-data-flow-java.html>`__–an introduction to analyzing global data flow in Java using CodeQL.
5959

6060
More resources
61-
--------------
61+
~~~~~~~~~~~~~~
6262

63-
- If you are completely new to QL, look at our introductory topics in :ref:`Getting started <getting-started>`.
64-
- To find more detailed information about how to write QL queries for specific languages, visit the links in :ref:`Writing QL queries <writing-ql-queries>`.
65-
- To read more about how QL queries have been used in Semmle's security research, and to read about new QL developments, visit the `Semmle blog <https://blog.semmle.com>`__.
63+
- If you are completely new to CodeQL, look at our introductory topics in :doc:`Learning CodeQL <index>`.
64+
- To find more detailed information about how to write queries for specific languages, visit the links in :ref:`Writing CodeQL queries <writing-ql-queries>`.
65+
- To read more about how CodeQL queries have been used in Semmle's security research, and to read about new CodeQL developments, visit the `Semmle blog <https://blog.semmle.com>`__.
6666
- Find more examples of queries written by Semmle's own security researchers in the `Semmle Demos repository <https://github.com/semmle/demos>`__ on GitHub.

docs/language/ql-training/_static-training/slides-semmle-2/static/theme/css/default.css

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ ul {
485485
margin-left: 2.2em;
486486
margin-bottom: 1em;
487487
position: relative;
488+
width: 90%;
488489
}
489490
/* line 300, ../scss/default.scss */
490491
ul li {
@@ -1300,13 +1301,13 @@ aside.gdbar img {
13001301
.title-slide hgroup h1 {
13011302
font-size: 2em;
13021303
line-height: 1.4;
1303-
/*letter-spacing: -3px;*/
13041304
color: white;
13051305
margin: auto;
13061306
display: block;
13071307
position: absolute;
13081308
top: 0;
13091309
bottom: 10%;
1310+
left: 1.25em;
13101311
height: 0;
13111312
}
13121313
/* line 898, ../scss/default.scss */
@@ -1430,31 +1431,19 @@ hgroup .pre {
14301431
color: #5c31ff;
14311432
}
14321433

1433-
/* title slide (deck title, subtitle, semmle logo)*/
1434+
/* title slide (deck title, subtitle)*/
14341435

14351436
.title-slide {
14361437
background-image: url("../../title-slide.svg");
14371438
background-size: cover;
14381439
}
14391440

1440-
.semmle-logo sup {
1441-
vertical-align: super;
1442-
font-size: 0.3em;
1443-
font-weight: 100;
1444-
}
1445-
1446-
.title-slide .semmle-logo {
1447-
color: white;
1448-
font-size: 1.2em;
1449-
position: absolute;
1450-
top: 10%;
1451-
}
1452-
14531441
.title-slide p {
14541442
color: white;
14551443
font-size: 1em;
14561444
position: absolute;
14571445
bottom: 30%;
1446+
left: 2.6em;
14581447
}
14591448

14601449
.title-slide hgroup .pre {
@@ -1464,6 +1453,7 @@ hgroup .pre {
14641453
.subheading {
14651454
position: absolute;
14661455
top: 62.5%;
1456+
left: 0;
14671457
}
14681458

14691459
.subheading p {
@@ -1569,7 +1559,7 @@ p.first.admonition-title {
15691559
text-align: left;
15701560
font-size: 0.8em;
15711561
width: 100%;
1572-
overflow: scroll;
1562+
overflow: auto;
15731563
border: 1px solid black;
15741564
}
15751565

@@ -1608,7 +1598,7 @@ p.first.admonition-title {
16081598
display: block;
16091599
position: fixed;
16101600
top: 0;
1611-
right: -1%;
1601+
right: 0;
16121602
font-size: 1.2em;
16131603
}
16141604

docs/language/ql-training/_static-training/title-slide.svg

Lines changed: 1 addition & 148 deletions
Loading

docs/language/ql-training/conf.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# QL training slides build configuration file
3+
# CodeQL training slides build configuration file
44
#
55
# This file is execfile()d with the current directory set to its
66
# containing dir.
@@ -59,7 +59,7 @@ def setup(sphinx):
5959
master_doc = 'index'
6060

6161
# General information about the project.
62-
project = u'QL training and variant analysis examples'
62+
project = u'CodeQL training and variant analysis examples'
6363

6464
# Add any paths that contain custom static files (such as style sheets) here,
6565
# relative to this directory. They are copied after the builtin static files,
@@ -77,18 +77,18 @@ def setup(sphinx):
7777

7878
# The name for this set of Sphinx documents. If None, it defaults to
7979
# "<project> v<release> documentation".
80-
html_title = 'QL training and variant analysis examples'
80+
html_title = 'CodeQL training and variant analysis examples'
8181

8282
# Output file base name for HTML help builder.
83-
htmlhelp_basename = 'QL training'
83+
htmlhelp_basename = 'CodeQL training'
8484
# The Semmle version info for the current release you're documenting, acts as replacement for
8585
# |version| and |release|, also used in various other places throughout the
8686
# built documents.
8787
#
8888
# The short X.Y version.
89-
version = u'1.21'
89+
version = u'1.22'
9090
# The full version, including alpha/beta/rc tags.
91-
release = u'1.21'
91+
release = u'1.22'
9292
copyright = u'2019 Semmle Ltd'
9393
author = u'Semmle Ltd'
9494

docs/language/ql-training/cpp/bad-overflow-guard.rst

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
Example: Bad overflow guard
33
===========================
44

5-
QL for C/C++
6-
7-
.. container:: semmle-logo
8-
9-
Semmle :sup:`TM`
5+
CodeQL for C/C++
106

117
.. rst-class:: setup
128

@@ -16,17 +12,17 @@ Setup
1612
For this example you should download:
1713

1814
- `QL for Eclipse <https://help.semmle.com/ql-for-eclipse/Content/WebHelp/install-plugin-free.html>`__
19-
- `ChakraCore snapshot <https://downloads.lgtm.com/snapshots/cpp/microsoft/chakracore/ChakraCore-revision-2017-April-12--18-13-26.zip>`__
15+
- `ChakraCore database <https://downloads.lgtm.com/snapshots/cpp/microsoft/chakracore/ChakraCore-revision-2017-April-12--18-13-26.zip>`__
2016

2117
.. note::
2218

2319
For the examples in this presentation, we will be analyzing `ChakraCore <https://github.com/microsoft/ChakraCore>`__.
2420

2521
You can query the project in `the query console <https://lgtm.com/query/project:2034240708/lang:cpp/>`__ on LGTM.com.
2622

27-
.. insert snapshot-note.rst to explain differences between snapshot available to download and the version available in the query console.
23+
.. insert database-note.rst to explain differences between database available to download and the version available in the query console.
2824
29-
.. include:: ../slide-snippets/snapshot-note.rst
25+
.. include:: ../slide-snippets/database-note.rst
3026

3127
.. resume slides
3228
@@ -127,13 +123,13 @@ This happens even though the overflow check passed!
127123

128124
.. rst-class:: background2
129125

130-
Developing a QL query
131-
=====================
126+
Developing a CodeQL query
127+
=========================
132128

133129
Finding bad overflow guards
134130

135-
QL query: bad overflow guards
136-
=============================
131+
CodeQL query: bad overflow guards
132+
==================================
137133

138134
Let’s look for overflow guards of the form ``v + b < v``, using the classes
139135
``AddExpr``, ``Variable`` and ``RelationalOperation`` from the ``cpp`` library.
@@ -153,10 +149,10 @@ Let’s look for overflow guards of the form ``v + b < v``, using the classes
153149
- a ``RelationalOperation``: the overflow comparison check.
154150
- a ``Variable``: used as an argument to both the addition and comparison.
155151

156-
- The ``where`` part of the query ties these three QL variables together using `predicates <https://help.semmle.com/QL/ql-handbook/predicates.html>`__ defined in the `standard QL for C/C++ library <https://help.semmle.com/qldoc/cpp/>`__.
152+
- The ``where`` part of the query ties these three variables together using `predicates <https://help.semmle.com/QL/ql-handbook/predicates.html>`__ defined in the `standard CodeQL for C/C++ library <https://help.semmle.com/qldoc/cpp/>`__.
157153

158-
QL query: bad overflow guards
159-
=============================
154+
CodeQL query: bad overflow guards
155+
=================================
160156

161157
We want to ensure the operands being added have size less than 4 bytes.
162158

@@ -180,8 +176,8 @@ We can get the size (in bytes) of a type using the ``getSize()`` method.
180176
- We therefore write a helper predicate for small expressions.
181177
- This predicate effectively represents the set of all expressions in the database where the size of the type of the expression is less than 4 bytes, that is, less than 32-bits.
182178

183-
QL query: bad overflow guards
184-
=============================
179+
CodeQL query: bad overflow guards
180+
==================================
185181

186182
We can ensure the operands being added have size less than 4 bytes, using our new predicate.
187183

@@ -216,8 +212,8 @@ Now our query becomes:
216212
- The “range” part, ``op = a.getAnOperand()``, restricts ``op`` to being one of the two operands to the addition.
217213
- The “condition” part, ``isSmall(op)``, says that the ``forall`` holds only if the condition (that the ``op`` is small) holds for everything in the range–that is, both the arguments to the addition.
218214

219-
QL query: bad overflow guards
220-
=============================
215+
CodeQL query: bad overflow guards
216+
=================================
221217

222218
Sometimes the result of the addition is cast to a small type of size less than 4 bytes, preventing automatic widening. We don’t want our query to flag these instances.
223219

@@ -233,4 +229,4 @@ The final query
233229
.. literalinclude:: ../query-examples/cpp/bad-overflow-guard-3.ql
234230
:language: ql
235231

236-
This query finds a single result in our historic snapshot, which was `a genuine bug in ChakraCore <https://github.com/Microsoft/ChakraCore/commit/2500e1cdc12cb35af73d5c8c9b85656aba6bab4d>`__.
232+
This query finds a single result in our historic database, which was `a genuine bug in ChakraCore <https://github.com/Microsoft/ChakraCore/commit/2500e1cdc12cb35af73d5c8c9b85656aba6bab4d>`__.

docs/language/ql-training/cpp/control-flow-cpp.rst

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
Analyzing control flow
33
======================
44

5-
QL for C/C++
6-
7-
.. container:: semmle-logo
8-
9-
Semmle :sup:`TM`
5+
CodeQL for C/C++
106

117
.. Include information slides here
128
@@ -18,17 +14,17 @@ Setup
1814
For this example you should download:
1915

2016
- `QL for Eclipse <https://help.semmle.com/ql-for-eclipse/Content/WebHelp/install-plugin-free.html>`__
21-
- `ChakraCore snapshot <https://downloads.lgtm.com/snapshots/cpp/microsoft/chakracore/ChakraCore-revision-2017-April-12--18-13-26.zip>`__
17+
- `ChakraCore database <https://downloads.lgtm.com/snapshots/cpp/microsoft/chakracore/ChakraCore-revision-2017-April-12--18-13-26.zip>`__
2218

2319
.. note::
2420

2521
For the examples in this presentation, we will be analyzing `ChakraCore <https://github.com/microsoft/ChakraCore>`__.
2622

2723
You can query the project in `the query console <https://lgtm.com/query/project:2034240708/lang:cpp/>`__ on LGTM.com.
2824

29-
.. insert snapshot-note.rst to explain differences between snapshot available to download and the version available in the query console.
25+
.. insert database-note.rst to explain differences between database available to download and the version available in the query console.
3026
31-
.. include:: ../slide-snippets/snapshot-note.rst
27+
.. include:: ../slide-snippets/database-note.rst
3228

3329
.. resume slides
3430
@@ -93,7 +89,7 @@ Control flow graphs
9389
Modeling control flow
9490
=====================
9591

96-
The control flow is modeled with a QL class, ``ControlFlowNode``. Examples of control flow nodes include statements and expressions.
92+
The control flow is modeled with a CodeQL class, ``ControlFlowNode``. Examples of control flow nodes include statements and expressions.
9793

9894
- ``ControlFlowNode`` provides API for traversing the control flow graph:
9995

@@ -226,7 +222,7 @@ A ``GuardCondition`` is a ``Boolean`` condition that controls one or more basic
226222
Further materials
227223
=================
228224

229-
- QL for C/C++: https://help.semmle.com/QL/learn-ql/ql/cpp/ql-for-cpp.html
225+
- CodeQL for C/C++: https://help.semmle.com/QL/learn-ql/ql/cpp/ql-for-cpp.html
230226
- API reference: https://help.semmle.com/qldoc/cpp
231227

232228
.. rst-class:: end-slide

0 commit comments

Comments
 (0)