Description
The cyclonedx.parser module has been removed in the latest version of the CycloneDX library.
Impact
Projects using the cyclonedx.parser module will no longer be able to import it, leading to import errors and potential breakage in the build process or application functionality.
Steps to Reproduce
Attempt to import the cyclonedx.parser module in a Python script:
from cyclonedx import parser
This will result in an ImportError.
Suggested Solutions
- Replace with New API: Please consider replacing the deprecated
cyclonedx.parser with the new API provided by the CycloneDX library. Check the latest documentation for the updated API usage.
- Alternative Implementation: As an alternative, you can use the following code snippet to parse BOMs using the CycloneDX model classes.
import sqlite3
import os
from typing import List
from cyclonedx import output
from cyclonedx.model import ExternalReference, ExternalReferenceType, HashType
from cyclonedx.model.bom import Bom
from cyclonedx.model.component import Component
from cyclonedx.model.vulnerability import Vulnerability, VulnerabilitySeverity, VulnerabilityRating
class ParserWarning:
_item: str
_warning: str
def __init__(self, item: str, warning: str) -> None:
self._item = item
self._warning = warning
def get_item(self) -> str:
return self._item
def get_warning_message(self) -> str:
return self._warning
def __repr__(self) -> str:
return f'<ParserWarning item={self._item!r} warning={self._warning!r}>'
class BaseParser:
_components: List[Component] = []
_warnings: List[ParserWarning] = []
def __init__(self) -> None:
self._components.clear()
self._warnings.clear()
def component_count(self) -> int:
return len(self._components)
def get_components(self) -> List[Component]:
return self._components
def get_warnings(self) -> List[ParserWarning]:
return self._warnings
def has_warnings(self) -> bool:
return len(self._warnings) > 0
Additional Information
Description
The
cyclonedx.parsermodule has been removed in the latest version of the CycloneDX library.Impact
Projects using the
cyclonedx.parsermodule will no longer be able to import it, leading to import errors and potential breakage in the build process or application functionality.Steps to Reproduce
Attempt to import the
cyclonedx.parsermodule in a Python script:This will result in an ImportError.
Suggested Solutions
cyclonedx.parserwith the new API provided by the CycloneDX library. Check the latest documentation for the updated API usage.Additional Information