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-language-guides/codeql-for-cpp.rst
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,10 @@ Experiment and learn how to write effective and efficient queries for CodeQL dat
28
28
29
29
- :doc:`CodeQL library for C and C++ <codeql-library-for-cpp>`: When analyzing C or C++ code, you can use the large collection of classes in the CodeQL library for C and C++.
30
30
31
+
- `CodeQL CTF: U-Boot Challenge <https://securitylab.github.com/ctf/uboot/>`__: Follow the steps that members of GitHub Security Lab went through to find 13 CWE vulnerabilities in U-Boot.
32
+
33
+
- `CodeQL CTF: SEGV Hunt <https://securitylab.github.com/ctf/segv/>`__: Follow the steps that members of GitHub Security Lab went through to find unsafe uses of ``alloca`` in the GNU C Library (glibc).
34
+
31
35
- :doc:`Functions in C and C++ <functions-in-cpp>`: You can use CodeQL to explore functions in C and C++ code.
32
36
33
37
- :doc:`Expressions, types, and statements in C and C++ <expressions-types-and-statements-in-cpp>`: You can use CodeQL to explore expressions, types, and statements in C and C++ code to find, for example, incorrect assignments.
Copy file name to clipboardExpand all lines: docs/codeql/codeql-language-guides/codeql-for-go.rst
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,9 @@ Experiment and learn how to write effective and efficient queries for CodeQL dat
17
17
18
18
- :doc:`CodeQL library for Go <codeql-library-for-go>`: When you're analyzing a Go program, you can make use of the large collection of classes in the CodeQL library for Go.
19
19
20
+
- `CodeQL CTF: Go and don't return <https://securitylab.github.com/ctf/go-and-dont-return/>`__: Follow the steps that members of GitHub Security Lab went through to find a high severity vulnerability in MinIO, an Amazon S3-compatible object store.
21
+
20
22
- :doc:`Abstract syntax tree classes for working with Go programs <abstract-syntax-tree-classes-for-working-with-go-programs>`: CodeQL has a large selection of classes for representing the abstract syntax tree of Go programs.
21
23
22
-
- :doc:`Modeling data flow in Go libraries <modeling-data-flow-in-go-libraries>`: When analyzing a Go program, CodeQL does not examine the source code for external packages.
24
+
- :doc:`Modeling data flow in Go libraries <modeling-data-flow-in-go-libraries>`: When analyzing a Go program, CodeQL does not examine the source code for external packages.
23
25
To track the flow of untrusted data through a library, you can create a model of the library.
Copy file name to clipboardExpand all lines: docs/codeql/codeql-language-guides/codeql-for-java.rst
+3-1Lines changed: 3 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,9 @@ Experiment and learn how to write effective and efficient queries for CodeQL dat
28
28
29
29
- :doc:`CodeQL library for Java and Kotlin <codeql-library-for-java>`: When analyzing Java/Kotlin code, you can use the large collection of classes in the CodeQL library for Java/Kotlin.
30
30
31
-
- :doc:`Analyzing data flow in Java and Kotlin <analyzing-data-flow-in-java>`: You can use CodeQL to track the flow of data through a Java/Kotlin program to its use.
31
+
- :doc:`Analyzing data flow in Java and Kotlin <analyzing-data-flow-in-java>`: You can use CodeQL to track the flow of data through a Java/Kotlin program to its use.
32
+
33
+
- `CodeQL CTF: CodeQL and Chill <https://securitylab.github.com/ctf/codeql-and-chill/>`__: Follow the steps that members of GitHub Security Lab went through to track the flow of tainted data from user-controlled bean properties to custom error messages, and identify the known injection vulnerabilities.
32
34
33
35
- :doc:`Java and Kotlin types <types-in-java>`: You can use CodeQL to find out information about data types used in Java/Kotlin code. This allows you to write queries to identify specific type-related issues.
Copy file name to clipboardExpand all lines: docs/codeql/codeql-language-guides/codeql-for-javascript.rst
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,8 @@ Experiment and learn how to write effective and efficient queries for CodeQL dat
25
25
26
26
- :doc:`CodeQL library for TypeScript <codeql-library-for-typescript>`: When you're analyzing a TypeScript program, you can make use of the large collection of classes in the CodeQL library for TypeScript.
27
27
28
+
- `CodeQL CTF: XSS-unsafe jQuery plugins <https://securitylab.github.com/ctf/jquery/>`__: Follow the steps that members of GitHub Security Lab went through to find cross-site scripting vulnerabilities in Bootstrap's jQuery plugins.
29
+
28
30
- :doc:`Analyzing data flow in JavaScript and TypeScript <analyzing-data-flow-in-javascript-and-typescript>`: This topic describes how data flow analysis is implemented in the CodeQL libraries for JavaScript/TypeScript and includes examples to help you write your own data flow queries.
29
31
30
32
- :doc:`Using flow labels for precise data flow analysis <using-flow-labels-for-precise-data-flow-analysis>`: You can associate flow labels with each value tracked by the flow analysis to determine whether the flow contains potential vulnerabilities.
CodeQL is the analysis engine used by developers to automate security checks, and by
9
-
security researchers to perform variant analysis.
12
+
CodeQL is a language and toolchain for code analysis. It is designed to allow security researchers to scale their knowledge of a single vulnerability to identify variants of that vulnerability across a wide range of codebases. It is also designed to allow developers to automate security checks and integrate them into their development workflows.
13
+
14
+
Resources for learning CodeQL
15
+
-----------------------------
16
+
17
+
- **CodeQL docs site:** contains information on the CodeQL language and libraries, with tutorials and guides to help you learn how to write your own queries.
18
+
19
+
- :doc:`CodeQL queries <../writing-codeql-queries/codeql-queries>`: A general, language-neutral overview of the key components of a query.
20
+
21
+
- :doc:`QL tutorials <../writing-codeql-queries/ql-tutorials>`: Solve puzzles to learn the basics of QL before you analyze code with CodeQL. The tutorials teach you how to write queries and introduce you to key logic concepts along the way.
22
+
23
+
- :doc:`CodeQL language guides <../codeql-language-guides/index>`: Guides to the CodeQL libraries for each language, including the classes and predicates that are available for use in queries, with worked examples.
10
24
11
-
In CodeQL, code is treated like data. Security vulnerabilities, bugs,
12
-
and other errors are modeled as queries that can be executed against databases
13
-
extracted from code. You can run the standard CodeQL queries, written by GitHub
14
-
researchers and community contributors, or write your own to use in custom
15
-
analyses. Queries that find potential bugs highlight the result directly in the
16
-
source file.
25
+
- **GitHub Security Lab:** is GitHub's own security research team. They've created a range of resources to help you learn how to use CodeQL to find security vulnerabilities in real-world codebases.
26
+
27
+
- `Secure code game <https://github.com/skills/secure-code-game>`__: A series of interactive sessions that guide you from finding insecure code patterns manually, through to using CodeQL to find insecure code patterns automatically.
28
+
29
+
- `Security Lab CTF <https://securitylab.github.com/ctf/>`__: A series of Capture the Flag (CTF) challenges that are designed to help you learn how to use CodeQL to find security vulnerabilities in real-world codebases.
30
+
31
+
- `Security Lab blog <https://github.blog/tag/github-security-lab/>`__: A series of blog posts that describe how CodeQL is used by security researchers to find security vulnerabilities in real-world codebases.
17
32
18
33
About variant analysis
19
34
----------------------
@@ -30,6 +45,8 @@ queries. Then, develop or iterate over the query to automatically find logical
30
45
variants of the same bug that could be missed using traditional manual
31
46
techniques.
32
47
48
+
When you have a query that finds variants of a vulnerability, you can use multi-repository variant analysis to run that query across a large number of codebases, and identify all of the places where that vulnerability exists. For more information, see `Running CodeQL queries at scale with multi-repository variant analysis <https://docs.github.com/en/code-security/codeql-for-vs-code/getting-started-with-codeql-for-vs-code/running-codeql-queries-at-scale-with-multi-repository-variant-analysis>`__ in the GitHub docs.
49
+
33
50
CodeQL analysis
34
51
---------------
35
52
@@ -39,11 +56,13 @@ CodeQL analysis consists of three steps:
39
56
#. Running CodeQL queries against the database
40
57
#. Interpreting the query results
41
58
59
+
For information on the CodeQL toolchain and on running CodeQL to analyze a codebase, see the `CodeQL CLI <https://docs.github.com/en/code-security/codeql-cli>`__, `CodeQL for Visual Studio Code <https://docs.github.com/en/code-security/codeql-for-vs-code>`__, and `About code scanning with CodeQL <https://docs.github.com/en/code-security/code-scanning/introduction-to-code-scanning/about-code-scanning-with-codeql>`__ in the GitHub docs.
60
+
42
61
Database creation
43
62
~~~~~~~~~~~~~~~~~
44
63
45
64
To create a database, CodeQL first extracts a single relational representation
46
-
of each source file in the codebase.
65
+
of each source file in the codebase.
47
66
48
67
For compiled languages, extraction works by monitoring the normal build process.
49
68
Each time a compiler is invoked to process a source file, a copy of that file is
@@ -52,7 +71,7 @@ syntactic data about the abstract syntax tree and semantic data about name
52
71
binding and type information.
53
72
54
73
For interpreted languages, the extractor runs directly on the source code,
55
-
resolving dependencies to give an accurate representation of the codebase.
74
+
resolving dependencies to give an accurate representation of the codebase.
56
75
57
76
There is one :ref:`extractor <extractor>` for each language supported by CodeQL
58
77
to ensure that the extraction process is as accurate as possible. For
@@ -72,7 +91,7 @@ against it. CodeQL queries are written in a specially-designed object-oriented
72
91
query language called QL. You can run the queries checked out from the CodeQL
73
92
repo (or custom queries that you've written yourself) using the `CodeQL
74
93
for VS Code extension <https://docs.github.com/en/code-security/codeql-for-vs-code/>`__ or the `CodeQL CLI
75
-
<https://docs.github.com/en/code-security/codeql-cli>`__. For more information about queries, see ":ref:`About CodeQL queries <about-codeql-queries>`."
94
+
<https://docs.github.com/en/code-security/codeql-cli>`__. For more information about queries, see ":ref:`About CodeQL queries <about-codeql-queries>`."
76
95
77
96
.. _interpret-query-results:
78
97
@@ -95,7 +114,7 @@ code.
95
114
Following interpretation, results are output for code review and triaging. In
96
115
CodeQL for Visual Studio Code, interpreted query results are automatically
97
116
displayed in the source code. Results generated by the CodeQL CLI can be output
98
-
into a number of different formats for use with different tools.
117
+
into a number of different formats for use with different tools.
99
118
100
119
101
120
About CodeQL databases
@@ -104,7 +123,7 @@ About CodeQL databases
104
123
CodeQL databases contain queryable data extracted from a codebase, for a single
105
124
language at a particular point in time. The database contains a full,
106
125
hierarchical representation of the code, including a representation of the
107
-
abstract syntax tree, the data flow graph, and the control flow graph.
126
+
abstract syntax tree, the data flow graph, and the control flow graph.
108
127
109
128
Each language has its own unique database schema that defines the relations used
110
129
to create a database. The schema provides an interface between the initial
@@ -114,13 +133,13 @@ every language construct.
114
133
115
134
For each language, the CodeQL libraries define classes to provide a layer of
116
135
abstraction over the database tables. This provides an object-oriented view of
117
-
the data which makes it easier to write queries.
136
+
the data which makes it easier to write queries.
118
137
119
138
For example, in a CodeQL database for a Java program, two key tables are:
120
139
121
140
- The ``expressions`` table containing a row for every single expression in the
122
-
source code that was analyzed during the build process.
123
-
- The ``statements`` table containing a row for every single statement in the
141
+
source code that was analyzed during the build process.
142
+
- The ``statements`` table containing a row for every single statement in the
124
143
source code that was analyzed during the build process.
125
144
126
145
The CodeQL library defines classes to provide a layer of abstraction over each
0 commit comments