顯示具有 SonarQube 標籤的文章。 顯示所有文章
顯示具有 SonarQube 標籤的文章。 顯示所有文章

2025年3月7日 星期五

[研究]SonarQube是否有做原始碼安全性掃描?

[研究]SonarQube是否有做原始碼安全性掃描?

2025-03-07

https://www.sonarsource.com/products/sonarqube/downloads/

(下圖)用Security搜尋,



SonarQube Docs
https://docs.sonarsource.com/

SonarQube Community Build Documentation
https://docs.sonarsource.com/sonarqube-community-build/

輸入 "security hotspots" 查詢,選查詢結果第一個

https://docs.sonarsource.com/sonarqube-community-build/user-guide/security-hotspots/


What is a Security Hotspot?

Security Hotspot highlights a security-sensitive piece of code that the developer needs to review. Upon review, you'll either find no threat, or you will need to apply a fix to secure the code.

什麼是安全熱點?

安全熱點會反白顯示開發人員需要檢查的安全敏感程式碼片段。

********************************************************************************

在 SonarQube 教育訓練時,問了講師確認了,SonarQube Community Build (社群建置版)、開源版、免費版等 SonarQube 都沒有做源碼安全檢測,只做原始碼品質(源碼品質)檢測,,付費版本才有做類似 Fortify SCA (Fortify Static Code Analyzer) 或 Checkmarx 原始碼靜態分析測試。

(完)

2025年3月5日 星期三

[研究]SonarQube for Visual Studio 2019 安裝

[研究]SonarQube for Visual Studio 2019 安裝

2025-03-05

SonarQube for IDE
https://www.sonarsource.com/zh/products/sonarlint/

SonarQube for Visual Studio 2019
https://marketplace.visualstudio.com/items?itemName=SonarSource.SonarLintforVisualStudio2019

SonarQube for Visual Studio 2022
https://marketplace.visualstudio.com/items?itemName=SonarSource.SonarLintforVisualStudio2022

SonarQube for IDE Installation
https://docs.sonarsource.com/sonarqube-for-ide/visual-studio/getting-started/installation/












********************************************************************************

疑似還需要安裝 Node.js ?



Initializing the telemetry package...
Finished initializing the telemetry package...
Initializing the daemon package...
[Open in IDE] Creating request listener...
[Open in IDE] Checking availability of port 64120
Finished initializing the daemon package.
[Open in IDE] Request listener created successfully. Listening on port 64120.
Initializing the SonarLint package...
Finishing initializing the SonarLint package
Settings file does not exist at "C:\Users\Administrator\AppData\Roaming\SonarLint for Visual Studio\settings.json".
Default settings will be used
Current VS version:
    Visual Studio Enterprise 2019
    16.11.35731.53
    16.11.44
[NodeJSLocator] Checking environment variable SONAR_NODEJS_PATH
[NodeJsLocator] Environment variable is not set
[NodeJsLocator] Found incompatible Node.js version: 18.15.0. Path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\NodeJs\node.exe
[NodeJsLocator] Found incompatible Node.js version: 12.18.4. Path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\ServiceHub\Hosts\ServiceHub.Host.Node.x86\ServiceHub.Host.Node.x86.exe
[NodeJsLocator] Could not find a compatible Node.js version. Supported versions are v14.17+.
[NodeJSLocator] Checking environment variable SONAR_NODEJS_PATH
[NodeJsLocator] Environment variable is not set


********************************************************************************

SonarLint for Visual Studio 2019 和 VSSonarExtension2019 差別 ?

ChatGPT 說:

SonarLint for Visual Studio 2019 和 VSSonarExtension2019 都是與 SonarQube 相關的 Visual Studio 擴充套件,但它們的用途和功能有所不同:

1. SonarLint for Visual Studio 2019
  • 功能:SonarLint 是一個即時靜態程式碼分析工具,可在 Visual Studio 2019 中直接檢測程式碼的品質問題,例如潛在的錯誤、安全性漏洞和不良程式碼習慣。
  • 運作方式:
    • 獨立運作:可以獨立運行,不需要 SonarQube 伺服器。
    • 連接 SonarQube/SonarCloud(可選):可以與 SonarQube 或 SonarCloud 伺服器同步,以取得與組織內部 SonarQube 設定一致的規則集。
    • 即時分析:在程式碼編寫時即時顯示問題,並提供修正建議。
  • 適用對象:開發人員在開發階段即時檢查程式碼品質,不必等待 CI/CD 進行分析。

2. VSSonarExtension2019
  • 功能:VSSonarExtension2019 是一個協助將 Visual Studio 專案與 SonarQube 伺服器 整合的擴充套件,但本身不提供即時靜態分析功能。
  • 運作方式:
    • 需要連結 SonarQube 伺服器,並依照 SonarQube 設定進行分析。
    • 主要用於下載 SonarQube 配置、專案綁定,或在 CI/CD 中執行 SonarQube 分析。
    • 通常搭配 MSBuild Scanner 或 SonarQube Scanner for .NET 使用。
  • 適用對象:需要將 Visual Studio 2019 的專案與 SonarQube 進行 CI/CD 整合的開發團隊。

比較總結

特性SonarLint for Visual Studio 2019VSSonarExtension2019
主要用途即時靜態程式碼分析與 SonarQube 整合
是否需要 SonarQube不需要(可獨立使用)需要
是否提供即時分析
是否適用於 CI/CD
是否可同步 SonarQube 規則可選擇同步
如果你主要是想在 Visual Studio 2019 開發階段即時檢測程式碼,那麼 SonarLint 會比較適合。如果你的團隊已經有 SonarQube 伺服器,並且需要整合 Visual Studio 2019 進行掃描,那麼 VSSonarExtension2019 可能會更適合。

(完)

[研究]SonarQube for Visual Studio 2022 安裝

[研究]SonarQube for Visual Studio 2022 安裝

2025-03-05

SonarQube for IDE
https://www.sonarsource.com/zh/products/sonarlint/

SonarQube for Visual Studio 2019
https://marketplace.visualstudio.com/items?itemName=SonarSource.SonarLintforVisualStudio2019

SonarQube for Visual Studio 2022
https://marketplace.visualstudio.com/items?itemName=SonarSource.SonarLintforVisualStudio2022

SonarQube for IDE Installation
https://docs.sonarsource.com/sonarqube-for-ide/visual-studio/getting-started/installation/











********************************************************************************
SonarQube for Visual Studio 2022 和 VSSonarExtension2022 差別 ?

ChatGPT 說:

SonarQube for Visual Studio 2022 和 VSSonarExtension2022 主要的差異在於它們的用途、適用環境以及與 SonarQube 的整合方式:

1. SonarQube for Visual Studio 2022
  • 官方名稱:SonarLint for Visual Studio 2022
  • 用途:這是 SonarSource 官方提供的 Visual Studio 擴充套件,用來在本機開發環境即時分析程式碼品質。
  • 功能:
    • 本地端即時靜態程式碼分析,偵測安全性漏洞、錯誤和程式碼異味(Code Smells)。
    • 可連結到 SonarQube 或 SonarCloud,但本身也可以獨立運作。
    • 針對 C#, VB.NET 等語言提供規則檢查與即時回饋。
    • 需要安裝 SonarLint for Visual Studio 2022 擴充套件(來自 Visual Studio Marketplace)。
  • 適用環境:適合開發人員在 Visual Studio 2022 開發時使用,即時獲取建議。

2. VSSonarExtension2022
  • 來源:這是一款 第三方開發 的 Visual Studio 擴充套件,目的是幫助開發者在 Visual Studio 內更方便地與 SonarQube 互動。
  • 功能:
    • 不提供即時程式碼分析(不像 SonarLint),而是幫助使用者更方便地與 SonarQube 互動,例如執行分析、檢視報告等。
    • 主要作用是讓 Visual Studio 內可以直接存取 SonarQube 分析結果,但它本身不負責靜態程式碼分析。
  • 適用環境:適合 團隊 使用 SonarQube 時,想要在 Visual Studio 內整合 SonarQube 報告。
比較總結

 SonarQube for Visual Studio 2022 (SonarLint)VSSonarExtension2022
開發者SonarSource 官方第三方
功能即時靜態程式碼分析,提供建議讓 Visual Studio 可存取 SonarQube 報告
獨立運作可獨立運作,或連結 SonarQube/SonarCloud需搭配 SonarQube
適用對象開發者,寫程式時即時獲得建議需查看 SonarQube 分析結果的團隊
語言支援C#, VB.NET依 SonarQube 設定
如果你想要在 Visual Studio 內即時偵測問題,建議使用 SonarLint;如果是 想在 Visual Studio 內查看 SonarQube 分析結果,則可以考慮 VSSonarExtension2022。

(完)

2022年10月18日 星期二

[研究]SonarQube 9.7.0 + SonarScanner 5.8.0 (.NET 4.6) 原始碼品質、原始碼安全掃描工具安裝試用 (Win2022)

[研究]SonarQube 9.7.0 + SonarScanner 5.8.0 (.NET 4.6) 原始碼品質、原始碼安全、源碼品質、源碼安全掃描工具安裝試用 (Windows Server 2022)

2022-10-18
2022-10-19更新

OWASP整理了相關源碼靜態分析工具
https://www.owasp.org/index.php/Source_Code_Analysis_Tools
免費版本如Puma Scan、.NET Security Guard、SonarQube等

SonarQube - 維基百科,自由的百科全書
https://zh.wikipedia.org/zh-tw/SonarQube
SonarQube(曾用名Sonar(聲納))是一個開源的代碼品質管理系統。

Code Quality and Code Security | SonarQube
https://www.sonarqube.org/
Code Quality and Code Security (原始碼品質、原始碼安全)

(下圖) Click 圖片可看100%圖


********************************************************************************

軟體需求
https://docs.sonarqube.org/latest/requirements/requirements/

預設似乎使用 H2 Database Engine,不用另外安裝資料庫軟體。

Server 只支援 Java JRE 11,敝人安裝 Microsoft JDK,microsoft-jdk-11.0.16.1-windows-x64.msi,安裝時勾選 JAVA_HOME。


Windows
setx  SONAR_JAVA_PATH  "C:\Program Files\java_home\bin\java.exe"

Windows Server 2022 上
setx   SONAR_JAVA_PATH   "C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin\java.exe"

環境變數可以不在此時設定,後面一堆一起設定。(要指定到 java.exe 程式,不是路徑)

********************************************************************************

1.SonarQube 9.7.0 (Web Server) 下載與安裝

官方下載,sonarqube-9.7.0.61563.zip (2022年10月釋出)
https://www.sonarqube.org/
https://www.sonarqube.org/downloads/

安裝參考
https://docs.sonarqube.org/latest/setup/install-server/

SonarQube需要 ElasticSearch,已經內含。安裝很簡單,解壓縮即可。






啟動有 2 種方式:(一)程式 (二)服務

可以先以程式方式測試執行是否正常,切換到程式目錄,執行程式
cd   C:\sonarqube-9.7.0.61563\bin\windows-x86-64
StartSonar.bat

