簡體   English   中英

SoftLayer API Nessus掃描狀態/通過python報告

[英]SoftLayer API Nessus Scan Status / Report via python

我想使用python客戶端創建一個Nessus安全掃描器,並通過getStatus檢查狀態並通過getReport方法獲取結果。 同時,我通過php( SoftLayer API Nessus掃描狀態/通過PHP報告 )閱讀了這些幫助。 但是我如何通過python客戶端使用它們呢? 當我通過python調用setInitParameter(scan_id)時,異常如下:SoftLayerAPIError(Client):Function(“ setInitParameter”)不是此服務的有效方法

我建議您先閱讀客戶端的文檔:

https://github.com/softlayer/softlayer-python https://softlayer-api-python-client.readthedocs.io/en/latest/

初始化參數設置如下:

clientService.getObject(id=myInitParameter)

在這里您可以找到使用客戶端的更多示例:

https://softlayer.github.io/python/

在這里您可以找到其他文檔:

http://sldn.softlayer.com/blog

並重申與Softlayer的python客戶端不同,Softlayer的python客戶端數據以json格式發送,因此請求:

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

會是這樣的:

clientAccount = client['SoftLayer_Account']
accountInfo = clientAccount.getObject()   #for this case we do not need init parameter
hardware = clientAccount.getHardware()    #for this case we do not need init parameter

for server in hardware:

    scanclient = client['SoftLayer_Network_Security_Scanner_Request']

    scantemplate = {
       "accountId": accountInfo["id"],
       "hardwareId": server["id"],
      "ipAddress": server["primaryIpAddress"]
   }

   scanclient.createObject(scantemplate) 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM