Skip to content

Commit bf87ac1

Browse files
committed
- Use codeql bundle from github/codeql-action, instead of codeql cli binaries.
- Fix a mismatch between github-linguist and codeql: typescript
1 parent f7b37ec commit bf87ac1

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
nohup.out
2-
codeql-agent-results
2+
codeql-agent-results
3+
.vscode

Dockerfile

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ RUN apt-get update && \
3232
file \
3333
dos2unix \
3434
default-jdk \
35+
maven \
3536
gettext && \
3637
apt-get clean && \
3738
ln -sf /usr/bin/python3.8 /usr/bin/python && \
@@ -51,28 +52,37 @@ ENV CODEQL_HOME /root/codeql-home
5152
# Get CodeQL verion
5253
RUN curl --silent "https://api.github.com/repos/github/codeql-cli-binaries/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' > /tmp/codeql_version
5354

55+
# Get CodeQL Bundle version
56+
RUN curl --silent "https://api.github.com/repos/github/codeql-action/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' > /tmp/codeql_bundle_version
57+
5458
# record the latest version of the codeql-cli
5559
RUN mkdir -p ${CODEQL_HOME} \
56-
${CODEQL_HOME}/codeql-repo \
57-
${CODEQL_HOME}/codeql-go-repo \
60+
# ${CODEQL_HOME}/codeql-repo \
61+
# ${CODEQL_HOME}/codeql-go-repo \
5862
/opt/codeql
5963

6064
# get the latest codeql queries and record the HEAD
61-
RUN git clone --depth=1 https://github.com/github/codeql ${CODEQL_HOME}/codeql-repo && \
62-
git --git-dir ${CODEQL_HOME}/codeql-repo/.git log --pretty=reference -1 > /opt/codeql/codeql-repo-last-commit
63-
RUN git clone --depth=1 https://github.com/github/codeql-go ${CODEQL_HOME}/codeql-go-repo && \
64-
git --git-dir ${CODEQL_HOME}/codeql-go-repo/.git log --pretty=reference -1 > /opt/codeql/codeql-go-repo-last-commit
65+
# RUN git clone --depth=1 https://github.com/github/codeql ${CODEQL_HOME}/codeql-repo && \
66+
# git --git-dir ${CODEQL_HOME}/codeql-repo/.git log --pretty=reference -1 > /opt/codeql/codeql-repo-last-commit
67+
# RUN git clone --depth=1 https://github.com/github/codeql-go ${CODEQL_HOME}/codeql-go-repo && \
68+
# git --git-dir ${CODEQL_HOME}/codeql-go-repo/.git log --pretty=reference -1 > /opt/codeql/codeql-go-repo-last-commit
69+
70+
# RUN CODEQL_VERSION=$(cat /tmp/codeql_version) && \
71+
# wget -q https://github.com/github/codeql-cli-binaries/releases/download/${CODEQL_VERSION}/codeql-linux64.zip -O /tmp/codeql_linux.zip && \
72+
# unzip /tmp/codeql_linux.zip -d ${CODEQL_HOME} && \
73+
# rm /tmp/codeql_linux.zip
6574

66-
RUN CODEQL_VERSION=$(cat /tmp/codeql_version) && \
67-
wget -q https://github.com/github/codeql-cli-binaries/releases/download/${CODEQL_VERSION}/codeql-linux64.zip -O /tmp/codeql_linux.zip && \
68-
unzip /tmp/codeql_linux.zip -d ${CODEQL_HOME} && \
69-
rm /tmp/codeql_linux.zip
75+
# Downdload and extract CodeQL Bundle
76+
RUN CODEQL_BUNDLE_VERSION=$(cat /tmp/codeql_bundle_version) && \
77+
wget -q https://github.com/github/codeql-action/releases/download/${CODEQL_BUNDLE_VERSION}/codeql-bundle-linux64.tar.gz -O /tmp/codeql_linux.tar.gz && \
78+
tar -xf /tmp/codeql_linux.tar.gz -C ${CODEQL_HOME} && \
79+
rm /tmp/codeql_linux.tar.gz
7080

7181
ENV PATH="$PATH:${CODEQL_HOME}/codeql:/root/go/bin:/root/.go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
7282
COPY scripts /root/scripts
7383

7484
# Pre-compile our queries to save time later
75-
RUN /root/scripts/compile-qs.sh
85+
# RUN /root/scripts/compile-qs.sh
7686

7787
WORKDIR /root/
7888
ENTRYPOINT ["/root/scripts/analyze.sh"]

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Source build docker image `codeql-agent`
66
### Build and run local
77
```
88
cd codeql-agent
9-
docker build -t codeql-agent .
9+
sudo docker build -t doublevkay/codeql-agent-dev:1.1.0 .
10+
nohup sudo docker build -t doublevkay/codeql-agent-dev:1.1.0 .; telegram-send "Build image codeql v1.1.0 done"
1011
docker run --rm --name codeql-docker -v "$PWD/vulnerable-source-code:/opt/src" -e "LANGUAGE=python" -e "FORMAT=sarif-latest" codeql-agent
1112
```
1213

scripts/analyze.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,13 @@ then
2929
fi
3030

3131
LANGUAGE=${LANGUAGE,,}
32-
if [[ "$LANGUAGE" == "python" || "$LANGUAGE" == "javascript" || "$LANGUAGE" == "cpp" || "$LANGUAGE" == "csharp" || "$LANGUAGE" == "java" || "$LANGUAGE" == "go" ]]
32+
if [[ "$LANGUAGE" == "python" || "$LANGUAGE" == "javascript" || "$LANGUAGE" == "cpp" || "$LANGUAGE" == "csharp" || "$LANGUAGE" == "java" || "$LANGUAGE" == "go" || "$LANGUAGE" == "typescript" ]]
3333
then
34-
echo "$LANGUAGE"
34+
if [[ "$LANGUAGE" == "typescript" ]]
35+
then
36+
LANGUAGE="javascript"
37+
fi
38+
echo "$LANGUAGE"
3539
else
3640
echo "[!] Invalid language: $LANGUAGE"
3741
exit 3

0 commit comments

Comments
 (0)