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: README.md
+54-21Lines changed: 54 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,41 @@
1
1
## CodeQL Container
2
2
3
3
> **Note:** CodeQL container is currently in **public preview**. Please report any bugs to https://github.com/microsoft/codeql-container/issues.
4
-
> Current version of CodeQL only works for interpreted languages. We will add compiled languages support on future versions.
4
+
> Current version of CodeQL only works for interpreted languages. We will add compiled languages support in future versions.
5
5
6
-
CodeQL Container is a project aimed at making it easier to start using CodeQL (https://github.com/github/codeql). This project
7
-
contains a Docker file which builds a container, with the latest version of codeql-cli and codeql queries precompiled.
8
-
It also contains scripts to keep the toolchain in the container updated. You can use this container to:
6
+
The CodeQL Container is a project aimed at making it easier to start using CodeQL (more about codeQL at https://github.com/github/codeql). This project
7
+
contains a Docker file which builds a container with the latest version of codeql-cli, and the latest codeql queries precompiled.
8
+
It also contains automation to keep the toolchain in the container updated. You can use this container to:
9
9
10
10
* Start using codeql-cli and run queries on your projects without installing it on your local machine.
11
-
* Use is as an environment to develop codeql queries and test them.
12
-
* Test how the queries perform in windows and linux environments.
11
+
* Use it as an environment to develop codeql queries and test them.
12
+
* Test how the queries perform in windows and linux environments (and more...)
13
13
14
14
We shall continue to add more features and would be happy to accept contributions from the community.
15
15
16
+
### TL;DR
17
+
18
+
Analyze a python project django located in the folder ```/tmp/django``` by running the security and quality QL pack on it:
The codeQL container executes one codeQL command per invocation. We kept this design decision because it makes it easy for the user to run any codeQL command, and not be bound by the automation scripts inside the container.
26
50
27
-
If you want to analyze a particular source directory with codeql, run the container as:
51
+
So, if you want to analyze a particular source directory with the container, you start by running the container as:
where `/dir/to/analyze` contains the source files that have to be analyzed, and `/dir/for/results` is where the result output
34
-
needs to be stored, and you can specify QL_PACKS environment variable for specific QL packs to be run on the provided code.
58
+
needs to be stored, and you can specify CODEQL_CLI_ARGS environment variable for specific QL packs to be run on the provided code, among other things. The CODEQL_CLI_ARGS will be passed over to codeQL command line as it is.
59
+
35
60
For more information on CodeQL and QL packs, please visit https://www.github.com/github/codeql.
36
61
37
-
`CODEQL_CLI_ARGS` are the arguments that will be directly passed on to the codeql-cli. Some examples of `CODEQL_CLI_ARGS` are:
62
+
`CODEQL_CLI_ARGS` are the arguments that will be directly passed on to the codeql-cli. For example:
**Note:** If you map your source volume to some other mountpoint other than /opt/src, you will have to make the corresponding changes
44
-
in the `CODEQL_CLI_ARGS`.
68
+
This argument will create a codeQL db of your project (that you have mapped to the /opt/src folder above) in the /opt/results folder, which maps to /dir/for/results above on your local computer.
69
+
70
+
> **Note:** If you map your source volume to some other mountpoint other than /opt/src, you will have to make the corresponding changes
71
+
> in the `CODEQL_CLI_ARGS`.
45
72
46
-
There are some additional docker environment variables that you can specify to control the execution of the container:
73
+
There are some additional docker environment flags that you can set/unset to control the execution of the container:
47
74
48
75
*`CHECK_LATEST_CODEQL_CLI` - If there is a newer version of codeql-cli, download and install it
49
76
*`CHECK_LATEST_QUERIES` - if there is are updates to the codeql queries repo, download and use it
50
77
*`PRECOMPILE_QUERIES` - If we downloaded new queries, precompile all new query packs (query execution will be faster)
51
78
52
-
**WARNING:** Precompiling query packs might take a few hours, depending on speed of your machine and the CPU/memory limits (if any)
53
-
you have placed on the container.
79
+
> **WARNING:** Precompiling query packs might take a few hours, depending on speed of your machine and the CPU/memory limits (if any)
80
+
> you have placed on the container.
54
81
55
-
Since CodeQL first creates a database of the code representation, and then analyzes the db for issues, we need a few commands to
56
-
analyze a source code repo.
82
+
Since CodeQL first creates a database of the code representation, and then analyzes the said database for issues, we need to invoke the container more than once to analyze a source code repo. (Since the container only executes one codeQL command per invocation.)
57
83
58
84
For example, if you want to analyze a python project source code placed in `/dir/to/analyze` (or `C:\dir\to\analyze` for example, in Windows),
59
85
to analyze and get a SARIF result file, you will have to run:
For more information on CodeQL and QL packs, please visit https://www.github.com/github/codeql.
@@ -101,8 +127,15 @@ for JavaScript:
101
127
102
128
##### run_qlpack.sh
103
129
If you know which QL suite you would like to run on the code to be analyzed, use scripts/unix/run_qlpack.sh (or scripts/windows/run_qlpack.bat for windows).
130
+
131
+
```
132
+
scripts/unix/run_qlpack.sh /path/to/analyze /path/to/results language qlpack
133
+
```
134
+
135
+
For example, on windows:
136
+
104
137
```
105
-
scripts/unix/analyze_security.sh /path/to/analyze /path/to/results language qlpack
0 commit comments