Skip to content

Commit 247b547

Browse files
committed
Update [email protected]:j3ssie/codeql-docker.git
1 parent 98914be commit 247b547

File tree

3 files changed

+67
-11
lines changed

3 files changed

+67
-11
lines changed

Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ RUN apt-get update && \
4040
RUN wget -q -O - https://raw.githubusercontent.com/canha/golang-tools-install-script/master/goinstall.sh | bash
4141

4242
# Install latest codeQL
43-
ENV CODEQL_HOME /opt/codeql-home
43+
ENV CODEQL_HOME /root/codeql-home
4444

4545
# Get CodeQL verion
4646
RUN curl --silent "https://api.github.com/repos/github/codeql-cli-binaries/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' > /tmp/codeql_version
@@ -62,12 +62,12 @@ RUN CODEQL_VERSION=$(cat /tmp/codeql_version) && \
6262
unzip /tmp/codeql_linux.zip -d ${CODEQL_HOME} && \
6363
rm /tmp/codeql_linux.zip
6464

65-
ENV PATH="${CODEQL_HOME}/codeql:${PATH}"
65+
ENV PATH="$PATH:${CODEQL_HOME}/codeql:/root/go/bin:/root/.go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
66+
COPY scripts /root/scripts
6667

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
68+
# Pre-compile our queries to save time later
69+
RUN codeql query compile --threads=0 ${CODEQL_HOME}/codeql-repo/*/ql/src/codeql-suites/*.qls
70+
RUN codeql query compile --threads=0 ${CODEQL_HOME}/codeql-go-repo/ql/src/codeql-suites/*.qls
7071

71-
ENTRYPOINT /bin/bash
72-
# ENV PYTHONIOENCODING=utf-8
73-
# ENTRYPOINT ["python3", "/usr/local/startup_scripts/startup.py"]
72+
WORKDIR /root/
73+
ENTRYPOINT ["/root/scripts/run.sh"]

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,27 @@ docker run -it j3ssie/codeql-docker:latest
2020

2121
## Usage
2222

23-
### Access container with shell
23+
### Access container with bash shell
2424

2525
```shell
26-
docker run -it -t j3ssie/codeql-docker:latest /bin/bash
26+
docker run -it --entrypoint=/bin/bash -t j3ssie/codeql-docker:latest /bin/bash
2727
```
2828

29-
### Do analyze
29+
### Run with helper scripts
30+
31+
With `/tmp/src` is your source code and `/tmp/results` is where result store.
32+
33+
> NOTE: make sure /tmp/results folder is exist otherwise no result will be created
34+
35+
```shell
36+
# simple usage
37+
docker run --rm --name codeql-docker -v "/tmp/src:/opt/src" -v "/tmp/results:/opt/results" -e "LANGUAGE=go" j3ssie/codeql-docker:latest
38+
39+
# more options
40+
docker run --rm --name codeql-docker -v "/tmp/src:/opt/src" -v "/tmp/results:/opt/results" -e "LANGUAGE=go" -e "FORMAT=csv" -e "QS=golang-security-and-quality.qls" j3ssie/codeql-docker:latest
41+
```
42+
43+
### Manual analyze
3044

3145
```shell
3246
# Copy your code to container

scripts/analyze.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
RED="\033[31m"
4+
YELLOW="\033[33m"
5+
GREEN="\033[32m"
6+
RESET="\033[0m"
7+
8+
print_green() {
9+
echo -e "${GREEN}${1}${RESET}"
10+
}
11+
12+
SRC=/opt/src
13+
if [ -z $FORMAT ]
14+
then
15+
FORMAT="sarif-latest"
16+
fi
17+
18+
if [ -z $QS ]
19+
then
20+
QS="$LANGUAGE-security-and-quality.qls"
21+
fi
22+
23+
if [ -z $OUTPUT ]
24+
then
25+
OUTPUT="/opt/results"
26+
fi
27+
DB=$OUTPUT/db
28+
29+
echo "----------------"
30+
print_green " Language: $LANGUAGE"
31+
print_green " Query-suites: $QS"
32+
print_green " Database: $DB"
33+
print_green " Source: $SRC"
34+
print_green " Output: $OUTPUT"
35+
print_green " Format: $FORMAT"
36+
echo "----------------"
37+
38+
echo -e "Creating DB: codeql database create --language=$LANGUAGE $DB -s $SRC"
39+
codeql database create --language=$LANGUAGE $DB -s $SRC
40+
41+
echo -e "Start Scanning: codeql database analyze --format=$FORMAT --output=$OUTPUT/issues.$FORMAT $DB $QS"
42+
codeql database analyze --format=$FORMAT --output=$OUTPUT/issues.$FORMAT $DB $QS

0 commit comments

Comments
 (0)