Skip to content

Commit 93eff2a

Browse files
committed
A few more updates
1 parent 488b824 commit 93eff2a

File tree

8 files changed

+40
-24
lines changed

8 files changed

+40
-24
lines changed

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

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,46 @@ About the CodeQL model editor
1414

1515
The CodeQL model editor guides you through modeling the calls to external dependencies in your application or fully modeling all the public entry and exit points in an external dependency
1616

17-
When you open the model editor, it analyzes the currently selected CodeQL database and identifies where the application uses external APIs. An external (or third party) API is any API that is not part of the CodeQL database you have selected.
17+
When you open the model editor, it analyzes the currently selected CodeQL database and identifies where the application uses external APIs and all public methods. An external (or third party) API is any API that is not part of the CodeQL database you have selected.
1818

1919
The model editor has two different modes:
2020

21-
- Application mode (default view): The editor lists each the external framework used by the seelcted 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 seelcted 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.
2222

2323
- Dependency mode: The editor identifies the all 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

2525
Displaying the CodeQL model editor
2626
----------------------------------
2727

2828
#. Open your CodeQL workspace in VS Code, for example, the vscode-codeql-starter workspace.
29-
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.
30-
#. Open the CodeQL extension and select the CodeQL database that you want to model from the Databases section of the left side pane.
29+
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.
30+
#. Open the CodeQL extension and select the CodeQL database that you want to model from the "Databases" section of the left side pane.
3131
#. Use the command palette to run the “CodeQL: Open Model Editor (Beta)” command.
3232
#. The CodeQL model editor will open in a new tab and run a series of telemetry queries to identify APIs in the code.
3333
#. When the queries are complete, the APIs that have been identified are shown in the editor.
3434

35-
Modeling the calls to external APIs from your codebase
36-
------------------------------------------------------
35+
Modeling the calls your codebase makes to external APIs
36+
-------------------------------------------------------
3737

38-
You typically use this method 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 they also are not used by other teams in your organization.
38+
You typically use this method 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 but they are not used by other teams in your organization.
3939

4040
#. Select the CodeQL database that you want to improve CodeQL coverage for.
41-
#. Display the CodeQL model editor, by default the editor runs in application mode, so displays the list of external APIs used by the selected codebase.
42-
INSERT SCREENSHOT?
41+
#. 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.
42+
43+
.. image:: ../images/codeql-for-visual-studio-code/model-application-mode.png
44+
: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.
4346

4447
#. Click to expand an external API and view the list of calls from the codebase to the external dependency.
4548
#. Click **View** associated with an API call or method to show where it is used in your codebase.
49+
50+
.. image:: ../images/codeql-for-visual-studio-code/model-application-mode-expanded.png
51+
:width: 800
52+
: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.
53+
4654
#. When you have determined how to model the call or method, define the **Model type**.
4755
#. The remaining fields are updated with available options:
56+
4857
- **Source**: choose the **Output** element to model.
4958
- **Sink**: choose the **Input** element to model.
5059
- **Flow summary**: choose the **Input** and **Output** elements to model.
@@ -64,16 +73,25 @@ The models are stored in a series of YAML data extension files, one for each ext
6473
Modeling the public API of a codebase
6574
-------------------------------------
6675

67-
You typically use this method when you want to model a framework or library that your organization uses in more than one codebase. Once you have finished creating and testing the model, you can publish the CodeQL model pack for your whole organization to use.
76+
You typically use this method when you want to model a framework or library that your organization uses in more than one codebase. Once you have finished creating and testing the model, you can publish the CodeQL model pack to the GitHub Container Registry for your whole organization to use.
6877

6978
#. Select the CodeQL database that you want to model.
7079
#. Display the CodeQL model editor, by default the editor runs in application mode. Click **Model as dependency** to display dependency mode. The screen changes to show the public API of the framework or library.
71-
INSERT SCREENSHOT?
7280

