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/language/learn-ql/csharp/dataflow.rst
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,10 @@ Analyzing data flow in C#
4
4
Overview
5
5
--------
6
6
7
-
This topic describes how data flow analysis is implemented in the QL for C# library and includes examples to help you write your own data flow queries.
8
-
The following sections describe how to utilize the QL libraries for local data flow, global data flow and taint tracking.
7
+
This topic describes how data flow analysis is implemented in the CodeQL libraries for C# and includes examples to help you write your own data flow queries.
8
+
The following sections describe how to utilize the libraries for local data flow, global data flow, and taint tracking.
9
9
10
-
For a more general introduction to modeling data flow in QL, see :doc:`Introduction to data flow analysis in QL<../intro-to-data-flow>`.
10
+
For a more general introduction to modeling data flow, see :doc:`Introduction to data flow analysis with CodeQL<../intro-to-data-flow>`.
11
11
12
12
Local data flow
13
13
---------------
@@ -548,6 +548,6 @@ This can be adapted from the ``SystemUriFlow`` class:
548
548
What next?
549
549
----------
550
550
551
-
- Learn about the QL standard libraries used to write queries for C# in :doc:`Introducing the C# libraries <introduce-libraries-csharp>`.
551
+
- Learn about the standard libraries used to write queries for C# in :doc:`Introducing the C# libraries <introduce-libraries-csharp>`.
552
552
- Find out more about QL in the `QL language handbook <https://help.semmle.com/QL/ql-handbook/index.html>`__ and `QL language specification <https://help.semmle.com/QL/ql-spec/language.html>`__.
553
553
- Learn more about the query console in `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.
Copy file name to clipboardExpand all lines: docs/language/learn-ql/csharp/introduce-libraries-csharp.rst
+16-18Lines changed: 16 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,23 @@
1
-
Introducing the C# libraries
2
-
============================
1
+
Introducing the CodeQL libraries for C#
2
+
=======================================
3
3
4
4
Overview
5
5
--------
6
6
7
-
The C# QL libraries are a data model for analysis of C# code. QL is an object-oriented language, so the data model is represented as *QL classes*, which are organized into *QL libraries*. The QL classes are a layer of logic built on top of an underlying database.
8
-
9
-
The core library is imported at the top of each query using:
7
+
There is an extensive library for analyzing CodeQL databases extracted from C# projects. The classes in this library present the data from a database in an object-oriented form and provide abstractions and predicates to help you with common analysis tasks. The library is implemented as a set of QL modules, that is, files with the extension ``.qll``. The module ``csharp.qll`` imports all the core C# library modules, so you can include the complete library by beginning your query with:
10
8
11
9
.. code-block:: ql
12
10
13
11
import csharp
14
12
15
-
Since this is required for all C# queries, it is omitted from QL snippets below.
13
+
Since this is required for all C# queries, it is omitted from code snippets below.
16
14
17
-
The core library contains all the program elements, including `files <#files>`__, `types <#types>`__, methods, `variables <#variables>`__, `statements <#statements>`__, and `expressions <#expressions>`__. This is sufficient for most queries, however additional libraries can be imported for bespoke functionality such as control flow and data flow. See :doc:`QL for C# <ql-for-csharp>` for information about these additional libraries.
15
+
The core library contains all the program elements, including `files <#files>`__, `types <#types>`__, methods, `variables <#variables>`__, `statements <#statements>`__, and `expressions <#expressions>`__. This is sufficient for most queries, however additional libraries can be imported for bespoke functionality such as control flow and data flow. See :doc:`CodeQL for C# <ql-for-csharp>` for information about these additional libraries.
18
16
19
17
Class hierarchies
20
18
~~~~~~~~~~~~~~~~~
21
19
22
-
Each section contains a QL class hierarchy, showing the inheritance structure between QL classes. For example:
20
+
Each section contains a class hierarchy, showing the inheritance structure between CodeQL classes. For example:
23
21
24
22
- ``Expr``
25
23
@@ -46,13 +44,13 @@ Each section contains a QL class hierarchy, showing the inheritance structure be
46
44
47
45
This means that the class ``AddExpr`` extends class ``BinaryArithmeticOperation``, which in turn extends class ``ArithmeticOperation`` and so on. If you want to query any arithmetic operation, then use the class ``ArithmeticOperation``, but if you specifically want to limit the query to addition operations, then use the class ``AddExpr``.
48
46
49
-
QL classes can also be considered to be *sets*, and the ``extends`` relation between classes defines a subset. Every member of class ``AddExpr`` is also in the class ``BinaryArithmeticOperation``. In general, QL classes overlap and an entity can be a member of several classes.
47
+
Classes can also be considered to be *sets*, and the ``extends`` relation between classes defines a subset. Every member of class ``AddExpr`` is also in the class ``BinaryArithmeticOperation``. In general, classes overlap and an entity can be a member of several classes.
50
48
51
49
This overview omits some of the less important or intermediate classes from the class hierarchy.
52
50
53
51
Each class has predicates, which are logical propositions about that class. They also define navigable relationships between classes. Predicates are inherited, so for example the ``AddExpr`` class inherits the predicates ``getLeftOperand()`` and ``getRightOperand()`` from ``BinaryArithmeticOperation``, and ``getType()`` from class ``Expr``. This is similar to how methods are inherited in object-oriented programming languages.
54
52
55
-
In this overview, we present the most common and useful predicates. Consult the reference, QL source code, and autocomplete in the editor for the complete list of predicates available on each class.
53
+
In this overview, we present the most common and useful predicates. Consult the `reference<https://help.semmle.com/qldoc/csharp>`__, the CodeQL source code, and autocomplete in the editor for the complete list of predicates available on each class.
56
54
57
55
Exercises
58
56
~~~~~~~~~
@@ -72,7 +70,7 @@ Exercise 1: Simplify the following query:
72
70
Files
73
71
-----
74
72
75
-
Files are represented by the QL class `File <https://help.semmle.com/qldoc/csharp/semmle/code/csharp/File.qll/type.File$File.html>`__, and directories by the QL class `Folder <https://help.semmle.com/qldoc/csharp/semmle/code/csharp/File.qll/type.File$Folder.html>`__. The database contains all of the source files and assemblies used during the compilation.
73
+
Files are represented by the class `File <https://help.semmle.com/qldoc/csharp/semmle/code/csharp/File.qll/type.File$File.html>`__, and directories by the class `Folder <https://help.semmle.com/qldoc/csharp/semmle/code/csharp/File.qll/type.File$Folder.html>`__. The database contains all of the source files and assemblies used during the compilation.
76
74
77
75
Class hierarchy
78
76
~~~~~~~~~~~~~~~
@@ -143,7 +141,7 @@ To list all elements in ``Main.cs``, their QL class and location:
143
141
where e.getFile().getShortName() = "Main"
144
142
select e, e.getAQlClass(), e.getLocation()
145
143
146
-
Note that ``getAQlClass()`` is available on all QL classes and is a useful way to figure out the QL class of something. Often the same element will have several QL classes which are all returned by ``getAQlClass()``.
144
+
Note that ``getAQlClass()`` is available on all entities and is a useful way to figure out the QL class of something. Often the same element will have several classes which are all returned by ``getAQlClass()``.
147
145
148
146
Locations
149
147
---------
@@ -234,7 +232,7 @@ Find declarations containing a username:
234
232
Variables
235
233
---------
236
234
237
-
The QL class `Variable <https://help.semmle.com/qldoc/csharp/semmle/code/cil/Variable.qll/type.Variable$Variable.html>`__ represents C# variables, such as fields, parameters and local variables. The database contains all variables from the source code, as well as all fields and parameters from assemblies referenced by the program.
235
+
The class `Variable <https://help.semmle.com/qldoc/csharp/semmle/code/cil/Variable.qll/type.Variable$Variable.html>`__ represents C# variables, such as fields, parameters and local variables. The database contains all variables from the source code, as well as all fields and parameters from assemblies referenced by the program.
238
236
239
237
Class hierarchy
240
238
~~~~~~~~~~~~~~~
@@ -283,7 +281,7 @@ Find all unused local variables:
283
281
Types
284
282
-----
285
283
286
-
Types are represented by the QL class `Type <https://help.semmle.com/qldoc/csharp/semmle/code/cil/Type.qll/type.Type$Type.html>`__ and consist of builtin types, interfaces, classes, structs, enums, and type parameters. The database contains types from the program and all referenced assemblies including mscorlib and the .NET framework.
284
+
Types are represented by the CodeQL class `Type <https://help.semmle.com/qldoc/csharp/semmle/code/cil/Type.qll/type.Type$Type.html>`__ and consist of builtin types, interfaces, classes, structs, enums, and type parameters. The database contains types from the program and all referenced assemblies including mscorlib and the .NET framework.
287
285
288
286
The builtin types (``object``, ``int``, ``double`` etc.) have corresponding types (``System.Object``, ``System.Int32`` etc.) in mscorlib.
289
287
@@ -438,7 +436,7 @@ Exercise 5: Write a query to find all classes starting with the letter ``A``. (`
438
436
Callables
439
437
---------
440
438
441
-
Callables are represented by the QL class `Callable <https://help.semmle.com/qldoc/csharp/semmle/code/csharp/Callable.qll/type.Callable$Callable.html>`__ and are anything that can be called independently, such as methods, constructors, destructors, operators, anonymous functions, indexers, and property accessors.
439
+
Callables are represented by the class `Callable <https://help.semmle.com/qldoc/csharp/semmle/code/csharp/Callable.qll/type.Callable$Callable.html>`__ and are anything that can be called independently, such as methods, constructors, destructors, operators, anonymous functions, indexers, and property accessors.
442
440
443
441
The database contains all of the callables in your program and in all referenced assemblies.
444
442
@@ -564,7 +562,7 @@ Find ``Main`` methods which are not ``private``:
564
562
Statements
565
563
----------
566
564
567
-
Statements are represented by the QL class `Stmt <https://help.semmle.com/qldoc/csharp/semmle/code/csharp/Stmt.qll/type.Stmt$Stmt.html>`__ and make up the body of methods (and other callables). The database contains all statements in the source code, but does not contain any statements from referenced assemblies where the source code is not available.
565
+
Statements are represented by the class `Stmt <https://help.semmle.com/qldoc/csharp/semmle/code/csharp/Stmt.qll/type.Stmt$Stmt.html>`__ and make up the body of methods (and other callables). The database contains all statements in the source code, but does not contain any statements from referenced assemblies where the source code is not available.
568
566
569
567
Class hierarchy
570
568
~~~~~~~~~~~~~~~
@@ -922,7 +920,7 @@ Exercise 9: Limit the previous query to string types. Exclude empty passwords or
922
920
Attributes
923
921
----------
924
922
925
-
C# attributes are represented by the QL class `Attribute <https://help.semmle.com/qldoc/csharp/semmle/code/cil/Attribute.qll/type.Attribute$Attribute.html>`__. They can be present on many C# elements, such as classes, methods, fields, and parameters. The database contains attributes from the source code and all assembly references.
923
+
C# attributes are represented by the class `Attribute <https://help.semmle.com/qldoc/csharp/semmle/code/cil/Attribute.qll/type.Attribute$Attribute.html>`__. They can be present on many C# elements, such as classes, methods, fields, and parameters. The database contains attributes from the source code and all assembly references.
926
924
927
925
The attribute of any ``Element`` can be obtained via ``getAnAttribute()``, whereas if you have an attribute, you can find its element via ``getTarget()``. The following two query fragments are identical:
928
926
@@ -1122,6 +1120,6 @@ Here is the fixed version:
1122
1120
What next?
1123
1121
----------
1124
1122
1125
-
- Visit :doc:`Tutorial: Analyzing data flow in C# <dataflow>` to learn more about writing queries using the standard QL for C# data flow and taint tracking libraries.
1123
+
- Visit :doc:`Tutorial: Analyzing data flow in C# <dataflow>` to learn more about writing queries using the standard data flow and taint tracking libraries.
1126
1124
- Find out more about QL in the `QL language handbook <https://help.semmle.com/QL/ql-handbook/index.html>`__ and `QL language specification <https://help.semmle.com/QL/ql-spec/language.html>`__.
1127
1125
- Learn more about the query console in `Using the query console <https://lgtm.com/help/lgtm/using-query-console>`__.
Copy file name to clipboardExpand all lines: docs/language/learn-ql/csharp/ql-for-csharp.rst
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
-
QL for C#
2
-
=========
1
+
CodeQL for C#
2
+
=============
3
3
4
4
.. toctree::
5
5
:glob:
@@ -8,17 +8,17 @@ QL for C#
8
8
introduce-libraries-csharp
9
9
dataflow
10
10
11
-
These topics provide an overview of the QL C# libraries and show examples of how to use them.
11
+
These topics provide an overview of the CodeQL libraries for C# and show examples of how to use them.
12
12
13
-
- `Basic C# QL query <https://lgtm.com/help/lgtm/console/ql-csharp-basic-example>`__ describes how to write and run queries using LGTM.
13
+
- `Basic C# query <https://lgtm.com/help/lgtm/console/ql-csharp-basic-example>`__ describes how to write and run queries using LGTM.
14
14
15
-
- :doc:`Introducing the C# libraries <introduce-libraries-csharp>` introduces the standard libraries used to write queries for C# code.
15
+
- :doc:`Introducing the CodeQL libraries for C#<introduce-libraries-csharp>` introduces the standard libraries used to write queries for C# code.
16
16
17
17
.. raw:: html
18
18
19
19
<!-- Working with generic types and methods(generics) - how to query generic types and methods. -->
20
20
21
-
- :doc:`Tutorial: Analyzing data flow in C# <dataflow>` demonstrates how to write queries using the standard QL for C# data flow and taint tracking libraries.
21
+
- :doc:`Tutorial: Analyzing data flow in C# <dataflow>` demonstrates how to write queries using the standard data flow and taint tracking libraries for C#.
22
22
23
23
.. raw:: html
24
24
@@ -35,6 +35,6 @@ These topics provide an overview of the QL C# libraries and show examples of how
35
35
Other resources
36
36
---------------
37
37
38
-
- For examples of how to query common C# elements, see the `C# QL cookbook <https://help.semmle.com/wiki/display/CBCSHARP>`__.
39
-
- For the queries used in LGTM, display a `C# query <https://lgtm.com/search?q=language%3Acsharp&t=rules>`__ and click **Open in query console** to see the QL code used to find alerts.
40
-
- For more information about the C/C++ QL library see the `QL library for C# <https://help.semmle.com/qldoc/csharp>`__.
38
+
- For examples of how to query common C# elements, see the `C# cookbook <https://help.semmle.com/wiki/display/CBCSHARP>`__.
39
+
- For the queries used in LGTM, display a `C# query <https://lgtm.com/search?q=language%3Acsharp&t=rules>`__ and click **Open in query console** to see the code used to find alerts.
40
+
- For more information about the library for C# see the `CodeQL library for C# <https://help.semmle.com/qldoc/csharp>`__.
0 commit comments