บทนำ (Overview)
วัตถุประสงค์เพื่อ ติดตั้ง Sonarqube ให้สามารถใช้งานบน Windows และทดลอง Scan โปรแกรมที่เขียนด้วย C#
บทความโดย
Hades
Cyber Security Researcher
โปรแกรมจำเป็นต้องมี (Prerequisite):
- SonarQube Community edition
- Sonar c# plugin
- Sonar dependency check (Opensource scan)
- SonarScanner for MSBuildเลือก Download for .NET Framework 4.6+
- JRE
- MSbuild tools
ขั้นตอนการติดตั้ง (Installation step)
- MSbuild tool https://www.microsoft.com/en-us/download/confirmation.aspx?id=48159
- JRE http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html
- SonarQube
- https://www.sonarqube.org/downloads/
- Unzip SonarQube ไปยัง Pathที่ต้องการ โดยตัวอย่างจะ unzipไว้ที่ C:\
- เข้าไปที่ Path C:\sonarqube\bin\windows-x86-64(ขึ้นอยู่กับสถาปัตยกรรมที่ใช้งาน)
- เริ่ม Run file โดย Run ด้วยสิทธิ์ Administratorเท่านั้นตามลำดับต่อไปนี้
- InstallNTService.bat
- StartNTService.bat
- StartSonar.bat
- จากนั้นทดสอบการเข้าใช้งานSonarQube web application ได้ที่
- https://www.sonarqube.org/downloads/
- ติดตั้ง Sonar c#
- ติดตั้ง Sonar dependency check
- https://github.com/stevespringett/dependency-check-sonar-plugin/releases
- หลังจาก Load file มาแล้วให้ Copyไปไว้ที่ Path C:\sonarqube\extensions\plugins
- เข้ามาที่SonaQube เลือก System / Restart Server
- https://github.com/stevespringett/dependency-check-sonar-plugin/releases
- SonarScanner for MSBuild
- https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild
- https://github.com/SonarSource/sonar-scanner-msbuild/releases/download/4.3.1.1372/sonar-scanner-msbuild-4.3.1.1372-net46.zip
- Unzip SonarScannerไปยัง Path ที่ต้องการ โดยตัวอย่างจะunzip ไว้ที่ C:\
- เพิ่ม Pathลงใน Environment variable
- https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+MSBuild
- Testing C# source code scan:
- Download source code from: https://github.com/jerryhoff/WebGoat.NET.git
- เข้าไปยัง Project Path
SonarScanner.MSBuild.exe begin /k:"testcsharp3" /n:"test-csharp3" /v:"1.0" Testcsharp3: keyname test-csharp3: Project Name
- “C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe” /t:Rebuild
- SonarScanner.MSBuild.exe end
- เข้ามาที่Dashboard sonarqube