部署 AppScan 360° 靜態分析 叢集

可將 AppScan 360° 靜態分析 部署至任何 Kubernetes 環境。可從 HCL Harbor 或從 HCL 授權與下載入口網站下載的封存檔案 (tar.gz) 中存取 AppScan 360° SAST 部署相關的 Helm 圖表。任一套件組合都包含指令碼 (sast-service.sh),以簡化部署步驟。

使用 HCL Harbor 中的 Helm 圖表部署 AppScan 360° 靜態分析

從 Harbor 下載 Helm 圖表後:
  1. 請確保您連接到正確的 Kubernetes。

    驗證 .kube 資料夾中有正確的叢集配置檔。

  2. 取得 ASCP 伺服器主機名稱。

    例如,ascp.example.com

  3. ASCP 伺服器擷取鑑別記號、憑證和私密金鑰檔案到目前的機器。
    • 可以使用 --auth-token 選項將鑑別記號指定至 AppScan 360° SAST 部署。例如 --auth-token AgentsApiKey.txt
    • 可以使用 --cert 選項將CA 憑證指定至 AppScan 360° SAST 部署。例如 --cert AppScan360_RootCA.crt
    • 可以使用 --cert-key 選項將私密金鑰指定至 AppScan 360° SAST 部署。例如 --cert-key AppScan360_RootCA.key
  4. 「HCL Harbor」 > 「使用者設定檔」 > 「CLI 密碼」中取得使用者鑑別記號並將其儲存至檔案。

    例如 registry-token.txt

  5. 建立檔案以儲存 RabbitMQ 密碼。
    例如 rabbitmq-pwd.txt。此密碼是在安裝時於 RabbitMQ 配置。
    註: 此密碼一旦配置後即無法變更。
  6. 識別要使用的儲存提供者。

    Azure 支援 azurefile,但如果要使用任何其他儲存提供者,請確保其支援 ReadWriteMany

  7. 執行 AppScan 360° SAST 指令碼,提供在本端部署叢集的選項。例如:
    > ./sast-service.sh --install 
                      --ingress-host <sast-ingress-fqdn> \
                      --server <ascp-fqdn> \
                      --cert AppScan360_RootCA.crt \
                      --cert-key AppScan360_RootCA.key \
                      --auth-token AgentsApiKey.txt \
                      --rabbitmq-password rabbitmq-pwd.txt \
                      --registry-user <harbor-username> \
                      --registry-token registry-token.txt \
                      --storage-class azurefile \
                      --ingress-class nginx
    註:
    • 提供指令碼檔案的執行權限。例如 chmod -R +x sast-service.sh scripts/*
    • 使用此選項 -f 指定 Yaml 檔案的檔案路徑,並如 部署配置參數 中所述自訂值。例如 -f values.yaml
  8. 確認部署作業已順利完成:
    > kubectl get pods -n <NAMESPACE>
    其中 <NAMESPACE> 是安裝 AppScan 360° SAST 的名稱空間。預設值是 hcl-appscan-sast
  9. 確認所有與 AppScan 360° SAST 相關的 Pod 都已啟動並執行如下操作:
    Pod 名稱 就緒 狀態 重新啟動 年齡
    analyzer-<pod-id> 1/1 執行中 X X
    ascp-adapter-<pod-id> 1/1 執行中 X X
    gateway-<pod-id> 1/1 執行中 X X
    preparer-<pod-id> 1/1 執行中 X X
    sast-service-rabbitmq-0 1/1 執行中 X X
    scan-manager-<pod-id> 1/1 執行中 X X
    workflow-manager--<pod-id> 1/1 執行中 X X
  10. 請確定 AppScan 360° SAST 可透過 URL https://<sast-ingress-fqdn> 從瀏覽器連線。

    (例如,https://sast.example.com

從保存檔部署 AppScan 360° 靜態分析

下載並解壓縮 tar.gz 檔案後:
  1. 若要將儲存器映像上傳至 ACR 或任何其他選擇的登錄,請使用下列參數選項,將登錄認證提供給部署指令碼:
    註: AppScan 360° SAST 儲存器映像檔必須上傳至遠端 OCI 合規登錄。
    • --registry <registry>:用於推送儲存器映像的登錄。例如:appscanregistry.azurecr.io, docker.io
    • --registry-user <registry-username>:用於鑑別的登錄使用者名稱。
    • --registry-token <registry-token-file>:包含登錄使用者鑑別記號的檔案。例如:--registry-token ./registry-token.txt
    • --load-images:此選項表示儲存器映像應從檔案系統載入至登錄檔。儲存器映像檔可位於路徑中 sast-service-base/images/*.image
  2. 請確保您連接到正確的 Kubernetes。

    驗證 .kube 資料夾中有正確的叢集配置檔。

  3. 取得 ASCP 伺服器的主機名稱。

    例如,ascp.example.com

  4. ASCP 伺服器擷取鑑別記號、憑證和私密金鑰檔案到目前的機器。
    • 可以使用 --auth-token 選項將鑑別記號指定至 AppScan 360° SAST 部署。例如 --auth-token AgentsApiKey.txt
    • 可以使用 --cert 選項將CA 憑證指定至 AppScan 360° SAST 部署。例如 --cert AppScan360_RootCA.crt
    • 可以使用 --cert-key 選項將私密金鑰指定至 AppScan 360° SAST 部署。例如 --cert-key AppScan360_RootCA.key
  5. 建立檔案以儲存 RabbitMQ 密碼。
    例如 rabbitmq-pwd.txt。此密碼是在安裝時於 RabbitMQ 配置。
    註: 此密碼一旦配置後即無法變更。
  6. 識別要使用的儲存提供者。

    Azure 支援 azurefile,但如果要使用任何其他儲存提供者,請確保其支援 ReadWriteMany

  7. 執行 AppScan 360° SAST 指令碼,提供在本端部署叢集的選項。例如:
    > ./sast-service.sh --install 
                        --ingress-host <sast-ingress-fqdn> \
                        --server <ascp-fqdn>
                        --cert AppScan360_RootCA.crt \
                        --cert-key AppScan360_RootCA.key \
                        --auth-token AgentsApiKey.txt \
                        --rabbitmq-password rabbitmq-pwd.txt \
                        --registry <registry-name> \
                        --registry-user <registry-username> \
                        --registry-token <registry-token-file> \
                        --storage-class azurefile \
                        --ingress-class nginx \
                        --load-images
    註: 使用此選項 -f 指定 Yaml 檔案的檔案路徑,並如 部署配置參數 中所述自訂值。例如 -f values.yaml
  8. 確認部署作業已順利完成:
    > kubectl get pods -n <NAMESPACE>
    其中 <NAMESPACE> 是安裝 AppScan 360° SAST 的名稱空間。預設的 hcl-appscan-sast
  9. 確認所有與 AppScan 360° SAST 相關的 Pod 都已啟動並執行如下操作:
    Pod 名稱 就緒 狀態 重新啟動 年齡
    analyzer-<pod-id> 1/1 執行中 X X
    ascp-adapter-<pod-id> 1/1 執行中 X X
    gateway-<pod-id> 1/1 執行中 X X
    preparer-<pod-id> 1/1 執行中 X X
    sast-service-rabbitmq-0 1/1 執行中 X X
    scan-manager-<pod-id> 1/1 執行中 X X
    workflow-manager--<pod-id> 1/1 執行中 X X
  10. 請確定 AppScan 360° SAST 可透過 URL https://<sast-ingress-fqdn> 從瀏覽器連線。

    (例如,https://sast.example.com)。

ASCP 整合

AppScan 360° 靜態分析 輸入 URL 必須在 ASCP 中配置,以成功在 AppScan 360° 元件之間整合。可在安裝或重新配置 ASCP 伺服器時配置 URL,或作為後置安裝步驟。

配置 AppScan 360° SAST 輸入

若要配置提供的輸入以使用 https,請使用 nginx.ingress.kubernetes.io/backend-protocol 註釋來指出 NGINX 應如何與後端服務通訊:

  • 參數
    global.ingress.additionalAnnotations
  • 說明

    輸入時要在 AppScan 360° 靜態分析 中配置的註釋清單。

  • 例子
    nginx.ingress.kubernetes.io/backend-protocol: HTTPS

重新配置 AppScan 360° 靜態分析

初始部署 AppScan 360° 靜態分析 後,後續使用部署指令碼時,會使用最新指定的部署選項來重新配置 Kubernetes 叢集。不需要先移除叢集。

若要確認部署指令碼正在重新配置現有的安裝,請檢查下列訊息的指令碼輸出訊息:
Namespace 'hcl-appscan-sast' already exists. The SAST deployment will be upgraded.
註: 在某些情況下,名稱空間可能會持續處於終止狀態,而叢集上沒有可用的部署。在此情況下,重新配置會失敗。手動刪除名稱空間並重新嘗試部署。

部署指令選項

參數 說明 預設值 必要
-h|-help 顯示可用指令和適當使用方式。
-i|--install 部署 AppScan 360° SAST。此旗標預期沒有選項值。 N/A
-s|--server hostname 提供 ASCP 伺服器的主機名稱 (FQDN)。ASCP 伺服器是配置為 AppScan 360° 平台安裝的一部分,也是使用者可以啟動 AppScan 360° 靜態分析 掃描的方法。
-cc|--cert cert-file-path 若要設定 TLS 和 HTTPS,請提供簽署憑證檔案的完整合格路徑。
-ck|--cert-key key-file-path 為指定的憑證提供私密金鑰的對應路徑。
-at|--auth-token token ASCP SAST 服務的連線授權。它也有助於 ASCP 平台服務與 ASCP 之間的通訊與交換。
-p |--rabbitmq-passwords pwd-file-path 指定 RabbitMQ 使用者密碼的檔案路徑。附註:配置後,RabbitMQ 密碼即無法變更。
-sc|--storage-class name 允許使用者將儲存裝置供應商配置為用於所有 AppScan 360° SAST 儲存需求。範例包括 local-pathazurefilelonghorn
-r |--registry registry 載入映像的登錄名稱。
註: 針對使用含有 SAST 映像的封存檔案進行雲端部署,必須提供可由雲端 K8S 登錄存取的登錄,以確保部署期間能進行映像提取。
  • -x 指定為映像載入時。
  • 使用封存部署進行部署時。
-ru|--registry-user username 提供的登錄使用者名稱。 是,僅當使用封存檔案部署至本端 Kubernetes 叢集(例如,K3S)時除外。
-rt--registry-token token-file-path 包含指定登錄之使用者鑑別記號的檔案路徑。
註: 憑證僅能基於安全理由使用檔案提供。
是,僅當使用封存檔案部署至本端 Kubernetes 叢集(例如,K3S)時除外。
-ro|-repo|--repository repository 用於尋找映像和 Helm 圖表的存放庫路徑。 appscan360-sast/sast-service
-v--version 要下載的 AppScan 360° SAST 版本。 預設為用於目前部署的指令碼版本。
-t--tag image-tag 要安裝的 AppScan 360° SAST 版本。未指定時,會使用存放庫或封存中的最新版本。 最新可用版本。
-n|--namespace 其中部署 AppScan 360° SAST 的名稱空間。 hcl-appscan-sast
-f|--config-file yaml-file-path 使用指定配置細節的 yaml 檔案來配置或自訂儲存器部署。如需配置 yaml 檔案的相關資訊,請參閱 部署配置參數 N/A
-ih|--ingress-host hostname

完整網域名稱 (FQDN),以存取 AppScan 360° SAST 後置部署。

如果提供的 FQDN 無法在 DNS 中解析,則確保「‘/etc/hosts」檔案已更新,以對映 FQDN 與個別的 IP 位址。

sast.example.com
-ic|--ingress-class name 輸入控制器是用來透過閘道服務曝光 AppScan 360° SAST。若未指定,則不會配置任何輸入控制器。
-x--load-images 從 FNO 下載封存時,此參數會指示要從檔案系統載入儲存器映像,並推送至指定的儲存器登錄。 此選項僅應用於氣隙模式部署。
-verbose 產生與主控台部署相關的完整訊息。

範例(X)

使用 HCL Harbor 中的 Helm 圖表進行雲端 (Azure) 部署:
> az login ...
> ./sast-service.sh --install \
                    --ingress-host test.sast.example.com \
                    --server test.ascp.example.com \
                    --cert ./AppScan360_RootCA.crt \
                    --cert-key ./AppScan360_RootCA.key \
                    --auth-token ./AgentsApiKey.txt \
                    --rabbitmq-password ./rabbitmq-pwd.txt \
                    --registry-user hcl-harbor-user \
                    --registry-token ./registry-token.txt \
                    --ingress-class nginx \
                    --storage-class azurefile
使用封存檔案進行雲端 (Azure) 部署:
> az login ...
> ./sast-service.sh --install \
                    --ingress-host test.sast.example.com \
                    --server test.ascp.example.com \
                    --cert ./AppScan360_RootCA.crt \
                    --cert-key ./AppScan360_RootCA.key \
                    --auth-token ./AgentsApiKey.txt \
                    --rabbitmq-password ./rabbitmq-pwd.txt \
                    --registry appscanregistry.azurecr.io \
                    --registry-user azure-user \
                    --registry-token ./registry-token.txt \
                    --ingress-class nginx \
                    --storage-class azurefile \
                    --load-images
使用 HCL Harbor 中的 Helm 圖表進行本端 Kubernetes 部署:
> ./sast-service.sh --install \
                    --ingress-host test.sast.example.com \
                    --server test.ascp.example.com \
                    --cert ./AppScan360_RootCA.crt \
                    --cert-key ./AppScan360_RootCA.key \
                    --auth-token ./AgentsApiKey.txt \
                    --rabbitmq-password ./rabbitmq-pwd.txt \
                    --registry-user hcl-harbor-user \
                    --registry-token ./registry-token.txt \
                    --ingress-class nginx \
                    --storage-class local-path
使用封存檔案進行本端 Kubernetes 部署:
> ./sast-service.sh --install \
                    --ingress-host test.sast.example.com \
                    --server test.ascp.example.com \
                    --cert ./AppScan360_RootCA.crt \
                    --cert-key ./AppScan360_RootCA.key \
                    --auth-token ./AgentsApiKey.txt \
                    --rabbitmq-password ./rabbitmq-pwd.txt \
                    --registry docker.io \
                    --ingress-class nginx \
                    --storage-class local-path \
                    --load-images

部署後存取 AppScan 360° SAST

成功部署後,AppScan 360° SAST 可使用 Swagger UI 存取 REST API:
> https://<appscan sast url>/swagger-ui/index.html
AppScan 360° SAST 使用在部署期間以選項 —auth-token 指定的記號型鑑別。記號可使用下列指令提取:
> kubectl get secrets -n hcl-appscan-sast sast-service-secret -o jsonpath="{.data.SAST_AUTH_TOKEN}" | base64 -d