Skip to content

Commit d3eb533

Browse files
author
james
committed
docs: update titles, some links, add intros
1 parent 2245d64 commit d3eb533

10 files changed

Lines changed: 46 additions & 34 deletions

docs/language/learn-ql/cpp/conversions-classes.rst

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
Tutorial: Conversions and classes
2-
=================================
1+
Conversions and classes in C and C++
2+
====================================
33

4-
Overview
5-
--------
6-
7-
This topic contains worked examples of how to write queries using the CodeQL library classes for C/C++ conversions and classes.
4+
You can use the standard CodeQL libraries for C and C++ to detect when the type of an expression is changed.
85

96
Conversions
107
-----------
@@ -227,7 +224,7 @@ What next?
227224
----------
228225

229226
- Explore other ways of querying classes using examples from the `C/C++ cookbook <https://help.semmle.com/wiki/label/CBCPP/class>`__.
230-
- Take a look at the :doc:`Analyzing data flow in C/C++ <dataflow>` tutorial.
231-
- Try the worked examples in the following topics: :doc:`Example: Checking that constructors initialize all private fields <private-field-initialization>`, and :doc:`Example: Checking for allocations equal to 'strlen(string)' without space for a null terminator <zero-space-terminator>`.
227+
- Take a look at the :doc:`Analyzing data flow in C and C++ <dataflow>` tutorial.
228+
- Try the worked examples in the following topics: :doc:`Refining a query to account for edge cases <private-field-initialization>`, and :doc:`Detecting a potential buffer overflow <zero-space-terminator>`.
232229
- 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>`__.
233230
- Learn more about the query console in `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
Analyzing data flow in C/C++
2-
============================
1+
Analyzing data flow in C and C++
2+
================================
33

4-
Overview
5-
--------
4+
You can use data-flow analysis to track the flow of potentially malicious or insecure data that can cause vulnerabilities in your code base.
65

76
This topic describes how data flow analysis is implemented in the CodeQL libraries for C/C++ and includes examples to help you write your own data flow queries.
87
The following sections describe how to utilize the libraries for local data flow, global data flow, and taint tracking.
@@ -299,7 +298,7 @@ Exercise 4: Using the answers from 2 and 3, write a query which finds all global
299298
What next?
300299
----------
301300

302-
- Try the worked examples in the following topics: :doc:`Example: Checking that constructors initialize all private fields <private-field-initialization>` and :doc:`Example: Checking for allocations equal to 'strlen(string)' without space for a null terminator <zero-space-terminator>`.
301+
- Try the worked examples in the following topics: :doc:`Refining a query to account for edge cases <private-field-initialization>` and :doc:`Detecting a potential buffer overflow <zero-space-terminator>`.
303302
- 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>`__.
304303
- Learn more about the query console in `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.
305304

docs/language/learn-ql/cpp/expressions-types.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
Tutorial: Expressions, types and statements
2-
===========================================
1+
Expressions, types, and statements in C and C++
2+
===============================================
33

4-
Overview
5-
--------
4+
You can use CodeQL to explore expressions, types, and statements in C and C++ code to find, for example, incorrect assignments.
65

76
This topic contains worked examples of how to write queries using the standard CodeQL library classes for C/C++ expressions, types, and statements.
87

@@ -136,6 +135,6 @@ What next?
136135
----------
137136

138137
- Explore other ways of finding types and statements using examples from the C/C++ cookbook for `types <https://help.semmle.com/wiki/label/CBCPP/type>`__ and `statements <https://help.semmle.com/wiki/label/CBCPP/statement>`__.
139-
- Take a look at the :doc:`Conversions and classes <conversions-classes>` and :doc:`Analyzing data flow in C/C++ <dataflow>` tutorials.
138+
- Take a look at the :doc:`Conversions and classes in C and C++ <conversions-classes>` and :doc:`Analyzing data flow in C and C++ <dataflow>` tutorials.
140139
- 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>`__.
141140
- Learn more about the query console in `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.

docs/language/learn-ql/cpp/function-classes.rst

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
Tutorial: Function classes
2-
==========================
1+
Functions in C and C++
2+
=======================
3+
4+
You can use CodeQL to explore functions in C and C++ code.
35

46
Overview
57
--------
68

7-
The standard CodeQL library for C and C++ represents functions using the ``Function`` class (see :doc:`Introducing the C/C++ libraries <introduce-libraries-cpp>`).
9+
The standard CodeQL library for C and C++ represents functions using the ``Function`` class (see :doc:`CodeQL libraries for C and C++ <introduce-libraries-cpp>`).
810

911
The example queries in this topic explore some of the most useful library predicates for querying functions.
1012

@@ -26,7 +28,7 @@ This query is very general, so there are probably too many results to be interes
2628
Finding functions that are not called
2729
-------------------------------------
2830

29-
It might be more interesting to find functions that are not called, using the standard CodeQL ``FunctionCall`` class from the **abstract syntax tree** category (see :doc:`Introducing the C/C++ libraries <introduce-libraries-cpp>`). The ``FunctionCall`` class can be used to identify places where a function is actually used, and it is related to ``Function`` through the ``FunctionCall.getTarget()`` predicate.
31+
It might be more interesting to find functions that are not called, using the standard CodeQL ``FunctionCall`` class from the **abstract syntax tree** category (see :doc:`CodeQL libraries for C and C++ <introduce-libraries-cpp>`). The ``FunctionCall`` class can be used to identify places where a function is actually used, and it is related to ``Function`` through the ``FunctionCall.getTarget()`` predicate.
3032

