Skip to content

Commit 838e445

Browse files
committed
SonarQube
1 parent 2de5f9a commit 838e445

File tree

6 files changed

+98
-1
lines changed

6 files changed

+98
-1
lines changed

CxSonarQube/Dockerfile

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
FROM openjdk:8-alpine
2+
3+
LABEL description="SonarQube integrated with Checkmarx SAST"
4+
LABEL maintainer="Alex Ivkin"
5+
LABEL version="1.1 alpha"
6+
7+
ENV CX_PLUGIN_URL=https://download.checkmarx.com/8.7.0/Plugins/Sonar-8.70.1.zip
8+
9+
ENV SONAR_VERSION=7.1 \
10+
SONARQUBE_HOME=/opt/sonarqube \
11+
# Database configuration
12+
# Defaults to using H2
13+
SONARQUBE_JDBC_USERNAME=sonar \
14+
SONARQUBE_JDBC_PASSWORD=sonar \
15+
SONARQUBE_JDBC_URL= \
16+
GPG_KEYS=F1182E81C792928921DBCAB4CFCA4A29D26468DE
17+
18+
RUN set -x \
19+
&& apk add --no-cache gnupg unzip libressl wget su-exec bash curl \
20+
&& ( gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEYS" \
21+
|| gpg --keyserver pgp.mit.edu --recv-keys "$GPG_KEYS" \
22+
|| gpg --keyserver keyserver.pgp.com --recv-keys "$GPG_KEYS" ) \
23+
&& mkdir /opt \
24+
&& cd /opt \
25+
&& wget -O sonarqube.zip --no-verbose https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-$SONAR_VERSION.zip \
26+
&& wget -O sonarqube.zip.asc --no-verbose https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-$SONAR_VERSION.zip.asc \
27+
&& gpg --batch --verify sonarqube.zip.asc sonarqube.zip \
28+
&& unzip sonarqube.zip \
29+
&& mv sonarqube-$SONAR_VERSION sonarqube \
30+
&& addgroup -S sonarqube \
31+
&& adduser -S -G sonarqube sonarqube \
32+
&& chown -R sonarqube:sonarqube sonarqube \
33+
&& rm sonarqube.zip* \
34+
&& rm -rf $SONARQUBE_HOME/bin/*
35+
36+
RUN set -eux \
37+
&& cd /opt/ \
38+
&& curl -L $CX_PLUGIN_URL --output cxplugin.zip \
39+
&& unzip -q cxplugin.zip -d $SONARQUBE_HOME/extensions/plugins/ \
40+
&& rm cxplugin.zip
41+
42+
COPY run-sonarqube.sh $SONARQUBE_HOME/bin/
43+
RUN chmod +x $SONARQUBE_HOME/bin/run-sonarqube.sh
44+
45+
EXPOSE 9000
46+
VOLUME "$SONARQUBE_HOME/data"
47+
48+
WORKDIR $SONARQUBE_HOME
49+
ENTRYPOINT ["./bin/run-sonarqube.sh"]

CxSonarQube/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# SonarQube docker container for Checkmarx integration
2+
3+
SonarQube server with the Checkmarx plugin. Based on the official docker image from [here](https://github.com/docker-library/docs/tree/master/sonarqube).
4+
By default, the image will use an embedded H2 database that is not suited for production. To configure an external DB check the [official reference](https://github.com/docker-library/docs/tree/master/sonarqube).
5+
6+
No special options are required to build the image: `docker build -t cxai/cxsonarqube .`
7+
8+
## Running
9+
10+
`docker run --name sonarqube -d --rm -p 9000:9000 -p 9092:9092 -v sonarqube:/opt/sonarqube/data cxai/cxsonarqube`
11+
12+
## Setup
13+
14+
1. Login as admin/admin
15+
2. Create a project. Click on the project, go to Administration -> Checkmarx and configure server URL/credentials. Pick the Cx project.
16+
3. Get the [sonar scanner](https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner) for your platform
17+
4. Create a scan token
18+
5. Run the sonarqube scan
19+
`sonar-scanner -Dsonar.projectKey=projectKey -Dsonar.sources=. -Dsonar.host.url=http://localhost:9000 -Dsonar.login=yourScanToken`
20+
21+
## References
22+
* [Setting up the Checkmarx SonarQube Plugin](https://checkmarx.atlassian.net/wiki/spaces/KC/pages/234815626/Setting+up+the+Checkmarx+SonarQube+Plugin)

CxSonarQube/build

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
docker build -t cxai/cxsonarqube .

CxSonarQube/run

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
docker run --name sonarqube -d --rm -p 9000:9000 -p 9092:9092 -v sonarqube:/opt/sonarqube/data cxai/cxsonarqube
4+
5+
sleep 2
6+
firefox http://localhost:9000

CxSonarQube/run-sonarqube.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
if [ "${1:0:1}" != '-' ]; then
6+
exec "$@"
7+
fi
8+
9+
chown -R sonarqube:sonarqube $SONARQUBE_HOME
10+
exec su-exec sonarqube \
11+
java -jar lib/sonar-application-$SONAR_VERSION.jar \
12+
-Dsonar.log.console=true \
13+
-Dsonar.jdbc.username="$SONARQUBE_JDBC_USERNAME" \
14+
-Dsonar.jdbc.password="$SONARQUBE_JDBC_PASSWORD" \
15+
-Dsonar.jdbc.url="$SONARQUBE_JDBC_URL" \
16+
-Dsonar.web.javaAdditionalOpts="$SONARQUBE_WEB_JVM_OPTS -Djava.security.egd=file:/dev/./urandom" \
17+
"$@"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ Containers marked as GUI require X11 server on the host. See individual README f
1414
* Checkmarx CLI: [dockerfile](https://github.com/cxai/Docker-CxIntegrations/tree/master/CxCLI), [image](https://hub.docker.com/r/cxai/cxcli/)
1515
* Eclipse (GUI): [dockerfile](https://github.com/cxai/Docker-CxIntegrations/tree/master/CxEclipse), [image](https://hub.docker.com/r/cxai/cxeclipse/)
1616
* TeamCity [dockerfile](https://github.com/cxai/Docker-CxIntegrations/tree/master/CxTeamCity), [image](https://hub.docker.com/r/cxai/cxteamcity/)
17+
* SonarQube [dockerfile](https://github.com/cxai/Docker-CxIntegrations/tree/master/CxSonarQube), [image](https://hub.docker.com/r/cxai/cxsonarqube/)
1718
* Ant
1819
* Maven
1920
* Threadfix
2021
* Bamboo
21-
* SonarQube
2222
* TFS
2323
* LDAP
2424
* SAML IdP

0 commit comments

Comments
 (0)