73-
#. Click to expand a public method and view the list of available methods.
81+
.. image:: ../images/codeql-for-visual-studio-code/model-dependency-mode.png
82+
:width: 800
83+
:alt: Screenshot of the "Dependency mode" view of the CodeQL model pack editor in Visual Studio Code showing three of the packages published by the "sofa-jraft" codebase.
84+
85+
#. Click to expand a package and view the list of available methods.
7486
#. Click **View** associated with a method to show its definition.
87+
88+
.. image:: ../images/codeql-for-visual-studio-code/model-dependency-mode-expanded.png
89+
:width: 800
90+
:alt: Screenshot of the "Dependency mode" view of the CodeQL model pack editor in Visual Studio Code showing the public methods available in the "com.alipay.soft.jraft.option" package ready for modeling. The "View" option for the first method is highlighted with a dark orange outline.
91+
7592
#. When you have determined how to model the method, define the **Model type**.
7693
#. The remaining fields are updated with available options:
94+
7795
- **Source**: choose the **Output** element to model.
7896
- **Sink**: choose the **Input** element to model.
7997
- **Flow summary**: choose the **Input** and **Output** elements to model.
@@ -97,12 +115,10 @@ Testing CodeQL model packs
97115

98116
You can test any CodeQL model packs you create in VS Code by toggling the "use model packs" setting on and off. This method works for both databases and for variant analysis repositories.
99117

100-
- To run queries on a CodeQL database with any model packs that are stored within the ``.github/codeql/extensions`` directory of the workspace, update your ``settings.json`` file with: ``"codeQL.runningQueries.useModelPacks": all,``.
101-
- To run queries on a CodeQL database without using model packs, update your ``settings.json`` file with: ``"codeQL.runningQueries.useModelPacks": none,``.
102-
103-
If your model is working well, you should see a difference in the results of the two different runs. If you don't see any differences results, you may want to introduce a known bug to verify that the model behaves as expected.
118+
- To run queries on a CodeQL database with any model packs that are stored within the ``.github/codeql/extensions`` directory of the workspace, update your ``settings.json`` file with: ``"codeQL.runningQueries.useModelPacks": all,``
119+
- To run queries on a CodeQL database without using model packs, update your ``settings.json`` file with: ``"codeQL.runningQueries.useModelPacks": none,``
104120

105-
#. If you have set up VS Code to use data extensions (using the “codeQL.runningQueries.useExtensionPacks” setting), then you can also run a query and see that the unsafe calls are now detected.
121+
If your model is working well, you should see a difference in the results of the two different runs. If you don't see any differences in results, you may need to introduce a known bug to verify that the model behaves as expected.
106122

107123
Using CodeQL model packs with code scanning
108124
-------------------------------------------

docs/codeql/codeql-for-visual-studio-code/working-with-codeql-packs-in-visual-studio-code.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,4 @@ To view the full definition of an element of a query, you can right-click and ch
5252
Working with CodeQL model packs
5353
-------------------------------
5454

55-
The CodeQL extension for Visual Studio Code includes a dedicated editor for creating and editing model packs.
56-
57-
TODO a little more, but mostly about the general use, because editing will be in a new article.
58-
59-
For headings use ~~~~~~~~ in this section
55+
The CodeQL extension for Visual Studio Code includes a dedicated editor for creating and editing model packs. For information on using the model editor, see ":ref:`Using the CodeQL model editor <using-the-codeql-model-editor>`."

docs/codeql/codeql-language-guides/data-extensions-to-model-java-dependencies.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ You can use data extensions to model the methods and callables that control data
1212
About this article
1313
------------------
1414

15-
This article explains how data extensions interact with standard queries and the syntax used to define extensions. If you want to create your own data extensions, you should use the CodeQL model editor in the CodeQL extension for Visual Studio Code. For more information, see ":ref:`Using the CodeQL model editor <using-the-codeql-model-editor>`."
15+
This article contains reference material about how data extensions interact with standard queries and the syntax used to define extensions.
16+
17+
If you want to create your own data extensions, you should use the CodeQL model editor in the CodeQL extension for Visual Studio Code. The model editor automatically guides you through the process of defining models, displaying the properties you need to define and the options available. You can save the resulting models as data extensions and use them without worrying about the syntax.
18+
19+
For more information, see ":ref:`Using the CodeQL model editor <using-the-codeql-model-editor>`."
1620

1721
About data extensions
1822
---------------------

docs/codeql/codeql-language-guides/extensible-predicates.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ You can use data extensions to model the methods and callables that control data
1313
About this article
1414
------------------
1515

16-
This reference article describes of each inputs to the extensible predicates, including access paths, kinds, and provenance.
16+
This reference article describes the available inputs for the extensible predicates, including access paths, kinds, and provenance.
1717

1818
Sources, sinks, summaries, and neutrals are commonly known as models. These models support several shared arguments and a few model-specific arguments. The arguments populate a series of columns for each extensible predicate.
1919

149 KB
Loading
99.2 KB
Loading
73.5 KB
Loading
88.1 KB
Loading

0 commit comments

Comments
 (0)