You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## This script Launches the benchmark, populates results on Sonarqube Dashboard and then fetch same results back from the SonarQube Server using SONAR Host,Project and Token
3
-
## This Script is totaly experimental. Tested Against SonarQube Enterprise Server version 9.9 LTS
4
-
## To run SonarQube benchmark you need to be on the /BenchmarkJava path and run ./scripts/runSonarQube.sh
2
+
3
+
# this script will
4
+
# - create a sonarqube server using the default configuration
5
+
# - setup basic things (account, project, token)
6
+
# - start a scan (takes >= 1 hour on mac)
7
+
# - create a report file
8
+
# - shutdown sonarqube server
5
9
6
10
source scripts/requireCommand.sh
7
11
8
12
requireCommand curl
13
+
requireCommand docker
9
14
requireCommand jq
10
15
11
16
# Check for install/updates at https://github.com/SonarSource/sonarqube
12
-
# This is Page size, If facing JQ Errors due to Long Arguments, Decrease this Number. Tested with SonarQube 9.9 LTS, 50 and 100 where producing lots of errors,
13
-
elements_per_request=20
14
17
15
-
if [ !-f scripts/SonarQubeCredentials.sh ];then cat > scripts/SonarQubeCredentials.sh <<EOF
16
-
#!/usr/bin/env bash
17
-
sonar_host="" # e. g. http://localhost:9000
18
-
sonar_project=""
19
-
sonar_token=""
20
-
EOF
21
-
chmod +x scripts/SonarQubeCredentials.sh
22
-
fi
18
+
sonar_port="9876"
19
+
sonar_host="http://localhost:$sonar_port"
20
+
sonar_project="benchmark"
21
+
sonar_user="admin"
22
+
sonar_default_password="admin"
23
+
sonar_password="password"
24
+
25
+
echo"Creating temporary SonarQube instance"
26
+
27
+
docker pull sonarqube
28
+
29
+
# start local sonarqube
30
+
container_id=$(docker run --rm -d -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true -p "$sonar_port:9000" sonarqube)
# sonarqube does not allow us to grab more than 10k issues, but most of them are information exposure which is not even
80
+
# considered by benchmark so let's just get all relevant rules and receive results for only those rules
44
81
45
-
## WE ARE GOING TO DISCARD RULE CHERRY PICKING. SO ALL RESULTS ARE REPORTED REGARDLESS SO THAT BENCHMARK CAN POPULATE RESULTS & SCORE ACCORDINGLY.
46
-
## The content/data structure returned is controled by SONARQUEBE end server, Benchmark Script picks them accordingly and match them back to test cases and create the score.
47
-
## If returned data are not structured in a way expected by Benchmark/Score calculator. Example: CWE/DataPoint missed then results will not be counted/scored. This can end up in in-correct/Lower Score calculation.
## We are using two files to write results to. One as buffer the other as final to incrementally add results and swap in-between.
66
-
## This helps to have some sort of fault tolerance. If jq hits long argument or sonarqube sends back impaired data/empty for a single page, previous progress of result collection will not be erased/lost retroactively.
0 commit comments