Skip to content

Commit 98914be

Browse files
committed
Init
0 parents  commit 98914be

File tree

2 files changed

+129
-0
lines changed

2 files changed

+129
-0
lines changed

Dockerfile

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
FROM ubuntu:20.04 AS codeql_base
2+
LABEL maintainer="Github codeql team"
3+
4+
# tzdata install needs to be non-interactive
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
# install/update basics and python
8+
RUN apt-get update && \
9+
apt-get upgrade -y && \
10+
apt-get install -y --no-install-recommends \
11+
software-properties-common \
12+
vim \
13+
curl \
14+
wget \
15+
git \
16+
jq \
17+
build-essential \
18+
unzip \
19+
apt-transport-https \
20+
python3.8 \
21+
python3-venv \
22+
python3-pip \
23+
python3-setuptools \
24+
python3-dev \
25+
gnupg \
26+
g++ \
27+
make \
28+
gcc \
29+
apt-utils \
30+
rsync \
31+
file \
32+
dos2unix \
33+
default-jdk \
34+
gettext && \
35+
apt-get clean && \
36+
ln -s /usr/bin/python3.8 /usr/bin/python && \
37+
ln -s /usr/bin/pip3 /usr/bin/pip
38+
39+
# Install Golang
40+
RUN wget -q -O - https://raw.githubusercontent.com/canha/golang-tools-install-script/master/goinstall.sh | bash
41+
42+
# Install latest codeQL
43+
ENV CODEQL_HOME /opt/codeql-home
44+
45+
# Get CodeQL verion
46+
RUN curl --silent "https://api.github.com/repos/github/codeql-cli-binaries/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' > /tmp/codeql_version
47+
48+
# record the latest version of the codeql-cli
49+
RUN mkdir -p ${CODEQL_HOME} \
50+
${CODEQL_HOME}/codeql-repo \
51+
${CODEQL_HOME}/codeql-go-repo \
52+
/opt/codeql
53+
54+
# get the latest codeql queries and record the HEAD
55+
RUN git clone https://github.com/github/codeql ${CODEQL_HOME}/codeql-repo && \
56+
git --git-dir ${CODEQL_HOME}/codeql-repo/.git log --pretty=reference -1 > /opt/codeql/codeql-repo-last-commit
57+
RUN git clone https://github.com/github/codeql-go ${CODEQL_HOME}/codeql-go-repo && \
58+
git --git-dir ${CODEQL_HOME}/codeql-go-repo/.git log --pretty=reference -1 > /opt/codeql/codeql-go-repo-last-commit
59+
60+
RUN CODEQL_VERSION=$(cat /tmp/codeql_version) && \
61+
wget -q https://github.com/github/codeql-cli-binaries/releases/download/${CODEQL_VERSION}/codeql-linux64.zip -O /tmp/codeql_linux.zip && \
62+
unzip /tmp/codeql_linux.zip -d ${CODEQL_HOME} && \
63+
rm /tmp/codeql_linux.zip
64+
65+
ENV PATH="${CODEQL_HOME}/codeql:${PATH}"
66+
67+
## Pre-compile our queries to save time later
68+
# RUN codeql query compile --threads=0 ${CODEQL_HOME}/codeql-repo/*/ql/src/codeql-suites/*.qls
69+
# RUN codeql query compile --threads=0 ${CODEQL_HOME}/codeql-go-repo/ql/src/codeql-suites/*.qls
70+
71+
ENTRYPOINT /bin/bash
72+
# ENV PYTHONIOENCODING=utf-8
73+
# ENTRYPOINT ["python3", "/usr/local/startup_scripts/startup.py"]

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# CodeQL docker build
2+
3+
Based on [microsoft/codeql-container](https://github.com/microsoft/codeql-container) with java, golang installed and .NET removed.
4+
5+
## Build & Run
6+
7+
```shell
8+
docker build -t j3ssie/codeql-docker:latest .
9+
```
10+
11+
or pull the latest from docker hub
12+
13+
```shell
14+
docker pull j3ssie/codeql-docker:latest
15+
16+
# then run the container
17+
docker run -it j3ssie/codeql-docker:latest
18+
```
19+
20+
21+
## Usage
22+
23+
### Access container with shell
24+
25+
```shell
26+
docker run -it -t j3ssie/codeql-docker:latest /bin/bash
27+
```
28+
29+
### Do analyze
30+
31+
```shell
32+
# Copy your code to container
33+
docker cp <your-source-cde> <docker-ID>:/opt/src
34+
35+
# create DB in this folder /opt/src/db
36+
# This might take a while depend on your code
37+
codeql database create --language=<language> /opt/src/db -s /opt/src
38+
39+
# run analyze
40+
# normally query-suites will will be: <language>-security-and-quality.qls
41+
codeql database analyze --format=sarif-latest --output=/opt/issues.sarif /opt/src/db <query-suites>
42+
43+
# copy the result back to host machine
44+
docker cp <docker-ID>:/opt/issues.sarif .
45+
```
46+
47+
### Other commands
48+
49+
```shell
50+
# List all query suites
51+
codeql resolve queries
52+
53+
# Upgrade DB
54+
codeql database upgrade <database>
55+
56+
```

0 commit comments

Comments
 (0)