vdb/lib/utils.py
def convert_to_occurrence(datas):
    """Method to parse raw search result and convert to Vulnerability occurence

    :param datas: Search results from database
    :return List of vulnerability occurence
    """
    data_list = []
    id_list = []
    for d in datas:
        vobj = load(d)
        vdetails = vobj["details"]
        package_type = ""
        package = ""
        cpe_uri = ""
        if isinstance(vdetails, dict):
            package_type = vdetails["package_type"]
            package = vdetails["package"]
            cpe_uri = vdetails["cpe_uri"]
        else:
            package_type = vdetails.package_type
            package = vdetails.package
            cpe_uri = vdetails.cpe_uri
        unique_key = vobj["id"] + "|" + package
        # Filter duplicates for the same package with the same id
        if unique_key not in id_list:
            occ = VulnerabilityOccurrence(
                id=vobj["id"],
                problem_type=vobj["problem_type"],
                type=package_type,
                severity=vobj["severity"],
                cvss_score=vobj["score"],
                package_issue=PackageIssue(
                    affected_location=cpe_uri,
                    fixed_location=vdetails.fixed_location,
                    min_affected_version_including=vdetails.min_affected_version_including,
                    max_affected_version_including=vdetails.max_affected_version_including,
                    min_affected_version_excluding=vdetails.min_affected_version_excluding,
                    max_affected_version_excluding=vdetails.max_affected_version_excluding,
                ),
                short_description=vobj["description"],
                long_description=None,
                related_urls=vobj["related_urls"],
                effective_severity=vobj["severity"],
            )
            id_list.append(unique_key)
            data_list.append(occ)
    return data_list
Method to parse raw search result and convert to Vulnerability occurence

    :param datas: Search results from database
    :return List of vulnerability occurence
    
Method to parse raw search result and convert to Vulnerability occurence
:param datas: Search results from database
:return List of vulnerability occurence
Method to parse raw search result and convert to Vulnerability occurence : param datas : Search results from database : return List of vulnerability occurence
def convert_to_occurrence(datas):
    data_list = []
    id_list = []
    for d in datas:
        vobj = load(d)
        vdetails = vobj["details"]
        package_type = ""
        package = ""
        cpe_uri = ""
        if isinstance(vdetails, dict):
            package_type = vdetails["package_type"]
            package = vdetails["package"]
            cpe_uri = vdetails["cpe_uri"]
        else:
            package_type = vdetails.package_type
            package = vdetails.package
            cpe_uri = vdetails.cpe_uri
        unique_key = vobj["id"] + "|" + package
        if unique_key not in id_list:
            occ = VulnerabilityOccurrence(
                id=vobj["id"],
                problem_type=vobj["problem_type"],
                type=package_type,
                severity=vobj["severity"],
                cvss_score=vobj["score"],
                package_issue=PackageIssue(
                    affected_location=cpe_uri,
                    fixed_location=vdetails.fixed_location,
                    min_affected_version_including=vdetails.min_affected_version_including,
                    max_affected_version_including=vdetails.max_affected_version_including,
                    min_affected_version_excluding=vdetails.min_affected_version_excluding,
                    max_affected_version_excluding=vdetails.max_affected_version_excluding,
                ),
                short_description=vobj["description"],
                long_description=None,
                related_urls=vobj["related_urls"],
                effective_severity=vobj["severity"],
            )
            id_list.append(unique_key)
            data_list.append(occ)
    return data_list
def convert_to_occurrence ( datas ) : data_list = [ ] id_list = [ ] for d in datas : vobj = load ( d ) vdetails = vobj [ "details" ] package_type = "" package = "" cpe_uri = "" if isinstance ( vdetails , dict ) : package_type = vdetails [ "package_type" ] package = vdetails [ "package" ] cpe_uri = vdetails [ "cpe_uri" ] else : package_type = vdetails . package_type package = vdetails . package cpe_uri = vdetails . cpe_uri unique_key = vobj [ "id" ] + "|" + package if unique_key not in id_list : occ = VulnerabilityOccurrence ( id = vobj [ "id" ] , problem_type = vobj [ "problem_type" ] , type = package_type , severity = vobj [ "severity" ] , cvss_score = vobj [ "score" ] , package_issue = PackageIssue ( affected_location = cpe_uri , fixed_location = vdetails . fixed_location , min_affected_version_including = vdetails . min_affected_version_including , max_affected_version_including = vdetails . max_affected_version_including , min_affected_version_excluding = vdetails . min_affected_version_excluding , max_affected_version_excluding = vdetails . max_affected_version_excluding , ) , short_description = vobj [ "description" ] , long_description = None , related_urls = vobj [ "related_urls" ] , effective_severity = vobj [ "severity" ] , ) id_list . append ( unique_key ) data_list . append ( occ ) return data_list
Method to parse raw search result and convert to Vulnerability occurence
:param datas: Search results from database
:return List of vulnerability occurence
Method to parse raw search result and convert to Vulnerability occurence : param datas : Search results from database : return List of vulnerability occurence
"""Method to parse raw search result and convert to Vulnerability occurence

    :param datas: Search results from database
    :return List of vulnerability occurence
    """ # Filter duplicates for the same package with the same id
datas