SoftLayer API Nessus Scan Status / Report via PHP

╄→尐↘猪︶ㄣ 提交于 2019-12-11 19:46:09

问题


To generate/initiate a new vulnerability scan at SoftLayer, this works (for every server in an account):

    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";
        }
    }

When changing

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

to

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

The API responds with an error concerning "Object does not exist to execute method on.".

Would SoftLayer_Network_Security_Scanner_RequestInitParameters be required as per the docs? If so how do you define these "init parameters" and attach to the request for status or report?

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


回答1:


You need to set the init parameter using the Softlayer PHP client you can do that like this:

When you are creating the client:

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

Or after creating the client:

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

The init parameter is basically the id of the object you wish to get edit or delete, in this case the init parameter is the id of the vulnerability scan you wish to get the report.

You can try this code:

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

To get the list of your vulnerabilities scans in a VSI you can use this method: http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getSecurityScanRequests and for bare metal servers you can use this one: http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/getSecurityScanRequests

Regards



来源:https://stackoverflow.com/questions/33764302/softlayer-api-nessus-scan-status-report-via-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!