'Converts a record from version 7 to version 8. Version 8 fixes the
structured output for scripts using the vulns NSE library.'

@staticmethod
def __migrate_schema_hosts_7_8(doc):

    assert (doc['schema_version'] == 7)
    doc['schema_version'] = 8
    for port in doc.get('ports', []):
        for script in port.get('scripts', []):
            if ('vulns' in script):
                if any(((elt in script['vulns']) for elt in ['ids', 'refs', 'description', 'state', 'title'])):
                    script['vulns'] = [script['vulns']]
                else:
                    script['vulns'] = [dict(tab, id=vulnid) for (vulnid, tab) in viewitems(script['vulns'])]
