開始使用 Lucent Sky AVM CLI

2024/1/20 |

Lucent Sky AVM 是一套開發者工具,能找出應用程式中的安全弱點,並直接在程式碼中修正弱點。Lucent Sky AVM 包括了 CLEAR Engine(分析及修正引擎)、Web UI、CLI、IDE 擴充套件。

這個文章描述了 CLI 的基本功能,並帶領你使用 CLI 掃描一個應用程式。要深入了解關於 CLI 的其他功能,請參考 Lucent Sky 知識庫:
Lucent Sky AVM CLI 參考資料

在這個文章中,你將會學習如何:

  • 安裝和設定 Lucent Sky CLI
  • 建立包含應用程式程式碼的壓縮檔案
  • 建立一個 API 金鑰
  • 掃描一個應用程式
  • 下載修正後的程式碼
  • 下載報告

本文結束時,你將能夠使用 CLI 來掃描應用程式並產生修正後的程式碼和報告。

必要條件

  • Bash、Command Prompt、Windows PowerShell - 本文中的範例使用 PowerShell,但 CLI 亦可在 Bash 或 Command Prompt 中使用。

安裝和設定 Lucent Sky CLI

要深入了解關於如何安裝 Lucent Sky AVM CLI,請參考 Lucent Sky 知識庫:
Lucent Sky AVM CLI 管理者指南

建立包含應用程式程式碼的壓縮檔案。

要深入了解關於如何建立包含應用程式程式碼的壓縮檔案,請參考 Lucent Sky 知識庫:
準備應用程式以進行掃描

建立一個 API 金鑰

  1. 以瀏覽器開啟 Web UI 並以你的帳號登入。
  2. 瀏覽至 設定 > '帳戶,再選擇 建立新的金鑰。在對話框中,輸入 CLI 做為金鑰的描述,再選擇 建立金鑰
  3. 選擇並複製產生的 API 金鑰。

設置 CLI

  1. 開啟 PowerShell,並瀏覽至 CLI 安裝的目錄。
  2. 輸入以下命令來設定 CLI 以使用一個遠端的 CLEAR Engine 實體:

     # Replace <InstanceFqdn> with the FQDN or IP address of the CLEAR Engine instance
     $instanceFqdn = "<InstanceFqdn>"
     .\SkyAnalyzer.Interface.Console.exe --Interface config --Method set --Value "endpoint = $instanceFqdn:5759"
    
  3. 輸入以下命令來建立一個儲存 API 金鑰的環境變數供驗證使用:

     # Replace <ApiKey> with the API key
     $Env:CLEAR_API_KEY = "<ApiKey>"
    

掃描一個應用程式

  1. 開啟 PowerShell,並瀏覽至 CLI 安裝的目錄。
  2. 輸入以下命令來建立一個應用程式:

     $applicationId = New-Guid
     # Replace <ApplicationName> with a descriptive name of the application
     $applicationNAme = "<ApplicationName>"
     # Replace <Framework> with the framework of the application
     $framework = "<Framework>"
     .\SkyAnalyzer.Interface.Console.exe --Interface Application --Method Create --Name $applicationNAme --Framework $framework --ApplicationId $applicationId
    
  3. 輸入以下命令來建立一個掃描:

     $scanId = New-Guid
     .\SkyAnalyzer.Interface.Console.exe --Interface Scan --Method Create --ApplicationId $applicationId --ScanId $scanId
    
  4. 輸入以下命令來上傳應用程式的程式碼並開始掃描:

     # Replace <SourceCodePath> with path to the source code archive
     $sourceCodePath = "<SourceCodePath>"
     .\SkyAnalyzer.Interface.Console.exe --Interface Scan --Method Analyze --ScanId $scanId --SourceCodePath $sourceCodePath
    

    這個命令會在掃描完成後結束。要深入了解如何以非同步方式開始掃描,請參考 Lucent Sky 知識庫:
    Lucent Sky AVM CLI 參考資料

下載修正後的程式碼

  1. 輸入以下命令來產生並下載修正後的程式碼:

     # Replace <RemediatedSourceCodePath> with path to save the remediated source code archive
     $remediatedSourceCodePath = "<RemediatedSourceCodePath>"
     .\SkyAnalyzer.Interface.Console.exe --Interface Scan --Method Remediate --ScanId $scanId --RemediatedSourceCodePath $remediatedSourceCodePath --RemediationOption 0
    

下載報告

  1. 輸入以下命令來產生並下載 HTML 格式的報告,其中 <ReportPath> 是儲存報告的路徑:

     # Replace <ReportPath> with path to save the remediated source code archive
     $reportPath = "<ReportPath>"
     .\SkyAnalyzer.Interface.Console.exe --Interface Scan --Method Report --ScanId $scanId --ReportPath $reportPath --ReportFormat html