Skip to content

Commit

Permalink
fix: typing broke some use cases
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Horton <paul.horton@owasp.org>
  • Loading branch information
madpah committed Jul 13, 2022
1 parent b0bafcf commit c766507
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions vexy/parser/cyclonedx.py
Expand Up @@ -25,7 +25,7 @@
import json
import keyword
from datetime import datetime
from typing import Any, Dict, Set
from typing import cast, Any, Dict, Set
from xml.dom.minidom import Element, Text, parseString

from cyclonedx.model.bom import Bom
Expand Down Expand Up @@ -117,10 +117,10 @@ def _component_from_json(json_data: Dict[str, Any]) -> Component:
def _component_from_xml(xml_element: Element) -> Component:
jd = {}
for e in xml_element.childNodes:
if isinstance(e, Element) and isinstance(e, Text):
if isinstance(e, Element):
if e.nodeName == 'purl':
jd.update({e.nodeName: PackageURL.from_string(purl=str(e.firstChild.data).strip())})
jd.update({e.nodeName: PackageURL.from_string(purl=str(cast(Text, e.firstChild).data).strip())})
elif e.nodeName not in _XML_IGNORE_KEYS:
jd.update({e.nodeName: str(e.firstChild.data).strip()})
jd.update({e.nodeName: str(cast(Text, e.firstChild)..data).strip()})

return Component(**jd)

0 comments on commit c766507

Please sign in to comment.