0

要在 SoftLayer 上生成/启动新的漏洞扫描,这有效(对于帐户中的每个服务器):

    require_once('SoapClient.class.php');
    $apiUsername = "omitted";
    $apiKey = "omitted";

    $client = SoftLayer_SoapClient::getClient('SoftLayer_Account', null, $apiUsername, $apiKey);

    $accountInfo = $client->getObject();
    $hardware = $client->getHardware();

    foreach ($hardware as $server){
        $scanclient = SoftLayer_SoapClient::getClient('SoftLayer_Network_Security_Scanner_Request', '', $apiUsername, $apiKey);

        $scantemplate = new stdClass();
        $scantemplate->accountId = $accountInfo->id;
        $scantemplate->hardwareId = $server->id;
        $scantemplate->ipAddress = $server->primaryIpAddress;
        try{
                // Successfully creates new scan
                $scan = $scanclient->createObject($scantemplate);
        } catch (Exception $e){
                echo $e->getMessage() . "\n\r";
        }
    }

换的时候

$reportstatus = $scanclient->createObject($scantemplate);

$reportstatus = $scanclient->getReport($scantemplate);

API 以有关“对象不存在执行方法”的错误响应。

根据文档,是否需要 SoftLayer_Network_Security_Scanner_RequestInitParameters?如果是这样,您如何定义这些“初始化参数”并附加到状态或报告请求?

http://sldn.softlayer.com/reference/services/SoftLayer_Network_Security_Scanner_Request/getReport

4

1 回答 1

1

您需要使用 Softlayer PHP 客户端设置 init 参数,您可以这样做:

创建客户端时:

$virtualGuestService = SoftLayer_SoapClient::getClient('SoftLayer_Virtual_Guest', $initParemter, $username, $key);

或者在创建客户端之后:

$virtualGuestService = SoftLayer_SoapClient::getClient('SoftLayer_Virtual_Guest', null, $username, $key);
# Setting the init parameter
$virtualGuestService->setInitParameter($virtualGuestId);

init 参数基本上是您希望编辑或删除的对象的 id,在这种情况下,init 参数是您希望获取报告的漏洞扫描的 id。

你可以试试这段代码:

$scanclient = SoftLayer_SoapClient::getClient('SoftLayer_Network_Security_Scanner_Request', '', $apiUsername, $apiKey);
$scanclient->setInitParameter(15326); # The id of the vulnerability scan
$reportstatus = $scanclient->getReport();

要获取 VSI 中的漏洞扫描列表,您可以使用此方法 : http ://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getSecurityScanRequests ,对于裸机服务器,您可以使用此方法: http://sldn .softlayer.com/reference/services/SoftLayer_Hardware_Server/getSecurityScanRequests

问候

于 2015-11-17T19:13:33.213 回答