Skip to content

IndexError when Grype "Identifiers" are blank #58

@ForkedProject10

Description

@ForkedProject10

Describe the bug
An IndexError is thrown when an SBOM is processed that contains an empty Identifiers set.

Steps to reproduce

Use SecScanner2JUnit utility to process SBOM from a scan that produced an empty set of Identifiers. For example:

        {
            "language": "",
            "category": "container_scanning",
            "message": "BIT-redis-2025-27151 in redis-7.4.3-0",
            "description": "Redis is an open source, in-memory database that persists on disk. In versions starting from 7.0.0 to before 8.0.2, a stack-based buffer overflow exists in redis-check-aof due to the use of memcpy with strlen(filepath) when copying a user-supplied file path into a fixed-size stack buffer. This allows an attacker to overflow the stack and potentially achieve code execution. This issue has been patched in version 8.0.2.",
            "cve": "BIT-redis-2025-27151",
            "severity": "Medium",
            "confidence": "Unknown",
            "remediateMetadata": {
                "package_name": "redis",
                "package_version": "7.4.3-0",
                "fixed_version": "8.0.2",
                "summary": "Upgrade redis to 8.0.2"
            },
            "solution": "Upgrade redis to 8.0.2",
            "scanner": {
                "id": "grype",
                "name": "grype"
            },
            "location": {
                "dependency": {
                    "package": {
                        "name": "redis"
                    },
                    "version": "7.4.3-0"
                },
                "operating_system": "",
                "image": ""
            },
            "identifiers": [],
            "links": [
                {
                    "url": "https://github.com/redis/redis/releases/tag/8.0.2"
                },
                {
                    "url": "https://github.com/redis/redis/security/advisories/GHSA-5453-q98w-cmvm"
                },
                {
                    "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-27151"
                }
            ]
        }

This throws an IndexError exception that reports the following:

Traceback (most recent call last):
  File "/usr/local/bin/ss2ju", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.12/site-packages/secscanner2junit/__init__.py", line 74, in main
    testsuite = parser.parse()
                ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/secscanner2junit/container_scanning.py", line 37, in parse
    testcases.append(self.parse_vulnerability(raw_vulnerability))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/secscanner2junit/container_scanning.py", line 19, in parse_vulnerability
    tc = TestCase(name=vulnerability.get_testcase_name(),
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/secscanner2junit/vulnerability.py", line 78, in get_testcase_name
    return self.__identifiers[0].get_name() + id_part + severity_part
           ~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Expected behavior
ss2ju properly handles null identifiers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions