Skip to content

Commit af0f32f

Browse files
committed
further changes for query help in sarif
1 parent 3bfa868 commit af0f32f

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

docs/codeql/codeql-cli/analyzing-databases-with-the-codeql-cli.rst

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ You can also specify:
6464
see `Configuring CodeQL CLI in your CI system <https://docs.github.com/en/code-security/secure-coding/using-codeql-code-scanning-with-your-existing-ci-system/configuring-codeql-cli-in-your-ci-system>`__ in the GitHub documentation.
6565

6666
- ``--sarif-add-query-help``: (supported in version 2.7.1 onwards) adds any custom query help written
67-
in Markdown to SARIF (v2.1.0 or later) analysis results. For each query that runs, CodeQL command
68-
replaces the ``.ql`` extension of the query file with ``.md``. If the .md file exists,
69-
its contents are treated as Markdown-formatted help text for the query and included in the SARIF output.
67+
in Markdown to SARIF (v2.1.0 or later) analysis results. Query help stored in ``.qhelp`` files must be
68+
converted to ``.md`` before running the analysis. For further information,
69+
see ":doc:`Testing query help files <testing-query-help-files>`."
7070

7171
- .. include:: ../reusables/threads-query-execution.rst
7272

@@ -206,6 +206,20 @@ A SARIF results file is generated. Specifying ``--format=sarif-latest`` ensures
206206
that the results are formatted according to the most recent SARIF specification
207207
supported by CodeQL.
208208

209+
.. _including-query-help-for-custom-codeql-queries-in-sarif-files:
210+
211+
Including query help for custom CodeQL queries in SARIF files
212+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
213+
214+
Code scanning does not process ``.qhelp`` files for custom CodeQL queries, so to show
215+
query help for custom queries in the code scanning UI you must include markdown-rendered query help
216+
in SARIF files generated during an analysis.
217+
218+
For CodeQL CLI 2.7.1 onwards, you can include markdown-rendered query help in SARIF files
219+
by providing the ``--sarif-add-query-help`` option when running
220+
``codeql database analyze``. Query help written in ``.qhelp`` files cannot be include in SARIF files,
221+
somust be converted to markdown before running the analysis. For more information, see
222+
":doc:`Testing query help files <testing-query-help-files>`."
209223

210224
Results
211225
-------

docs/codeql/codeql-cli/testing-query-help-files.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ in the CodeQL repository.
1515
The CodeQL CLI includes a command to test query help and render the content as
1616
markdown, so that you can easily preview the content in your IDE. Use the command to validate
1717
query help files before uploading them to the CodeQL repository or sharing them with other users.
18+
For CodeQL CLI 2.7.1 onwards, you can also include the markdown-rendered query help in SARIF files
19+
generated during CodeQL analyses so that the query help can be displayed in the code scanning UI.
20+
For more information, see
21+
":ref:`Analyzing databases with the CodeQL CLI <including-query-help-for-custom-codeql-queries-in-sarif-files>`."
1822

1923
Prerequisites
2024
-------------

docs/codeql/writing-codeql-queries/query-help-files.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ Query help files are written using a custom XML format, and stored in a file wit
4040
The header and single top-level ``qhelp`` element are both mandatory.
4141
The following sections explain additional elements that you may include in your query help files.
4242

43+
.. pull-quote::
44+
45+
Code scanning does not process ``.qhelp`` files for custom CodeQL queries, so to show
46+
query help for custom queries in the code scanning UI you must convert the ``.qhelp`` files to markdown
47+
and then include the markdown-rendered query help in SARIF files generated during an analysis.
48+
For more information, see
49+
":ref:`Analyzing databases with the CodeQL CLI <including-query-help-for-custom-codeql-queries-in-sarif-files>`."
4350

4451
Section-level elements
4552
======================

0 commit comments

Comments
 (0)