Submitting Virus Detection Job

Last updated: 2023-09-13 11:29:07

Feature Overview

This document provides an overview of APIs and SDK code samples for cloud-based malware scanning interfaces.
Note
COS PHP SDK v2.5.0 or higher is required. Older versions may contain bugs; it is recommended to upgrade to the latest version when using.
API
Description
Submitting a virus detection job
Queries the status or result of a virus detection job

Submitting Virus Detection Job

Note

Submitting a virus detection job.

Method prototype

public Guzzle\Service\Resource\Model detectVirus(array $args = array());

Sample Request

Example 1: Scanning files in a bucket for malware

<?php

require dirname(__FILE__) . '/../vendor/autoload.php';

$secretId = "SECRETID"; //Replace it with the actual <1>SecretId</1>, which can be viewed and managed in the CAM console at https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //Replace it with the actual <1>SecretKey</1>, which can be viewed and managed in the CAM console at https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //Replace it with the actual <1>region</1>, which can be viewed in the console at https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'schema' => 'https', // Must be https for moderation
'credentials'=> array(
'secretId' => $secretId ,
'secretKey' => $secretKey)));

try {
// Scanning files in the storage bucket for malware
$result = $cosClient->detectVirus(array(
'Bucket' => 'examplebucket-1250000000', // Bucket name, composed of BucketName-Appid, can be viewed in the COS console at https://console.cloud.tencent.com/cos5/bucket
'Input' => array(
'Object' => 'test01.exe'
),
'Conf' => array(
'DetectType' => 'Virus',
// 'Callback' => '',
),
));
// Request successful
print_r($result);
} catch (\Exception $e) {
// Request failed
echo($e);
}

Example 2: URL Malware Detection

<?php

require dirname(__FILE__) . '/../vendor/autoload.php';

$secretId = "SECRETID"; //Replace it with the actual <1>SecretId</1>, which can be viewed and managed in the CAM console at https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //Replace it with the actual <1>SecretKey</1>, which can be viewed and managed in the CAM console at https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //Replace it with the actual <1>region</1>, which can be viewed in the console at https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'schema' => 'https', // Must be https for moderation
'credentials'=> array(
'secretId' => $secretId ,
'secretKey' => $secretKey)));

try {
// URL Malware Scanning
$result = $cosClient->detectVirus(array(
'Bucket' => 'examplebucket-125000000', // Bucket name, composed of BucketName-Appid, can be viewed in the COS console at https://console.cloud.tencent.com/cos5/bucket
'Input' => array(
'Url' => 'https://example.com/test01.exe',
),
'Conf' => array(
'DetectType' => 'Virus',
// 'Callback' => '',
),
));
// Request successful
print_r($result);
} catch (\Exception $e) {
// Request failed
echo($e);
}

Description

Request has the following sub-nodes:
Parameter name
Local Disk Types
Description
Required
Bucket
String
Bucket name in the format of BucketName-APPID
Required
Conf
Array
Operation rule
Required
Input
Array
Information of the file to be scanned
Required
The specific data description in Conf is as follows:
Parameter name
Local Disk Types
Description
Required
DetectType
String
Virus detection type, which is fixed at Virus currently.
Required
Callback
String
Callback URL, starting with either http:// or https://
Not required

Querying virus detection job result

Note

This API is used to query the status or result of a virus detection task.

Method prototype

public Guzzle\Service\Resource\Model getDetectVirusResult(array $args = array());

Sample Request

<?php

require dirname(__FILE__) . '/../vendor/autoload.php';

$secretId = "SECRETID"; //Replace it with the actual <1>SecretId</1>, which can be viewed and managed in the CAM console at https://console.cloud.tencent.com/cam/capi
$secretKey = "SECRETKEY"; //Replace it with the actual <1>SecretKey</1>, which can be viewed and managed in the CAM console at https://console.cloud.tencent.com/cam/capi
$region = "ap-beijing"; //Replace it with the actual <1>region</1>, which can be viewed in the console at https://console.cloud.tencent.com/cos5/bucket
$cosClient = new Qcloud\Cos\Client(
array(
'region' => $region,
'schema' => 'https', // Must be https for moderation
'credentials'=> array(
'secretId' => $secretId ,
'secretKey' => $secretKey)));

try {
$result = $cosClient->getDetectVirusResult(array(
'Bucket' => 'examplebucket-1250000000', // Bucket name, composed of BucketName-Appid, can be viewed in the COS console at https://console.cloud.tencent.com/cos5/bucket
'Key' => 'examplejobid', // JobId
));
// Request successful
print_r($result);
} catch (\Exception $e) {
// Request failed
echo($e);
}

Description

Parameter name
Local Disk Types
Description
Required
Bucket
String
Bucket name in the format of BucketName-APPID
Required
Key
String
ID of the job to be queried
Required