diff --git a/cve_bin_tool/version_scanner.py b/cve_bin_tool/version_scanner.py index 860921beae..96f0365c2c 100644 --- a/cve_bin_tool/version_scanner.py +++ b/cve_bin_tool/version_scanner.py @@ -234,13 +234,13 @@ def run_java_checker(self, filename: str) -> Iterator[ScanInfo]: if parent is None: product = root.find(schema + "artifactId").text version = root.find(schema + "version").text - if version is None: + if version is None and parent is not None: version = parent.find(schema + "version").text # Check valid version identifier (i.e. starts with a digit) if not version[0].isdigit(): self.logger.debug(f"Invalid {version} detected in {filename}") version = None - if product is None: + if product is None and parent is not None: product = parent.find(schema + "artifactId").text if product is not None and version is not None: product_info, file_path = self.find_java_vendor(product, version)