Skip to content

Commit

Permalink
fix: list of available language parsers (fixes #4334) (#4336)
Browse files Browse the repository at this point in the history
* fixes #4334  
* fixes #4328
  • Loading branch information
anthonyharrison authored Aug 12, 2024
1 parent a1c7226 commit cadd5b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 13 additions & 0 deletions cve_bin_tool/parsers/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ def load_valid_files() -> dict[str, list[type[Parser]]]:
valid_files = load_valid_files()


def identify_parsers() -> list:
"""Reports names of parsers"""
parsers = []
for i in BUILTIN_PARSERS.items():
parser = i[0].split(".")[0]
if parser not in parsers:
parsers.append(parser)
return parsers


available_parsers = identify_parsers()


def parse(filename, output, cve_db, logger):
"""
Parses the given filename using the appropriate parser.
Expand Down
5 changes: 2 additions & 3 deletions cve_bin_tool/version_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# SPDX-License-Identifier: GPL-3.0-or-later
from __future__ import annotations

import itertools
import subprocess
import sys
from logging import Logger
Expand All @@ -16,7 +15,7 @@
from cve_bin_tool.extractor import Extractor, TempDirExtractorContext
from cve_bin_tool.file import is_binary
from cve_bin_tool.log import LOGGER
from cve_bin_tool.parsers.parse import parse, valid_files
from cve_bin_tool.parsers.parse import available_parsers, parse, valid_files
from cve_bin_tool.strings import parse_strings
from cve_bin_tool.util import (
DirWalk,
Expand Down Expand Up @@ -137,7 +136,7 @@ def number_of_checkers(self) -> int:
@classmethod
def available_language_checkers(cls) -> list[str]:
"""Find Language checkers"""
return list(sorted(map(str, set(itertools.chain(*valid_files.values())))))
return sorted(available_parsers)

def print_language_checkers(self) -> None:
"""Logs the message that lists the names of the language checkers"""
Expand Down

0 comments on commit cadd5b6

Please sign in to comment.