首页 文章

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

提问于
浏览
0

我想使用python客户端创建Nessus Security Scanner并通过getStatus检查状态,并通过getReport方法获取结果 . 虽然,我已经通过php(SoftLayer API Nessus Scan Status / Report via PHP)阅读了这些帮助 . 但是如何通过python客户端使用这些?当我通过python调用setInitParameter(scan_id)时,异常如flow:SoftLayerAPIError(Client):Function("setInitParameter")不是此服务的有效方法

1 回答

  • 0

    我建议你先阅读客户的文档:

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

    init参数设置如下:

    clientService.getObject(id=myInitParameter)
    

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

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

    在这里您可以找到其他文档:

    http://sldn.softlayer.com/blog

    并重新说明,与Softlayer的python客户端不同,php客户端数据以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)
    

相关问题