Skip to content

Commit eb89851

Browse files
authored
Merge branch 'master' into update-references
2 parents 9db6b8f + 965235a commit eb89851

File tree

5 files changed

+55
-41
lines changed

5 files changed

+55
-41
lines changed

cpp/ql/src/Likely Bugs/ReturnConstTypeMember.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ struct S {
88

99
// Whereas here it does make a semantic difference.
1010
auto getValCorrect() const -> int {
11-
return val
11+
return val;
1212
}
1313
};

cpp/ql/src/semmle/code/cpp/ir/dataflow/DefaultTaintTracking.qll

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,22 @@ private predicate instructionTaintStep(Instruction i1, Instruction i2) {
201201
or
202202
i2.(UnaryInstruction).getUnary() = i1
203203
or
204-
i2.(ChiInstruction).getPartial() = i1 and
204+
// Flow out of definition-by-reference
205+
i2.(ChiInstruction).getPartial() = i1.(WriteSideEffectInstruction) and
205206
not i2.isResultConflated()
206207
or
208+
// Flow from an element to an array or union that contains it.
209+
i2.(ChiInstruction).getPartial() = i1 and
210+
not i2.isResultConflated() and
211+
exists(Type t | i2.getResultLanguageType().hasType(t, false) |
212+
t instanceof Union
213+
or
214+
t instanceof ArrayType
215+
or
216+
// Buffers or unknown size
217+
t instanceof UnknownType
218+
)
219+
or
207220
exists(BinaryInstruction bin |
208221
bin = i2 and
209222
predictableInstruction(i2.getAnOperand().getDef()) and

docs/language/learn-ql/writing-queries/query-help.rst

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Each query help file provides detailed information about the purpose and use of
2626
Structure
2727
=========
2828

29-
Query help files are written using an XML format called Qhelp (``.qhelp``). Query help files must have the same base name as the query they describe, and must be located in the same directory. The basic structure is as follows:
29+
Query help files are written using a custom XML format, and stored in a file with a ``.qhelp`` extension. Query help files must have the same base name as the query they describe, and must be located in the same directory. The basic structure is as follows:
3030

3131
.. code-block:: xml
3232
@@ -44,32 +44,32 @@ Section-level elements
4444

4545
Section-level elements are used to group the information in the help file into sections. Many sections have a heading, either defined by a ``title`` attribute or a default value. The following section-level elements are optional child elements of the ``qhelp`` element.
4646

47-
+--------------------+------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
48-
| Element | Attributes | Children | Purpose of section |
49-
+====================+====================================+========================+===============================================================================================================================================+
50-
| ``example`` | None | Any block element | Demonstrate an example of code that violates the rule implemented by the query with guidance on how to fix it. Default heading. |
51-
+--------------------+------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
52-
| ``fragment`` | None | Any block element | See :ref:`Qhelp inclusion <qhelp-inclusion>` below. No heading. |
53-
+--------------------+------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
54-
| ``hr`` | None | None | A horizontal rule. No heading. |
55-
+--------------------+------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
56-
| ``include`` | ``src`` The Qhelp file to include. | None | Include a Qhelp file at the location of this element. See :ref:`Qhelp inclusion <qhelp-inclusion>` below. No heading. |
57-
+--------------------+------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
58-
| ``overview`` | None | Any block element | Overview of the purpose of the query. Typically this is the first section in a query document. No heading. |
59-
+--------------------+------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
60-
| ``recommendation`` | None | Any block element | Recommend how to address any alerts that this query identifies. Default heading. |
61-
+--------------------+------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
62-
| ``references`` | None | ``li`` elements | Reference list. Typically this is the last section in a query document. Default heading. |
63-
+--------------------+------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
64-
| ``section`` | ``title`` Title of the section | Any block element | General-purpose section with a heading defined by the ``title`` attribute. |
65-
+--------------------+------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
66-
| ``semmleNotes`` | None | Any block element | Implementation notes about the query. This section is used only for queries that implement a rule defined by a third party. Default heading. |
67-
+--------------------+------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
47+
+--------------------+-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
48+
| Element | Attributes | Children | Purpose of section |
49+
+====================+=========================================+========================+===============================================================================================================================================+
50+
| ``example`` | None | Any block element | Demonstrate an example of code that violates the rule implemented by the query with guidance on how to fix it. Default heading. |
51+
+--------------------+-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
52+
| ``fragment`` | None | Any block element | See :ref:`Query help inclusion <qhelp-inclusion>` below. No heading. |
53+
+--------------------+-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
54+
| ``hr`` | None | None | A horizontal rule. No heading. |
55+
+--------------------+-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
56+
| ``include`` | ``src`` The query help file to include. | None | Include a query help file at the location of this element. See :ref:`Query help inclusion <qhelp-inclusion>` below. No heading. |
57+
+--------------------+-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
58+
| ``overview`` | None | Any block element | Overview of the purpose of the query. Typically this is the first section in a query document. No heading. |
59+
+--------------------+-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
60+
| ``recommendation`` | None | Any block element | Recommend how to address any alerts that this query identifies. Default heading. |
61+
+--------------------+-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
62+
| ``references`` | None | ``li`` elements | Reference list. Typically this is the last section in a query document. Default heading. |
63+
+--------------------+-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
64+
| ``section`` | ``title`` Title of the section | Any block element | General-purpose section with a heading defined by the ``title`` attribute. |
65+
+--------------------+-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
66+
| ``semmleNotes`` | None | Any block element | Implementation notes about the query. This section is used only for queries that implement a rule defined by a third party. Default heading. |
67+
+--------------------+-----------------------------------------+------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+
6868

6969
Block elements
7070
==============
7171

72-
The following elements are optional child elements of the ``section``, ``example``, ``fragment``, ``recommendation``, ``overview`` and ``semmleNotes`` elements.
72+
The following elements are optional child elements of the ``section``, ``example``, ``fragment``, ``recommendation``, ``overview``, and ``semmleNotes`` elements.
7373

7474
.. table::
7575
:widths: 7 20 10 25
@@ -84,7 +84,8 @@ The following elements are optional child elements of the ``section``, ``example
8484
| | | ``height`` Optional, height of the image. | | |
8585
| | | ``width`` Optional, the width of the image. | | |
8686
+----------------+----------------------------------------------------------+--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
87-
| ``include`` | ``src`` The Qhelp file to include. | None | Include a Qhelp file at the location of this element. See :ref:`Qhelp inclusion <qhelp-inclusion>` below for more information. |
87+
| ``include`` | ``src`` The query help file to include. | None | Include a query help file at the location of this element. See :ref:`Query help inclusion <
88+
-inclusion>` below for more information. |
8889
+----------------+----------------------------------------------------------+--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
8990
| ``ol`` | None | ``li`` | Display an ordered list. See List elements below. |
9091
+----------------+----------------------------------------------------------+--------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
@@ -105,12 +106,12 @@ The following elements are optional child elements of the ``section``, ``example
105106
List elements
106107
=============
107108

108-
Qhelp files support two types of block elements for lists: ``ul`` and ``ol``. Both block elements support only one child elements of the type ``li``. Each ``li`` element contains either inline content or a block element.
109+
Query help files support two types of block elements for lists: ``ul`` and ``ol``. Both block elements support only one child elements of the type ``li``. Each ``li`` element contains either inline content or a block element.
109110

110111
Table elements
111112
==============
112113

113-
The ``table`` block element is used to include a table in a Qhelp file. Each table includes a number of rows, each of which includes a number of cells. The data in the cells will be rendered as a grid.
114+
The ``table`` block element is used to include a table in a query help file. Each table includes a number of rows, each of which includes a number of cells. The data in the cells will be rendered as a grid.
114115

115116
+-----------+------------+--------------------+-------------------------------------------+
116117
| Element | Attributes | Children | Purpose |
@@ -159,12 +160,12 @@ Inline content is used to define the content for paragraphs, list items, table c
159160

160161
.. _qhelp-inclusion:
161162

162-
Qhelp inclusion
163-
===============
163+
Query help inclusion
164+
====================
164165

165-
To enable the reuse of content between different help topics, shared content can be stored in one Qhelp file and then included in a number of other Qhelp files using the ``include`` element. The shared content can stored either in the same directory as the including files, or in ``SEMMLE_DIST/docs/include``.
166+
To reuse content between different help topics, you can store shared content in one query help file and then include it in a number of other query help files using the ``include`` element. The shared content can be stored either in the same directory as the including files, or in ``SEMMLE_DIST/docs/include``.
166167

167-
The ``include`` element can be used as a section or block element, the content of the Qhelp file defined by the ``src`` attribute must contain elements that are appropriate to the location of the ``include`` element.
168+
The ``include`` element can be used as a section or block element. The content of the query help file defined by the ``src`` attribute must contain elements that are appropriate to the location of the ``include`` element.
168169

169170
Section-level include elements
170171
------------------------------
@@ -177,7 +178,7 @@ Section-level ``include`` elements can be located beneath the top-level ``qhelp`
177178
<include src="XSS.qhelp" />
178179
</qhelp>
179180
180-
In this example, the `XSS.qhelp <https://github.com/Semmle/ql/blob/master/csharp/ql/src/Security%20Features/CWE-079/XSS.qhelp>`__ file must conform to the standard for a full Qhelp file as described above. That is, the ``qhelp`` element may only contain non-``fragment``, section-level elements.
181+
In this example, the `XSS.qhelp <https://github.com/Semmle/ql/blob/master/csharp/ql/src/Security%20Features/CWE-079/XSS.qhelp>`__ file must conform to the standard for a full query help file as described above. That is, the ``qhelp`` element may only contain non-``fragment``, section-level elements.
181182

182183
Block-level include elements
183184
----------------------------

docs/language/learn-ql/writing-queries/writing-queries.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ CodeQL queries are used in code scanning analyses to find problems in source cod
2222
- :doc:`Providing locations in CodeQL queries <../locations>`: CodeQL includes mechanisms for extracting the location of elements in a codebase. Use these mechanisms when writing custom CodeQL queries and libraries to help display information to users.
2323
- :doc:`About data flow analysis <../intro-to-data-flow>`: Data flow analysis is used to compute the possible values that a variable can hold at various points in a program, determining how those values propagate through the program and where they are used.
2424
- :doc:`Creating path queries <path-queries>`: You can create path queries to visualize the flow of information through a codebase.
25-
- :doc:`trouble shooting query performance <debugging-queries>`: Improve the performance of your CodeQL queries by following a few simple guidelines.
25+
- :doc:`Troubleshooting query performance <debugging-queries>`: Improve the performance of your CodeQL queries by following a few simple guidelines.

0 commit comments

Comments
 (0)