SoftLayer API Nessus通过PHP扫描状态/报告

时间:2015-11-17 18:23:59

标签: php api security ibm-cloud-infrastructure nessus

要在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?如果是这样,您如何定义这些“init参数”并附加到状态或报告请求?

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

1 个答案:

答案 0 :(得分: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

此致