You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/codeql/codeql-for-visual-studio-code/using-the-codeql-model-editor.rst
+33-17Lines changed: 33 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,37 +14,46 @@ About the CodeQL model editor
14
14
15
15
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
16
16
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.
18
18
19
19
The model editor has two different modes:
20
20
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.
22
22
23
23
- 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.
24
24
25
25
Displaying the CodeQL model editor
26
26
----------------------------------
27
27
28
28
#. 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.
31
31
#. Use the command palette to run the “CodeQL: Open Model Editor (Beta)” command.
32
32
#. The CodeQL model editor will open in a new tab and run a series of telemetry queries to identify APIs in the code.
33
33
#. When the queries are complete, the APIs that have been identified are shown in the editor.
34
34
35
-
Modeling the calls to external APIs from your codebase
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.
39
39
40
40
#. 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.
: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.
43
46
44
47
#. Click to expand an external API and view the list of calls from the codebase to the external dependency.
45
48
#. Click **View** associated with an API call or method to show where it is used in your codebase.
: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
+
46
54
#. When you have determined how to model the call or method, define the **Model type**.
47
55
#. The remaining fields are updated with available options:
56
+
48
57
- **Source**: choose the **Output** element to model.
49
58
- **Sink**: choose the **Input** element to model.
50
59
- **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
64
73
Modeling the public API of a codebase
65
74
-------------------------------------
66
75
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.
68
77
69
78
#. Select the CodeQL database that you want to model.
70
79
#. 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?
72
80
73
-
#. Click to expand a public method and view the list of available methods.
: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.
74
86
#. Click **View** associated with a method to show its definition.
: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
+
75
92
#. When you have determined how to model the method, define the **Model type**.
76
93
#. The remaining fields are updated with available options:
94
+
77
95
- **Source**: choose the **Output** element to model.
78
96
- **Sink**: choose the **Input** element to model.
79
97
- **Flow summary**: choose the **Input** and **Output** elements to model.
@@ -97,12 +115,10 @@ Testing CodeQL model packs
97
115
98
116
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.
99
117
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,``
104
120
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.
Copy file name to clipboardExpand all lines: docs/codeql/codeql-for-visual-studio-code/working-with-codeql-packs-in-visual-studio-code.rst
+1-5Lines changed: 1 addition & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,8 +52,4 @@ To view the full definition of an element of a query, you can right-click and ch
52
52
Working with CodeQL model packs
53
53
-------------------------------
54
54
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>`."
Copy file name to clipboardExpand all lines: docs/codeql/codeql-language-guides/data-extensions-to-model-java-dependencies.rst
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,11 @@ You can use data extensions to model the methods and callables that control data
12
12
About this article
13
13
------------------
14
14
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>`."
Copy file name to clipboardExpand all lines: docs/codeql/codeql-language-guides/extensible-predicates.rst
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ You can use data extensions to model the methods and callables that control data
13
13
About this article
14
14
------------------
15
15
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.
17
17
18
18
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.
0 commit comments