【问题标题】:SoftLayer API Nessus Scan Status / Report via pythonSoftLayer API Nessus 扫描状态/通过 python 报告
【发布时间】:2017-09-02 20:36:26
【问题描述】:

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

【问题讨论】:

  • 啊哈,我可以通过直接设置参数 id = scan_id 来将 id 设置为 getStatus 或 getReport 方法。
  • 客户端['SoftLayer_Network_Security_Scanner_Request'].getStatus(id=15326); # 漏洞扫描的id

标签: python api ibm-cloud-infrastructure


【解决方案1】:

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

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 客户端与 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) 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多