3133
.. code-block:: ql
3234
@@ -91,6 +93,6 @@ What next?
9193
----------
9294

9395
- Explore other ways of finding functions using examples from the `C/C++ cookbook <https://help.semmle.com/wiki/label/CBCPP/function>`__.
94-
- Take a look at some of the other tutorials: :doc:`Expressions, types and statements <expressions-types>`, :doc:`Conversions and classes <conversions-classes>`, and :doc:`Analyzing data flow in C/C++ <dataflow>`.
96+
- Take a look at some other tutorials: :doc:`Expressions, types and statements in C and C++ <introduce-libraries-cpp>`, :doc:`Conversions and classes in C and C++ <conversions-classes>`, and :doc:`Analyzing data flow in C and C++ <dataflow>`.
9597
- 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>`__.
9698
- Learn more about the query console in `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.

docs/language/learn-ql/cpp/guards.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Using the guards library in C and C++
22
=====================================
33

4+
You can use the CodeQL guards library to identify conditional expressions that control the execution of other code in C and C++ codebases.
5+
46
Overview
57
--------
68

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
Introducing the CodeQL libraries for C/C++
2-
==========================================
1+
CodeQL libraries for C and C++
2+
==============================
3+
4+
Explore the standard CodeQL libraries for C and C++.
35

46
Overview
57
--------
68

7-
There is an extensive library for analyzing CodeQL databases extracted from C/C++ projects. The classes in this library present the data from a database in an object-oriented form and provide abstractions and predicates to help you with common analysis tasks. The library is implemented as a set of QL modules, that is, files with the extension ``.qll``. The module ``cpp.qll`` imports all the core C/C++ library modules, so you can include the complete library by beginning your query with:
9+
There is an extensive library for analyzing CodeQL databases extracted from C/C++ projects. The classes in this library present the data from a database in an object-oriented form and provide abstractions and predicates to help you with common analysis tasks.
10+
The library is implemented as a set of QL modules, that is, files with the extension ``.qll``. The module ``cpp.qll`` imports all the core C/C++ library modules, so you can include the complete library by beginning your query with:
811

912
.. code-block:: ql
1013
1114
import cpp
1215
1316
The rest of this topic summarizes the available CodeQL classes and corresponding C/C++ constructs.
1417

15-
NOTE: You can find related classes and features using the query console's auto-complete feature. You can also press *F3* to jump to the definition of any element; library files are opened in new tabs in the console.
18+
.. pull-quote:: Note
19+
20+
You can find related classes and features using the query console's auto-complete feature. You can also press *F3* to jump to the definition of any element. Library files are opened in new tabs in the console.
1621

1722
Summary of the library classes
1823
------------------------------
@@ -522,6 +527,6 @@ This table lists `Preprocessor <https://help.semmle.com/qldoc/cpp/semmle/code/cp
522527
What next?
523528
----------
524529

525-
- Experiment with the worked examples in the CodeQL for C/C++ topics: :doc:`Function classes <function-classes>`, :doc:`Expressions, types and statements <expressions-types>`, :doc:`Conversions and classes <conversions-classes>`, and :doc:`Analyzing data flow in C/C++ <dataflow>`.
530+
- Experiment with the worked examples in the CodeQL for C/C++ topics: :doc:`Functions in C and C++ <function-classes>`, :doc:`Expressions, types, and statements in C and C++ <expressions-types>`, :doc:`Conversions and classes in C and C++ <conversions-classes>`, and :doc:`Analyzing data flow in C and C++ <dataflow>`.
526531
- 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>`__.
527532
- Learn more about the query console in `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.

docs/language/learn-ql/cpp/private-field-initialization.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
Example: Checking that constructors initialize all private fields
2-
=================================================================
1+
Refining a query to account for edge cases
2+
==========================================
3+
4+
You can improve the results generated by a CodeQL query by adding conditions to remove false positives caused by common edge cases.
35

46
Overview
57
--------
@@ -147,6 +149,6 @@ Finally we can simplify the query by using the `transitive closure operator <htt
147149
What next?
148150
----------
149151

150-
- Take a look at another example: :doc:`Checking for allocations equal to 'strlen(string)' without space for a null terminator <zero-space-terminator>`.
152+
- Take a look at another example: :doc:`Detecting a potential buffer overflow <zero-space-terminator>`.
151153
- 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>`__.
152154
- Learn more about the query console in `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.

docs/language/learn-ql/cpp/range-analysis.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Using range analysis for C and C++
22
==================================
33

4+
You can use range analysis to determine the upper or lower bounds on an expression, or whether an expression could potentially over or underflow.
5+
46
Overview
57
--------
68

docs/language/learn-ql/cpp/value-numbering-hash-cons.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
Hash consing and value numbering
2-
=================================================
2+
================================
3+
4+
You can use specialized CodeQL libraries to recognize expressions that are syntactically identical or compute the same value at runtime in C and C++ codebases.
35

46
Overview
57
--------

docs/language/learn-ql/cpp/zero-space-terminator.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
Example: Checking for allocations equal to ``strlen(string)`` without space for a null terminator
2-
=================================================================================================
1+
Detecting a potential buffer overflow
2+
=====================================
3+
4+
You can use CodeQL to detect potential buffer overflows by checking for allocations equal to ``strlen`` in C and C++.
35

46
Overview
57
--------

0 commit comments

Comments
 (0)