pythonhtmlibm-cloudibm-cloud-infrastructure

Conversion of HTML string to HTML page of report Nessus security scanner


When I run this command I get an HTML string:

report = client['SoftLayer_Network_Security_Scanner_Request'].getReport(id=19133434)

I wrote this data into .html file using Python. However, when I open the file through the browser some of the HTML features are not available. Could someone help me out with this?

Html code

u'<html xmlns="w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta><title>Nessus Scan Report</title><style type="text/css" media="all">\n\tUL.ulist {padding: 0 10px; line-height:25px; margin-bottom:0px; margin-top:0px;};\n\tLI.list {padding: 0 10px; line-height:25px; margin-bottom:0px; margin-top:0px; list-style: disc;}\n\tLI.list0 {padding: 0 10px; line-height:25px; margin-bottom:0px; margin-top:0px; list-style: disc; color:#357abd;}\n\tLI.list1 {padding: 0 10px; line-height:25px; margin-bottom:0px; margin-top:0px; l .....</html>

Solution

  • Try with this script:

    """
    Get Report
    Get the vulnerability report for a scan request.
    
    Important manual pages:
    http://sldn.softlayer.com/reference/services/SoftLayer_Network_Security_Scanner_Request/getReport
    
    License: http://sldn.softlayer.com/article/License
    Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
    """
    import webbrowser
    import SoftLayer
    
    # Your SoftLayer API username and key.
    USERNAME = 'set me'
    API_KEY = 'set me'
    
    # define the file's name
    file = 'report.html'
    
    # Create client
    client = SoftLayer.Client(username=USERNAME, api_key=API_KEY)
    requestService = client['SoftLayer_Network_Security_Scanner_Request']
    
    f = open(file, 'w')
    try:
        report = requestService.getReport(id=19133434)
        f.write(report)
        f.close()
        webbrowser.open_new_tab(file)
    except SoftLayer.SoftLayerAPIError as e:
        print("Unable to get report. faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))
    

    Let me know your results or if you continue having issues

    References: