檢視次數:

使用 TrendAI Vision One™ File Security Java SDK 掃瞄檔案以檢測惡意程式。

Java SDK for TrendAI Vision One™™ File Security 讓您能夠輕鬆打造應用程式,無縫整合 File Security。使用此 SDK,您可以對應用程式中的資料和檔案進行全面掃瞄,以識別潛在的惡意元素。
請按照以下步驟設置您的開發環境並配置您的項目,為有效使用文件安全奠定基礎。

檢查先決條件 上層主題

在安裝 SDK 之前,請確保您具備以下條件:

建立 API 金鑰 上層主題

File Security SDK 需要提供有效的 API 金鑰作為 SDK 客戶端物件的參數。TrendAI Vision One™ API 金鑰與不同的區域相關聯。請參閱下方的區域標誌以更好地了解與 API 金鑰相關的有效區域。

步驟

  1. 前往AdministrationsAPI Keys
  2. 點選Add API Key
  3. 配置 API 金鑰以使用具有Run file scan via SDK權限的角色。
  4. 驗證 API 金鑰是否與您計劃使用的區域相關聯。
  5. 為 API 金鑰設置過期時間並記錄以供將來參考。

安裝 SDK 上層主題

步驟

  • Maven Central Repository 下載 jar。
  • 對於 Maven,將以下依賴項添加到 pom.xml
    <dependency>
      <groupId>com.trend</groupId>
      <artifactId>file-security-java-sdk</artifactId>
      <version>1.0.0</version>
    </dependency>

使用檔案安全性 Java SDK 上層主題

步驟

  1. 通過指定您的TrendAI Vision One™區域和有效的API 金鑰來創建客戶端物件。
  2. 啟動檔案掃瞄或緩衝區掃瞄以掃瞄目標資料防護。
    以下是一個說明如何使用 SDK 的 Java 程式碼範例。
    import com.trend.cloudone.amaas.AMaasClient;
    
    public static void main(String[] args) {
        try {
            // 1. Create an AMaaS Client object and configure it to carry out the scans in Vision One "us-east-1" region.
            AMaasClient client = new AMaasClient("us-east-1", "your-api-key");
    
            // 2. Call ScanFile() to scan the content of a file.
            String scanResult = client.scanFile(""path-of-file-to-scan"");
    
            if (scanResult != null) {
                // 3. Print out the JSON response from ScanFile()
                System.out.println("scan result " + scanResult);
            }
        } catch (AMaasException err) {
            info("Exception {0}", err.getMessage());
        }
    }
  3. 解析掃瞄 API 返回的 JavaScript 物件標記 (JSON) 回應,以判斷掃瞄的資料是否包含惡意程式。當在掃瞄的物件中檢測到惡意內容時,scanResult 會顯示一個值,並且 foundMalwares 會包含檔案名稱和惡意程式的名稱。
    以下是一個範例 JSON 回應。
    {
      "version": "1.0",
      "scanId": "25072030425f4f4d68953177d0628d0b",
      "scanResult": 1,
      "scanTimestamp": "2022-11-02T00:55:31Z",
      "fileName": "EICAR_TEST_FILE-1.exe",
      "filePath": "AmspBvtTestSamples/BVT_RightClickScan_DS/unclean/EICAR_TEST_FILE-1.exe",
      "foundMalwares": [
        {     
          "fileName": "Eicar.exe",
          "malwareName": "Eicar_test_file"
        }
      ]
    }

    JSON 回應

    回應代碼 偵測到惡意程式 未檢測到
    掃描結果
    非零
    null
    發現的惡意軟體 fileNamemalwareName null