[Python] 'str' object has no attribute 'items' - but why

Discussão em 'Python' iniciado por Stack, Maio 9, 2025.

  1. Stack

    Stack Membro Participativo

    So I am perplexed, I have this function:

    def generateCriticalHigh():
    build_dir2 = "LEFT_TO_RIGHT"
    table_attr2 = {"style" : "width:100%", "class" : "table table-striped"}

    f = open(rawjson,'r')
    json_object_partial = json.load(f)

    important_vulnerabilities = [vulnerability
    for result in json_object_partial.get("results", [])
    for vulnerability in result.get("vulnerabilities", [])
    if vulnerability.get("severity") in ["critical", "high"]
    ]

    json_output = json.dumps(important_vulnerabilities, cls=ListOfListsEncoder)
    print("json_output is: {}".format(json_output))
    table_attr = {"style" : "width:100%", "class" : "table table-striped"}
    highandcriticalhtml = convert(json_output, build_direction=build_dir2, table_attributes=table_attr2)


    above json_output outputs subset:

    json_output is: "id": "CVE-2023-42282", "status": "fixed in 1.1.9, 2.0.1", "cvss": 9.8, "vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "description": "The ip package before 1.1.9 for Node.js might allow SSRF because some IP addresses (such as 0x7f.1) are improperly categorized as globally routable via isPublic.", "severity": "critical", "packageName": "ip"],


    the problem is, after this output it states: AttributeError: 'str' object has no attribute 'items' . Its pointing at line: convert(json_output, build_direction=build_dir2, table_attributes=table_attr2)

    What might I be doing wrong here? Im using json2html here: https://github.com/latture/json2table

    Thank you.

    Continue reading...

Compartilhe esta Página