Skip to content

Commit ed5e281

Browse files
committed
Draft docs for revised UI
1 parent cedb91b commit ed5e281

9 files changed

+28
-8
lines changed

docs/codeql/codeql-for-visual-studio-code/using-the-codeql-model-editor.rst

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ When you open the model editor, it analyzes the currently selected CodeQL databa
1818

1919
The model editor has two different modes:
2020

21-
- Application mode (default view): The editor lists each external framework used by the selected CodeQL database. When you expand a framework, a list of all calls to and from the external API is shown with the options available to model dataflow through each call. This mode is most useful for improving the CodeQL results for the specific codebase.
21+
- Application mode (default view): The editor lists each external framework used by the selected CodeQL database. When you expand a framework, a list of all calls to and from the external API is shown with the options available to model dataflow through each call. This mode is most useful for improving the CodeQL results for a specific codebase.
2222

2323
- Dependency mode: The editor identifies all of the publicly accessible APIs in the selected CodeQL database. This view guides you through modeling each public API that the codebase makes available. When you have finished modeling the entire API, you can save the model and use it to improve the CodeQL analysis for all codebases that use the dependency.
2424

@@ -28,38 +28,49 @@ Displaying the CodeQL model editor
2828
#. Open your CodeQL workspace in VS Code, for example, the ``vscode-codeql-starter`` workspace.
2929
If you haven't updated the ``ql`` submodule for a while, update it from ``main`` to ensure that you have the queries used to gather data for the model editor.
3030
#. Open the CodeQL extension and select the CodeQL database that you want to model from the "Databases" section of the left side pane.
31-
#. Use the command palette to run the CodeQL: Open Model Editor (Beta)” command.
32-
#. The CodeQL model editor will open in a new tab and run a series of telemetry queries to identify APIs in the code.
31+
#. In the left side panel, expand the "CodeQL method modeling" section and click **Start modeling** to display the model editor.
32+
#. The CodeQL model editor runs a series of telemetry queries to identify APIs in the code and opens in a new tab.
3333
#. When the queries are complete, the APIs that have been identified are shown in the editor.
3434

3535
Modeling the calls your codebase makes to external APIs
3636
-------------------------------------------------------
3737

38-
You typically use this approach when you are looking at a specific codebase where you want to improve the precision of CodeQL results. This is usually when the codebase uses frameworks or libraries that are not supported by CodeQL and if the source code of the framework or library is not included in the analysis.
38+
You typically use this approach when you are looking at a specific codebase where you want to improve the precision of CodeQL results. This is useful when the codebase uses frameworks or libraries that are not supported by CodeQL and if the source code of the framework or library is not included in the analysis.
3939

4040
#. Select the CodeQL database that you want to improve CodeQL coverage for.
4141
#. Display the CodeQL model editor. By default the editor runs in application mode, so the list of external APIs used by the selected codebase is shown.
4242

4343
.. image:: ../images/codeql-for-visual-studio-code/model-application-mode.png
4444
:width: 800
45-
:alt: Screenshot of the "Application mode" view of the CodeQL model pack editor in Visual Studio Code showing three of the external frameworks used by the "sofa-jraft" codebase.
45+
:alt: Screenshot of the "Application mode" view of the CodeQL model pack editor in Visual Studio Code showing two of the external Java frameworks used by the "sofa-jraft" codebase.
4646

4747
#. Click to expand an external API and view the list of calls from the codebase to the external dependency.
48-
#. Click **View** associated with an API call or method to show where it is used in your codebase.
4948

5049
.. image:: ../images/codeql-for-visual-studio-code/model-application-mode-expanded.png
5150
:width: 800
5251
:alt: Screenshot of the "Application mode" view of the CodeQL model pack editor in Visual Studio Code showing the calls to the "rocksdbjni" framework ready for modeling. The "View" option for the first call is highlighted with a dark orange outline.
5352

54-
#. When you have determined how to model the call or method, define the **Model type**.
53+
#. Click **View** associated with an API call or method to show where it is used in your codebase.
54+
55+
.. image:: ../images/codeql-for-visual-studio-code/model-application-mode-view-code.png
56+
:width: 800
57+
:alt: Screenshot of a file showing a place where your codebase calls the API is highlighted with a dark orange outline.
58+
59+
#. The file containing the first call from your codebase to the API is opened and a "CodeQL methods usage" view opened (typically this is co-located with the "Problems" and "Terminal" views. The "CodeQL methods usage" view lists of all the calls from your code to the API, grouped by method. You can click through each use to decide how to a model the method.
60+
61+
.. image:: ../images/codeql-for-visual-studio-code/model-application-mode-view-list.png
62+
:width: 800
63+
:alt: Screenshot of the "CodeQL methods usage" view. The currently displayed method call is highlighted blue.
64+
65+
#. When you have determined how to model the call or method, define the **Model type** in either the main model editor tab, or in the "CodeQL method modeling" tab.
5566
#. The remaining fields are updated with available options:
5667

5768
- **Source**: choose the **Output** element to model.
5869
- **Sink**: choose the **Input** element to model.
5970
- **Flow summary**: choose the **Input** and **Output** elements to model.
6071

6172
#. Define the **Kind** of dataflow for the model.
62-
#. When you have finished modeling, click **Save all** or **Save** (shown at the bottom right of each expanded list of calls). The percentage of calls modeled in the editor is updated.
73+
#. When you have finished modeling, display the main model editor and click **Save all** or **Save** (shown at the bottom right of each expanded list of methods). The percentage of methods modeled in the editor is updated.
6374

6475
The models are stored in your workspace at ``.github/codeql/extensions/<codeql-model-pack>``, where ``<codeql-model-pack>`` is the name of the CodeQL database that you selected. That is, the name of the repository, hyphen, the language analyzed by CodeQL.
6576

@@ -114,6 +125,15 @@ The models are stored in a series of YAML data extension files, one for each pub
114125
115126
The editor will create a separate model file for each package that you model.
116127

128+
Modeling methods that can be called in different ways
129+
-----------------------------------------------------
130+
131+
Some methods behave differently according to how they are called. In this case, once you have created one model for the method, you can add a second model using the **+** button in the method row.
132+
133+
.. image:: ../images/codeql-for-visual-studio-code/model-dependency-mode-plus.png
134+
:width: 800
135+
:alt: Screenshot of the "Dependency mode" view of the CodeQL model pack editor in Visual Studio Code showing one model for the ``com.alipay.sofa.jraft.option.BallotBoxOptions.getClosureQueue()`` method. The "+" button is outlined in dark orange. Click this button to create a second model for the method.
136+
117137
Testing CodeQL model packs
118138
--------------------------
119139

-49.6 KB
Loading
509 KB
Loading
135 KB
Loading
213 KB
Loading
-12.7 KB
Loading
42.3 KB
Loading
53 KB
Loading
10.7 KB
Loading

0 commit comments

Comments
 (0)