Skip to content

Commit 8055e91

Browse files
author
james
committed
docs: update titles and intros (writing codeql queries)
1 parent 8b8104a commit 8055e91

8 files changed

Lines changed: 45 additions & 22 deletions

File tree

docs/language/learn-ql/intro-to-data-flow.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
Introduction to data flow analysis with CodeQL
2-
##############################################
1+
About data flow analysis
2+
########################
3+
4+
Data flow analysis is used to compute the possible values that a variable can hold at various points in a program, determining how those values propagate through the program and where they are used.
35

46
Overview
57
********
68

7-
Data flow analysis computes the possible values that a variable can hold at various points in a program, determining how those values propagate through the program and where they are used.
89
Many CodeQL security queries implement data flow analysis, which can highlight the fate of potentially malicious or insecure data that can cause vulnerabilities in your code base.
910
These queries help you understand if data is used in an insecure way, whether dangerous arguments are passed to functions, or whether sensitive data can leak.
1011
As well as highlighting potential security issues, you can also use data flow analysis to understand other aspects of how a program behaves, by finding, for example, uses of uninitialized variables and resource leaks.

docs/language/learn-ql/locations.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Locations and strings for QL entities
33

44
.. Not sure how much of this topic needs to change, and what the title should be
55
6+
CodeQL includes mechanisms for extracting the location of elements in a codebase. Use these mechanisms when writing custom CodeQL queries and libraries to help display information to users.
7+
8+
69
Providing locations
710
-------------------
811

docs/language/learn-ql/writing-queries/debugging-queries.rst

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
Query writing: common performance issues
2-
========================================
1+
Troubleshooting query performance
2+
=================================
3+
4+
Improve the performance of your CodeQL queries by following a few simple guidelines.
5+
6+
About query performance
7+
-----------------------
38

49
This topic offers some simple tips on how to avoid common problems that can affect the performance of your queries.
510
Before reading the tips below, it is worth reiterating a few important points about CodeQL and the QL language:
@@ -19,9 +24,7 @@ Eliminate cartesian products
1924
The performance of a predicate can often be judged by considering roughly how many results it has.
2025
One way of creating badly performing predicates is by using two variables without relating them in any way, or only relating them using a negation.
2126
This leads to computing the `Cartesian product <https://en.wikipedia.org/wiki/Cartesian_product>`__ between the sets of possible values for each variable, potentially generating a huge table of results.
22-
2327
This can occur if you don't specify restrictions on your variables.
24-
2528
For instance, consider the following predicate that checks whether a Java method ``m`` may access a field ``f``::
2629

2730
predicate mayAccess(Method m, Field f) {

docs/language/learn-ql/writing-queries/introduction-to-queries.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
Introduction to query files
2-
###########################
1+
About CodeQL queries
2+
####################
3+
4+
CodeQL queries are used to analyze code for issues related to security, correctness, maintainability, and readability.
35

46
Overview
57
********
68

7-
Queries are programs written with CodeQL. They are designed to highlight issues related to the security, correctness, maintainability, and readability of a code base. You can also write custom queries to find specific issues relevant to your own project. Three important types of query are:
9+
CodeQL includes queries to find the relevant and interesting problems for a each supported language. You can also write custom queries to find specific issues relevant to your own project.
10+
11+
The important types of query are:
812

913
- **Alert queries**: queries that highlight issues in specific locations in your code.
1014
- **Path queries**: queries that describe the flow of information between a source and a sink in your code.
11-
- **Metric queries**: queries that compute statistics for your code.
1215

1316
You can add custom queries to `custom query packs <https://lgtm.com/help/lgtm/about-queries#what-are-query-packs>`__ to analyze your projects in `LGTM <https://lgtm.com>`__, use them to analyze a database with the `CodeQL CLI <https://help.semmle.com/codeql/codeql-cli.html>`__, or you can contribute to the standard CodeQL queries in our `open source repository on GitHub <https://github.com/semmle/ql>`__.
1417

@@ -78,7 +81,7 @@ When writing your own alert queries, you would typically import the standard lib
7881

7982
- C/C++: ``cpp``
8083
- C#: ``csharp``
81-
- COBOL: ``cobol``
84+
- Go: ``go``
8285
- Java: ``java``
8386
- JavaScript/TypeScript: ``javascript``
8487
- Python: ``python``
@@ -87,11 +90,10 @@ There are also libraries containing commonly used predicates, types, and other m
8790

8891
You can explore the contents of all the standard libraries in the `CodeQL library reference documentation <https://help.semmle.com/QL/ql-libraries.html>`__ or in the `GitHub repository <https://github.com/semmle/ql>`__.
8992

90-
9193
Optional CodeQL classes and predicates
9294
--------------------------------------
9395

94-
You can customize your analysis by defining your own predicates and classes in the query. See `Defining a predicate <https://help.semmle.com/QL/ql-handbook/predicates.html#defining-a-predicate>`__ and `Defining a class <https://help.semmle.com/QL/ql-handbook/types.html#defining-a-class>`__ for further details.
96+
You can customize your analysis by defining your own predicates and classes in the query. For further information, see `Defining a predicate <https://help.semmle.com/QL/ql-handbook/predicates.html#defining-a-predicate>`__ and `Defining a class <https://help.semmle.com/QL/ql-handbook/types.html#defining-a-class>`__.
9597

9698
From clause
9799
===========

docs/language/learn-ql/writing-queries/path-queries.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
Constructing path queries
2-
#########################
1+
Creating path queries
2+
#####################
3+
4+
You can create path queries to visualize the flow of information through a codebase.
35

46
Overview
57
========

docs/language/learn-ql/writing-queries/query-help.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
Query help reference
2-
********************
1+
Query help files
2+
****************
3+
4+
Query help files tell users the purpose of a query, and recommend how to solve the potential problem the query finds.
35

46
This topic provides detailed information on the structure of query help files.
57
For more information about how to write useful query help in a style that is consistent with the standard CodeQL queries, see the `Query help style guide <https://github.com/Semmle/ql/blob/master/docs/query-help-style-guide.md>`__ on GitHub.

docs/language/learn-ql/writing-queries/query-metadata.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
Query metadata
2-
==============
1+
Metadata for CodeQL queries
2+
===========================
3+
4+
Metadata is used to tell users important information about CodeQL queries. You must include the correct query metadata in a query to be able to view query results in source code.
5+
6+
About query metadata
7+
--------------------
38

49
Any query that is run as part of an analysis includes a number of properties, known as query metadata. Metadata is included at the top of each query file as the content of a `QLDoc <https://help.semmle.com/QL/ql-spec/qldoc.html>`__ comment.
510
For alerts and path queries, this metadata tells LGTM and the CodeQL `extension for VS Code <https://help.semmle.com/codeql/codeql-for-vscode.html>`__ how to handle the query and display its results correctly.

docs/language/learn-ql/writing-queries/select-statement.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
Defining 'select' statements
2-
============================
1+
Defining the results of a query
2+
===============================
3+
4+
You can control how analysis results are displayed in source code by modifying a query's ``select`` statement.
5+
6+
About query results
7+
-------------------
38

49
The information contained in the results of a query is controlled by the ``select`` statement. Part of the process of developing a useful query is to make the results clear and easy for other users to understand.
510
When you write your own queries in the query console or in the CodeQL `extension for VS Code <https://help.semmle.com/codeql/codeql-for-vscode.html>`__ there are no constraints on what can be selected.

0 commit comments

Comments
 (0)