(後面會把目錄加入環境變數 PATH,就不用切換目錄)



********************************************************************************
實際執行畫面

C:\>cd c:\sonarqube-9.7.0.61563\bin\windows-x86-64

c:\sonarqube-9.7.0.61563\bin\windows-x86-64>StartSonar.bat 
Starting SonarQube...
2022.10.18 14:25:24 INFO  app[][o.s.a.AppFileSystem] Cleaning or creating temp directory C:\sonarqube-9.7.0.61563\temp
2022.10.18 14:25:24 INFO  app[][o.s.a.es.EsSettings] Elasticsearch listening on [HTTP: 127.0.0.1:9001, TCP: 127.0.0.1:49945]
2022.10.18 14:25:24 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[ELASTICSEARCH] from [C:\sonarqube-9.7.0.61563\elasticsearch]: C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin\java -XX:+UseG1GC -Djava.io.tmpdir=C:\sonarqube-9.7.0.61563\temp -XX:ErrorFile=../logs/es_hs_err_pid%p.log -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -Djna.tmpdir=C:\sonarqube-9.7.0.61563\temp -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dio.netty.allocator.numDirectArenas=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j2.formatMsgNoLookups=true -Djava.locale.providers=COMPAT -Dcom.redhat.fips=false -Xmx512m -Xms512m -XX:MaxDirectMemorySize=256m -XX:+HeapDumpOnOutOfMemoryError -Delasticsearch -Des.path.home=C:\sonarqube-9.7.0.61563\elasticsearch -Des.path.conf=C:\sonarqube-9.7.0.61563\temp\conf\es -cp lib/* org.elasticsearch.bootstrap.Elasticsearch
2022.10.18 14:25:24 INFO  app[][o.s.a.SchedulerImpl] Waiting for Elasticsearch to be up and running
2022.10.18 14:25:34 INFO  app[][o.s.a.SchedulerImpl] Process[es] is up
2022.10.18 14:25:34 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[WEB_SERVER] from [C:\sonarqube-9.7.0.61563]: C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin\java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=C:\sonarqube-9.7.0.61563\temp -XX:-OmitStackTraceInFastThrow --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED -Dcom.redhat.fips=false -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/sonar-application-9.7.0.61563.jar;C:\sonarqube-9.7.0.61563\lib\jdbc\h2\h2-2.1.214.jar org.sonar.server.app.WebServer C:\sonarqube-9.7.0.61563\temp\sq-process2239496047474178083properties
2022.10.18 14:26:32 INFO  app[][o.s.a.SchedulerImpl] Process[web] is up
2022.10.18 14:26:32 INFO  app[][o.s.a.ProcessLauncherImpl] Launch process[COMPUTE_ENGINE] from [C:\sonarqube-9.7.0.61563]: C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin\java -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djava.io.tmpdir=C:\sonarqube-9.7.0.61563\temp -XX:-OmitStackTraceInFastThrow --add-opens=java.base/java.util=ALL-UNNAMED --add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.management/sun.management=ALL-UNNAMED --add-opens=jdk.management/com.sun.management.internal=ALL-UNNAMED -Dcom.redhat.fips=false -Xmx512m -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Dhttp.nonProxyHosts=localhost|127.*|[::1] -cp ./lib/sonar-application-9.7.0.61563.jar;C:\sonarqube-9.7.0.61563\lib\jdbc\h2\h2-2.1.214.jar org.sonar.ce.app.CeServer C:\sonarqube-9.7.0.61563\temp\sq-process16600548783928992018properties
2022.10.18 14:26:33 WARN  app[][startup] ####################################################################################################################
2022.10.18 14:26:33 WARN  app[][startup] Default Administrator credentials are still being used. Make sure to change the password or deactivate the account.
2022.10.18 14:26:33 WARN  app[][startup] ####################################################################################################################
2022.10.18 14:26:38 INFO  app[][o.s.a.SchedulerImpl] Process[ce] is up
2022.10.18 14:26:38 INFO  app[][o.s.a.SchedulerImpl] SonarQube is operational
2022.10.18 14:29:51 INFO  app[][o.s.a.SchedulerImpl] Stopping SonarQube
2022.10.18 14:29:51 INFO  app[][o.s.a.SchedulerImpl] Sonarqube has been requested to stop
2022.10.18 14:29:51 INFO  app[][o.s.a.SchedulerImpl] Stopping [Compute Engine] process...
2022.10.18 14:29:51 INFO  app[][o.s.a.SchedulerImpl] Process[Compute Engine] is stopped
2022.10.18 14:29:51 INFO  app[][o.s.a.SchedulerImpl] Stopping [Web Server] process...
2022.10.18 14:29:52 INFO  app[][o.s.a.SchedulerImpl] Process[Web Server] is stopped
2022.10.18 14:29:52 INFO  app[][o.s.a.SchedulerImpl] Stopping [ElasticSearch] process...
2022.10.18 14:29:52 INFO  app[][o.s.a.SchedulerImpl] Process[ElasticSearch] is stopped
2022.10.18 14:29:52 INFO  app[][o.s.a.SchedulerImpl] SonarQube is stopped
要終止批次工作嗎 (Y/N)? y

c:\sonarqube-9.7.0.61563\bin\windows-x86-64>


********************************************************************************

服務的安裝、啟動、狀態、停止、移除

建議安裝成服務,省去以後每次要啟動的麻煩。

執行 SonarService.bat   install   安裝
執行 SonarService.bat   start   啟動
執行 SonarService.bat   status   測試目前狀態
執行 SonarService.bat   stop   停止
執行 SonarService.bat   uninstall   移除



(下圖) 連上 http://localhost:9000/
注意,只支援 http,不支援 https


(下圖) 預設帳號、密碼都是 admin


(下圖) 進入畫面,先建立 Project 和 token,稍後使用







這裡說明一下產生的指令,SonarScanner.MSBuild.exe 是稍後要安裝的 SonarScanner for .NET 掃描工具程式。

SonarScanner.MSBuild.exe begin /k:"Project1Key" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="sqp_ee9f32dd70a77dff027e24ee836aef031d8c4d75"

如果沒有先切換到 .sln 檔案所在目錄,上面執行會出問題


C:\Code\WebApplication1>SonarScanner.MSBuild.exe end
SonarScanner for MSBuild 5.8
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
16:35:53.195  Temporary analysis directory (usually .sonarqube) doesn't exist. The "begin" step was probably not executed.
16:35:53.195  Post-processing failed. Exit code: 1
C:\Code\WebApplication1>


下面是執行 MSBuild.exe,需要至少 v14 或更新 (稍後安裝),而且要在 方案 (.sln) 所在的目錄。

MsBuild.exe /t:Rebuild  


如果不在 .sln 所在的目錄,要指定 .sln,例如:

MsBuild.exe /t:Rebuild   C:\Code\WebApplication1\WebApplication1.sln  

結束執行


SonarScanner.MSBuild.exe end /d:sonar.login="sqp_ee9f32dd70a77dff027e24ee836aef031d8c4d75"  

在某些 Google 的網頁中,end 後面是不需要 /d:sonar.login="sqp_ee9f32dd70a77dff027e24ee836aef031d8c4d75"   參數的 


SonarScanner.MSBuild.exe end  

實際測試是需要的,否則執行會出現錯誤 (可能不同 SonarQube 版本的要求不同)


C:\Code\WebApplication1>SonarScanner.MSBuild.exe end
SonarScanner for MSBuild 5.8
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
16:37:08.364  Credentials must be passed in both begin and end steps or not at all  
16:37:08.364  Post-processing failed. Exit code: 1  

實際測試是需要的,否則執行會出現

(下圖) 如果要正式使用,建議不要用預設的 Embedded database


Embedded database should be used for evaluation purposes only

The embedded database will not scale, it will not support upgrading to newer versions of SonarQube, and there is no support for migrating your data out of it into a different database engine.

********************************************************************************
2.SonarScanner for .NET 5.8.0 掃描工具下載、安裝

SonarScanner for .NET | SonarQube Docs 下載與說明
https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-msbuild/

建議下載 .NET Framework 4.6+,因為 .NET 5+ 沒有看到主程式 SonarScanner.MSBuild.exe,敝人暫時不知如何處理。




SonarScanner for NET 4.6+直接下載

https://github.com/SonarSource/sonar-scanner-msbuild/releases/download/5.8.0.52797/sonar-scanner-msbuild-5.8.0.52797-net46.zip

要使用 SonarScanner for NET 4.6+,有一些先決條件

(1) MSBuild.exe 需要 v14 或更新,可參考這篇安裝

[研究]Visual Studio 2022 v17 安裝 MSBuild.exe v17
http://shaurong.blogspot.com/2022/10/visual-studio-2022-v17-msbuildexe-v17.html

(2) 另外在Visual Studio 2022 v17 安裝 MSBuild.exe v17時,請勾選 .NET Framework 4.6.x,其他 .NET Framework 是否安裝隨便;後面建立 ASP.NET WebForm 方案進行測試時,框架版本也請選 4.6,成功了再去測試 4.7.x 或 4.8.x。

(下圖)工作負載「ASP.NET與網頁程式開發」是稍後為了測試而安裝的開發環境 


(下圖)「SonarScanner for NET 4.6+」需要的

SonarScanner for .NET 5.8.0 安裝只要解壓縮即可。





********************************************************************************

3.設定環境變數

(下圖) 新增 SONAR_JAVA_PATH 環境變數,值為
C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin\java.exe

(下圖) 編輯PATH,新增
C:\sonarqube-9.7.0.61563\bin\windows-x86-64
C:\sonar-scanner-msbuild-5.8.0.52797-net46
C:\sonar-scanner-msbuild-5.8.0.52797-net46\sonar-scanner-4.7.0.2747\bin
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64



(下圖) 新增 SONAR_JAVA_PATH 環境變數,值為
C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin\java.exe



(下圖) 編輯PATH,新增
C:\sonarqube-9.7.0.61563\bin\windows-x86-64
C:\sonar-scanner-msbuild-5.8.0.52797-net46
C:\sonar-scanner-msbuild-5.8.0.52797-net46\sonar-scanner-4.7.0.2747\bin
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64




注意,環境變數設定後,對已經開啟的「命令提示字元」無效,請關閉;僅對之後新開的「命令提示字元」有效。 

********************************************************************************

4.建立 ASP.NET WebForm 方案,掃描測試





Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" 
    Inherits="WebApplication1.Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
        </div>
    </form>
</body>
</html>


Default.aspx.cs

using System;

namespace WebApplication1
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.Redirect(TextBox1.Text);
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect(TextBox1.Text);
        }
    }
}

為了方便執行,建立了一個 C:\Temp\T1.bat 檔案,如下

cd  C:\Code\WebApplication1

@REM SonarScanner.MSBuild.exe begin /k:"Project1Key" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="sqp_ee9f32dd70a77dff027e24ee836aef031d8c4d75"
SonarScanner.MSBuild.exe begin /k:"Project1Key" /d:sonar.login="sqp_ee9f32dd70a77dff027e24ee836aef031d8c4d75"


MsBuild.exe /t:Rebuild

SonarScanner.MSBuild.exe end /d:sonar.login="sqp_ee9f32dd70a77dff027e24ee836aef031d8c4d75"
@REM SonarScanner.MSBuild.exe end

執行結果如下

C:\Code\WebApplication1>c:\temp\t1.bat

C:\Code\WebApplication1>cd C:\Code\WebApplication1
C:\Code\WebApplication1>SonarScanner.MSBuild.exe begin /k:"Project1Key" /d:sonar.login="sqp_ee9f32dd70a77dff027e24ee836aef031d8c4d75" SonarScanner for MSBuild 5.8 Using the .NET Framework version of the Scanner for MSBuild Pre-processing started. Preparing working directories... 16:37:48.886 Updating build integration targets... 16:37:48.98 Fetching analysis configuration settings... 16:37:49.324 Provisioning analyzer assemblies for cs... 16:37:49.339 Installing required Roslyn analyzers... 16:37:49.605 Provisioning analyzer assemblies for vbnet... 16:37:49.605 Installing required Roslyn analyzers... 16:37:49.636 Pre-processing succeeded. C:\Code\WebApplication1>MsBuild.exe /t:Rebuild MSBuild version 17.3.1+2badb37d1 for .NET Framework 在此解決方案中一次建置一個專案。若要啟用平行建置,請新增 "-m" 參數。 已經開始建置於 2022/10/18 下午 04:37:49。 節點 1 (Rebuild 目標) 上的專案 "C:\Code\WebApplication1\WebApplication1.sln"。 ValidateSolutionConfiguration: 建置方案組態 "Debug|Any CPU"。 專案 "C:\Code\WebApplication1\WebApplication1.sln" (1) 正在節點 1 (Rebuild 目標) 上建置 "C:\Code\WebApplication1\WebApplication1\W ebApplication1.csproj" (2)。 KillVBCSCompilerBeforeClean: ExecutablePath is C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Roslyn\VBCSCompiler.ex e CoreClean: 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\WebApplication1.dll.config"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\WebApplication1.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\WebApplication1.pdb"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\csc.exe"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\csc.exe.config"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\csc.rsp"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\csi.exe"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\csi.exe.config"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\csi.rsp"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.Build.Tasks.CodeAnalysis.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.CodeAnalysis.CSharp.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.CodeAnalysis.CSharp.Scripting.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.CodeAnalysis.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.CodeAnalysis.Scripting.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.CodeAnalysis.VisualBasic.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.CSharp.Core.targets"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.DiaSymReader.Native.amd64.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.DiaSymReader.Native.x86.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.Managed.Core.targets"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.VisualBasic.Core.targets"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.Win32.Primitives.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.AppContext.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Collections.Immutable.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Console.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Diagnostics.DiagnosticSource.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Diagnostics.FileVersionInfo.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Diagnostics.StackTrace.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Globalization.Calendars.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.IO.Compression.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.IO.Compression.ZipFile.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.IO.FileSystem.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.IO.FileSystem.Primitives.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Net.Http.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Net.Sockets.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Reflection.Metadata.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Runtime.InteropServices.RuntimeInformation.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Security.Cryptography.Algorithms.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Security.Cryptography.Encoding.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Security.Cryptography.Primitives.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Security.Cryptography.X509Certificates.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Text.Encoding.CodePages.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Threading.Tasks.Extensions.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.ValueTuple.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Xml.ReaderWriter.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Xml.XmlDocument.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Xml.XPath.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Xml.XPath.XDocument.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\vbc.exe"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\vbc.exe.config"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\vbc.rsp"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\VBCSCompiler.exe"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\VBCSCompiler.exe.config"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\bin\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.xml"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\obj\Debug\WebApplication1.csproj.AssemblyReference.cache"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\obj\Debug\WebApplication1.csproj.CoreCompileInputs.cache"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\obj\Debug\WebApplication1.csproj.CopyComplete"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\obj\Debug\WebApplication1.dll"。 正在刪除檔案 "C:\Code\WebApplication1\WebApplication1\obj\Debug\WebApplication1.pdb"。 GenerateTargetFrameworkMonikerAttribute: 將略過目標 "GenerateTargetFrameworkMonikerAttribute",因為所有輸出檔對於其輸入檔而言都已更新。 SonarCategoriseProject: Sonar: (WebApplication1.csproj) Categorizing project as test or product code... Sonar: (WebApplication1.csproj) categorized as MAIN project (production code). SonarCreateProjectSpecificDirs: 正在建立目錄 "C:\Code\WebApplication1\.sonarqube\conf\0"。 SonarWriteFilesToAnalyze: Sonar: (WebApplication1.csproj) Number of files to analyse: 8. The list of files to be analyzed is in C:\Code\WebAppl ication1\.sonarqube\conf\0\FilesToAnalyze.txt. SetRoslynCodeAnalysisProperties: Sonar: (WebApplication1.csproj) Analysis configured successfully with C:\Code\WebApplication1\.sonarqube\conf\0\Sonar ProjectConfig.xml. SonarQubeImportBeforeInfo: Sonar: (WebApplication1) SonarQube.Integration.ImportBefore.targets was loaded CoreCompile: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Roslyn\csc.exe /noconfig /nowarn:1701,17 02 /fullpaths /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+ /reference:C:\Code\WebApplic ation1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft.CodeDom.Providers.DotNet CompilerPlatform.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\M icrosoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\m scorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Co mponentModel.DataAnnotations.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFra mework\v4.6\System.Configuration.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NE TFramework\v4.6\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFram ework\v4.6\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Frame work\.NETFramework\v4.6\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\ .NETFramework\v4.6\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramew ork\v4.6\System.Drawing.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramewor k\v4.6\System.EnterpriseServices.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NE TFramework\v4.6\System.Web.ApplicationServices.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft \Framework\.NETFramework\v4.6\System.Web.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Frame work\.NETFramework\v4.6\System.Web.DynamicData.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft \Framework\.NETFramework\v4.6\System.Web.Entity.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsof t\Framework\.NETFramework\v4.6\System.Web.Extensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Mic rosoft\Framework\.NETFramework\v4.6\System.Web.Services.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\ Microsoft\Framework\.NETFramework\v4.6\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Micros oft\Framework\.NETFramework\v4.6\System.Xml.Linq.dll" /debug+ /debug:full /optimize- /out:obj\Debug\WebApplication1.d ll /ruleset:C:\Code\WebApplication1\.sonarqube\conf\Sonar-cs.ruleset /errorlog:C:\Code\WebApplication1\.sonarqube\out \0\Issues.json /subsystemversion:6.00 /target:library /warnaserror- /utf8output /langversion:7.3 /analyzer:C:\Users\A dministrator\AppData\Local\Temp\.sonarqube\resources\0\Google.Protobuf.dll /analyzer:C:\Users\Administrator\AppData\L ocal\Temp\.sonarqube\resources\0\SonarAnalyzer.CFG.dll /analyzer:C:\Users\Administrator\AppData\Local\Temp\.sonarqube \resources\0\SonarAnalyzer.CSharp.dll /analyzer:C:\Users\Administrator\AppData\Local\Temp\.sonarqube\resources\0\Sona rAnalyzer.dll /analyzer:C:\Users\Administrator\AppData\Local\Temp\.sonarqube\resources\1\Google.Protobuf.dll /analyze r:C:\Users\Administrator\AppData\Local\Temp\.sonarqube\resources\1\SonarAnalyzer.CFG.dll /analyzer:C:\Users\Administr ator\AppData\Local\Temp\.sonarqube\resources\1\SonarAnalyzer.dll /analyzer:C:\Users\Administrator\AppData\Local\Temp\ .sonarqube\resources\1\SonarAnalyzer.VisualBasic.dll /additionalfile:C:\Code\WebApplication1\.sonarqube\conf\cs\Sonar Lint.xml /additionalfile:C:\Code\WebApplication1\.sonarqube\conf\0\SonarProjectConfig.xml /additionalfile:C:\Code\Web Application1\.sonarqube\conf\0\ProjectOutFolderPath.txt Default.aspx.cs Default.aspx.designer.cs Properties\AssemblyI nfo.cs "obj\Debug\.NETFramework,Version=v4.6.AssemblyAttributes.cs" CompilerServer: server - server processed compilation - ef2dc32d-42cb-4069-9496-7b2572da9bb5 _CopyFilesMarkedCopyLocal: 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft .CodeDom.Providers.DotNetCompilerPlatform.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\Microsoft.CodeDom.Pro viders.DotNetCompilerPlatform.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\lib\net45\Microsoft .CodeDom.Providers.DotNetCompilerPlatform.xml" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\Microsoft.CodeDom.Pro viders.DotNetCompilerPlatform.xml"。 由於指定了 "AlwaysCreate",因此正在建立 "C:\Code\WebApplication1\WebApplication1\obj\Debug\WebApplication1.csproj.CopyComplete"。 _CopyAppConfigFile: 正在將檔案從 "C:\Code\WebApplication1\WebApplication1\Web.config" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\WebAppli cation1.dll.config"。 CopyFilesToOutputDirectory: 正在將檔案從 "C:\Code\WebApplication1\WebApplication1\obj\Debug\WebApplication1.dll" 複製到 "C:\Code\WebApplication1\WebApplic ation1\bin\WebApplication1.dll"。 WebApplication1 -> C:\Code\WebApplication1\WebApplication1\bin\WebApplication1.dll 正在將檔案從 "C:\Code\WebApplication1\WebApplication1\obj\Debug\WebApplication1.pdb" 複製到 "C:\Code\WebApplication1\WebApplic ation1\bin\WebApplication1.pdb"。 CopyRoslynCompilerFilesToOutputDirectory: 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ csc.exe" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\csc.exe"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ csc.exe.config" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\csc.exe.config"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ csc.rsp" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\csc.rsp"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ csi.exe.config" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\csi.exe.config"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ csi.rsp" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\csi.rsp"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ csi.exe" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\csi.exe"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ Microsoft.Build.Tasks.CodeAnalysis.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.Build.Tasks .CodeAnalysis.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ Microsoft.CodeAnalysis.CSharp.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.CodeAnalysis.CSh arp.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ Microsoft.CodeAnalysis.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.CodeAnalysis.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ Microsoft.CodeAnalysis.CSharp.Scripting.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.CodeAn alysis.CSharp.Scripting.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ Microsoft.CodeAnalysis.Scripting.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.CodeAnalysis. Scripting.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ Microsoft.CSharp.Core.targets" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.CSharp.Core.targets" 。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ Microsoft.CodeAnalysis.VisualBasic.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.CodeAnalysi s.VisualBasic.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ Microsoft.DiaSymReader.Native.x86.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.DiaSymReader .Native.x86.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ Microsoft.Managed.Core.targets" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.Managed.Core.target s"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ Microsoft.DiaSymReader.Native.amd64.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.DiaSymRead er.Native.amd64.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ Microsoft.Win32.Primitives.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.Win32.Primitives.dl l"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ Microsoft.VisualBasic.Core.targets" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\Microsoft.VisualBasic.Cor e.targets"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.AppContext.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.AppContext.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Console.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Console.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Collections.Immutable.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Collections.Immutabl e.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Diagnostics.FileVersionInfo.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Diagnostics.Fi leVersionInfo.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Diagnostics.DiagnosticSource.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Diagnostics.D iagnosticSource.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Globalization.Calendars.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Globalization.Cale ndars.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.IO.Compression.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.IO.Compression.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Diagnostics.StackTrace.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Diagnostics.StackTr ace.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.IO.Compression.ZipFile.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.IO.Compression.ZipF ile.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.IO.FileSystem.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.IO.FileSystem.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.IO.FileSystem.Primitives.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.IO.FileSystem.Pri mitives.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Net.Sockets.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Net.Sockets.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Net.Http.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Net.Http.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Runtime.InteropServices.RuntimeInformation.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System .Runtime.InteropServices.RuntimeInformation.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Reflection.Metadata.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Reflection.Metadata.dl l"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Security.Cryptography.Encoding.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Security.Cr yptography.Encoding.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Security.Cryptography.Algorithms.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Security. Cryptography.Algorithms.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Security.Cryptography.X509Certificates.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Sec urity.Cryptography.X509Certificates.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Security.Cryptography.Primitives.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Security. Cryptography.Primitives.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Text.Encoding.CodePages.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Text.Encoding.Code Pages.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.ValueTuple.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.ValueTuple.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Threading.Tasks.Extensions.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Threading.Tasks .Extensions.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Xml.ReaderWriter.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Xml.ReaderWriter.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Xml.XPath.XDocument.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Xml.XPath.XDocument.dl l"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Xml.XPath.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Xml.XPath.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ System.Xml.XmlDocument.dll" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\System.Xml.XmlDocument.dll"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ vbc.exe.config" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\vbc.exe.config"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ vbc.rsp" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\vbc.rsp"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ vbc.exe" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\vbc.exe"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ VBCSCompiler.exe.config" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\VBCSCompiler.exe.config"。 正在將檔案從 "C:\Code\WebApplication1\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\tools\roslynlatest\ VBCSCompiler.exe" 複製到 "C:\Code\WebApplication1\WebApplication1\bin\roslyn\VBCSCompiler.exe"。 SonarWriteProjectData: Sonar: (WebApplication1.csproj) Project processed successfully 專案 "C:\Code\WebApplication1\WebApplication1\WebApplication1.csproj" (Rebuild 目標) 建置完成。 專案 "C:\Code\WebApplication1\WebApplication1.sln" (Rebuild 目標) 建置完成。 建置成功。 0 個警告 0 個錯誤 經過時間 00:00:01.29 C:\Code\WebApplication1>SonarScanner.MSBuild.exe end /d:sonar.login="sqp_ee9f32dd70a77dff027e24ee836aef031d8c4d75" SonarScanner for MSBuild 5.8 Using the .NET Framework version of the Scanner for MSBuild Post-processing started. Calling the TFS Processor executable... The TFS Processor has finished Calling the SonarScanner CLI... INFO: Scanner configuration file: C:\sonar-scanner-msbuild-5.8.0.52797-net46\sonar-scanner-4.7.0.2747\bin\..\conf\sonar-scanner.properties INFO: Project root configuration file: C:\Code\WebApplication1\.sonarqube\out\sonar-project.properties INFO: SonarScanner 4.7.0.2747 INFO: Java 11.0.16.1 Microsoft (64-bit) INFO: Windows Server 2022 10.0 amd64 INFO: User cache: C:\Users\Administrator\.sonar\cache INFO: Scanner configuration file: C:\sonar-scanner-msbuild-5.8.0.52797-net46\sonar-scanner-4.7.0.2747\bin\..\conf\sonar-scanner.properties INFO: Project root configuration file: C:\Code\WebApplication1\.sonarqube\out\sonar-project.properties INFO: Analyzing on SonarQube server 9.7.0.61563 INFO: Default locale: "zh_TW", source code encoding: "x-windows-950" (analysis is platform dependent) INFO: Load global settings INFO: Load global settings (done) | time=124ms INFO: Server id: 147B411E-AYPpxPXyud4SDVuzfoCX INFO: User cache: C:\Users\Administrator\.sonar\cache INFO: Load/download plugins INFO: Load plugins index INFO: Load plugins index (done) | time=140ms INFO: Load/download plugins (done) | time=1812ms INFO: Process project properties INFO: Process project properties (done) | time=16ms INFO: Execute project builders INFO: Execute project builders (done) | time=46ms INFO: Project key: Project1Key INFO: Base dir: C:\Code\WebApplication1\WebApplication1 INFO: Working dir: C:\Code\WebApplication1\.sonarqube\out\.sonar INFO: Load project settings for component key: 'Project1Key' INFO: Load project settings for component key: 'Project1Key' (done) | time=46ms WARN: SCM provider autodetection failed. Please use "sonar.scm.provider" to define SCM of your project, or disable the SCM Sensor in the project settings. INFO: Load quality profiles INFO: Load quality profiles (done) | time=62ms INFO: Load active rules INFO: Load active rules (done) | time=3405ms INFO: Load analysis cache INFO: Load analysis cache (404) | time=156ms INFO: Load project repositories INFO: Load project repositories (done) | time=30ms INFO: Indexing files... INFO: Project configuration: INFO: Indexing files of module 'WebApplication1' INFO: Base dir: C:\Code\WebApplication1\WebApplication1 INFO: Source paths: Default.aspx.cs, Default.aspx.designer.cs, Properties/Assembl... INFO: Indexing files of module 'Project1Key' INFO: Base dir: C:\Code\WebApplication1\WebApplication1 INFO: 7 files indexed INFO: Quality profile for cs: Sonar way INFO: Quality profile for web: Sonar way INFO: ------------- Run sensors on module WebApplication1 INFO: Load metrics repository INFO: Load metrics repository (done) | time=46ms INFO: Sensor JaCoCo XML Report Importer [jacoco] INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms INFO: Sensor CSS Rules [javascript] ERROR: ??T: ?????????????C WARN: Node.js not found in PATH. PATH value was: C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\sonarqube-9.7.0.61563\bin\windows-x86-64;C:\sonar-scanner-msbuild-5.8.0.52797-net46;C:\sonar-scanner-msbuild-5.8.0.52797-net46\sonar-scanner-4.7.0.2747\bin;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\.dotnet\tools INFO: Hit the cache for 0 out of 0 INFO: Miss the cache for 0 out of 0 INFO: Sensor CSS Rules [javascript] (done) | time=10199ms INFO: Sensor C# Project Type Information [csharp] INFO: Sensor C# Project Type Information [csharp] (done) | time=16ms INFO: Sensor C# Analysis Log [csharp] INFO: Roslyn version: 4.3.0.0 INFO: Language version: CSharp7_3 INFO: Concurrent execution: enabled INFO: Sensor C# Analysis Log [csharp] (done) | time=15ms INFO: Sensor C# Properties [csharp] INFO: Sensor C# Properties [csharp] (done) | time=0ms INFO: Sensor HTML [web] INFO: Sensor HTML [web] (done) | time=188ms INFO: Sensor Text Sensor [text] INFO: 3 source files to be analyzed INFO: 3/3 source files have been analyzed INFO: Sensor Text Sensor [text] (done) | time=16ms INFO: Sensor VB.NET Project Type Information [vbnet] INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=0ms INFO: Sensor VB.NET Analysis Log [vbnet] INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=15ms INFO: Sensor VB.NET Properties [vbnet] INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms INFO: ------------- Run sensors on module Project1Key INFO: Sensor JaCoCo XML Report Importer [jacoco] INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms INFO: Sensor CSS Rules [javascript] INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped. INFO: Sensor CSS Rules [javascript] (done) | time=0ms INFO: Sensor C# Project Type Information [csharp] INFO: Sensor C# Project Type Information [csharp] (done) | time=0ms INFO: Sensor C# Analysis Log [csharp] INFO: Sensor C# Analysis Log [csharp] (done) | time=0ms INFO: Sensor C# Properties [csharp] INFO: Sensor C# Properties [csharp] (done) | time=0ms INFO: Sensor Text Sensor [text] INFO: 0 source files to be analyzed INFO: 0/0 source files have been analyzed INFO: Sensor Text Sensor [text] (done) | time=0ms INFO: Sensor VB.NET Project Type Information [vbnet] INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=0ms INFO: Sensor VB.NET Analysis Log [vbnet] INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=16ms INFO: Sensor VB.NET Properties [vbnet] INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms INFO: ------------- Run sensors on project INFO: Sensor C# [csharp] INFO: Importing results from 6 proto files in 'C:\Code\WebApplication1\.sonarqube\out\0\output-cs' INFO: Importing 1 Roslyn report INFO: Found 1 MSBuild C# project: 1 MAIN project. INFO: Sensor C# [csharp] (done) | time=140ms INFO: Sensor Analysis Warnings import [csharp] INFO: Sensor Analysis Warnings import [csharp] (done) | time=0ms INFO: Sensor Zero Coverage Sensor INFO: Sensor Zero Coverage Sensor (done) | time=16ms INFO: SCM Publisher No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it. INFO: CPD Executor Calculating CPD for 3 files INFO: CPD Executor CPD calculation finished (done) | time=15ms INFO: Analysis report generated in 172ms, dir size=124.6 kB INFO: Analysis report compressed in 141ms, zip size=19.7 kB INFO: Analysis report uploaded in 94ms INFO: ANALYSIS SUCCESSFUL, you can find the results at: http://localhost:9000/dashboard?id=Project1Key INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report INFO: More about the report processing at http://localhost:9000/api/ce/task?id=AYPqPkovm1i1HB6K5UeK INFO: Analysis total time: 20.917 s INFO: ------------------------------------------------------------------------ INFO: EXECUTION SUCCESS INFO: ------------------------------------------------------------------------ INFO: Total time: 25.089s INFO: Final Memory: 16M/57M INFO: ------------------------------------------------------------------------ The SonarScanner CLI has finished 16:38:17.521 Post-processing succeeded. C:\Code\WebApplication1>

執行結果




Open Redirect 是 Micro Focus Fortify SCA ( Static Code Analyzer ) 會被報告的問題,但在 SonarQube 似乎沒有被報告,Google 很多文章都說 SonarQube 是原始碼品質檢測軟體,而未提原始碼安全,或許無法真的和商業軟體相比。

初次測試使用,文章僅供參考。至於更多的測試,以及使用資料庫,等有空再說。

********************************************************************************

補:後來拿一個 .NET Framework 4.8 的 ASP.NET WebForm 方案來測試,有執行完,但有1萬多個 Warning。結果是偏原始碼品質,不知商業版的是否會有較多原始碼安全的部分。




(完)