Skip to content

Commit d56dfb0

Browse files
authored
Merge pull request #2 from microsoft/scovetta-readme-fixes
Update README.md
2 parents 98f0051 + d326d65 commit d56dfb0

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

README.md

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16,59 +16,62 @@ We shall continue to add more features and would be happy to accept contribution
1616
### Basic Usage
1717

1818
#### Downloading a pre-built container
19+
1920
We keep updating the docker image periodically and uploading it to the Microsoft Container Registry at: mcr.microsoft.com/codeql/codeql-container.
21+
2022
You can pull the image by running the command:
2123
```
2224
$ docker pull mcr.microsoft.com/codeql/codeql-container
2325
```
2426

2527
If you want to analyze a particular source directory with codeql, run the container as:
28+
2629
```
2730
$ docker run --rm --name codeql-container mcr.microsoft.com/codeql/codeql-container -v /dir/to/analyze:/opt/src -v /dir/for/results:/opt/results -e CODEQL_CLI_ARGS=<query run...>
2831
```
2932

30-
where /dir/to/analyze contains the source files that has to be analyzed, and /dir/for/results is where the result output
31-
needs to be stored.
32-
CODEQL_CLI_ARGS contents will be directly passed on to the codeql-cli. Some examples of CODEQL_CLI_ARGS are:
33+
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.
35+
For more information on CodeQL and QL packs, please visit https://www.github.com/github/codeql.
36+
37+
`CODEQL_CLI_ARGS` are the arguments that will be directly passed on to the codeql-cli. Some examples of `CODEQL_CLI_ARGS` are:
3338

3439
```
35-
CODEQL_CLI_ARGS = database create /opt/src/source_db
40+
CODEQL_CLI_ARGS="database create /opt/src/source_db"
3641
```
3742

38-
> **Note:** If you map your source volume to some other mount point other than /opt/src, you will have to make the corresponding changes
39-
> in the CODEQL_CLI_ARGS.
43+
**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`.
4045

4146
There are some additional docker environment variables that you can specify to control the execution of the container:
42-
* CHECK_LATEST_CODEQL_CLI - If there is a newer version of codeql-cli, download and install it
43-
* CHECK_LATEST_QUERIES - if there is are updates to the codeql queries repo, download and use it
44-
* PRECOMPILE_QUERIES - If we downloaded new queries, precompile all new query packs (query execution will be faster)
45-
> WARNING: Precompiling query packs might take a few hours, depending on speed of your machine and the CPU/Memory limits (if any)
46-
> you have placed on the container.
4747

48-
Since codeql first creates a database of the code representation, and then analyzes the said db for issues, we need to run couple commands to
49-
analyze a source code project.
50-
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),
51-
to analyze and get a sarif result file, you will have to run:
48+
* `CHECK_LATEST_CODEQL_CLI` - If there is a newer version of codeql-cli, download and install it
49+
* `CHECK_LATEST_QUERIES` - if there is are updates to the codeql queries repo, download and use it
50+
* `PRECOMPILE_QUERIES` - If we downloaded new queries, precompile all new query packs (query execution will be faster)
51+
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.
54+
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.
57+
58+
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+
to analyze and get a SARIF result file, you will have to run:
5260

5361
```
54-
$ docker run --rm --name codeql-container codeql-container -v /dir/to/analyze:/opt/src -v /dir/for/results:/opt/results -e CODEQL_CLI_ARGS="database create --language=python /opt/src/source_db"
55-
$ docker run --rm --name codeql-container codeql-container -v /dir/to/analyze:/opt/src -v /dir/for/results:/opt/results -e CODEQL_CLI_ARGS="database upgrade source_db"
56-
$ docker run --rm --name codeql-container codeql-container -v /dir/to/analyze:/opt/src -v /dir/for/results:/opt/results -e CODEQL_CLI_ARGS="database analyze source_db --output=/opt/results/issues.sarif /opt/src/source_db python-security-and-quality.qls"
62+
$ docker run --rm --name codeql-container mcr.microsoft.com/codeql/codeql-container -v /dir/to/analyze:/opt/src -v /dir/for/results:/opt/results -e CODEQL_CLI_ARGS="database create --language=python /opt/src/source_db"
63+
$ docker run --rm --name codeql-container mcr.microsoft.com/codeql/codeql-container -v /dir/to/analyze:/opt/src -v /dir/for/results:/opt/results -e CODEQL_CLI_ARGS="database analyze --format=sarifv2 --output=/opt/results/issues.sarif /opt/src/source_db
5764
```
5865

59-
This will run the python-security-and-quality.qls query pack on the provided source code and output the results to /path/to/results/issues.sarif on the local machine.
60-
> [The second step above is only required if the queries are newer than the one that codeql-cli recognizes.]
61-
62-
This command will run all the ql packs related to security and output the results to the results folder.
63-
6466
For more information on CodeQL and QL packs, please visit https://www.github.com/github/codeql.
6567

6668
#### Building the container
69+
6770
Building the container should be pretty straightforward.
6871

6972
```
70-
git clone ...
71-
cd src
73+
git clone https://github.com/microsoft/codeql-container
74+
cd codeql-container
7275
docker build . -f Dockerfile -t codeql-container
7376
```
7477

0 commit comments

Comments
 (0)