From 2b5eb4d0e8d27522832449ea16c114b10eac5cef Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 22 Jan 2024 11:11:30 +0100 Subject: [PATCH 01/13] run tests for all python version --- .github/workflows/pytest.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 430c6f0..91133ad 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -18,39 +18,43 @@ on: jobs: tests: runs-on: ubuntu-latest + strategy: + matrix: + python: ${{fromJSON('["3.8", "3.9", "3.10", "3.11", "3.12"]') }} + steps: - uses: actions/checkout@v1 - - name: Set up Python 3.8 + - name: Set up Python ${{ matrix.python }} uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: ${{ matrix.python }} # Used by ci_test.sh - - name: Install dependencies + - name: Install dependencies in ${{ matrix.python }} run: | python setup.py install pip install pytest pip install pytest-cov - - name: Run Parsing tests + - name: Run Parsing tests in ${{ matrix.python }} run: | pytest tests/test_parsing.py tests/test_versions.py --cov=tealer/teal/instructions --cov-branch --cov-fail-under=96 - - name: Run string tests + - name: Run string tests in ${{ matrix.python }} run: | pytest tests/test_string_representation.py - - name: Run version tests + - name: Run version tests in ${{ matrix.python }} run: | pytest tests/test_versions.py pytest tests/test_mode_detector.py - - name: Run cfg recovery tests + - name: Run cfg recovery tests in ${{ matrix.python }} run: | pytest tests/test_cfg.py - - name: Run detectors tests + - name: Run detectors tests in ${{ matrix.python }} run: | pytest tests/test_detectors.py From 64cb07992f56ee27b7869eb5a01f20b7b05210b5 Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 22 Jan 2024 11:25:06 +0100 Subject: [PATCH 02/13] Follow PEP 517/518 (move install to pyproject.toml) --- pyproject.toml | 29 +++++++++++++++++++++++++++++ setup.py | 28 ++-------------------------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 707f9b3..74282cd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,32 @@ +[build-system] +requires = ["setuptools>=42", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "tealer" +version = "0.1.1" +description = "Teal analyzer." +readme = "README.md" +authors = [{name = "Trail of Bits"}] +license = "AGPL-3.0" +requires-python = ">=3.8" +dependencies = [ + "prettytable>=0.7.2", + "py-algorand-sdk", + "pycryptodomex", + "requests", + "pyyaml", +] + +[project.optional-dependencies] +dev = ["pylint==2.13.4", "black==22.3.0", "mypy==0.942", "pytest-cov"] + +[project.urls] +homepage = "https://github.com/crytic/tealer" + +[project.scripts] +tealer = "tealer.__main__:main" + [tool.black] target-version = ["py36"] line-length = 100 diff --git a/setup.py b/setup.py index 4cc5083..c1057cf 100644 --- a/setup.py +++ b/setup.py @@ -1,27 +1,3 @@ -from setuptools import setup, find_packages +import setuptools -with open("README.md", encoding="utf-8") as f: - long_description = f.read() - -setup( - name="tealer", - description="Teal analyzer.", - url="https://github.com/crytic/tealer", - author="Trail of Bits", - version="0.1.1", - packages=find_packages(), - python_requires=">=3.8", - install_requires=[ - "prettytable>=0.7.2", - "py-algorand-sdk", - "pycryptodomex", - "requests", - "pyyaml", - "setuptools", - ], - extras_require={"dev": ["pylint==2.13.4", "black==22.3.0", "mypy==0.942", "pytest-cov"]}, - license="AGPL-3.0", - long_description=long_description, - long_description_content_type="text/markdown", - entry_points={"console_scripts": ["tealer = tealer.__main__:main"]}, -) +setuptools.setup() \ No newline at end of file From bee5566683d88ecad9b5e652b4d7acb7070fb3d1 Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 22 Jan 2024 11:45:22 +0100 Subject: [PATCH 03/13] Improvements --- .github/workflows/pytest.yml | 2 +- .github/workflows/pytest310.yml | 2 +- .github/workflows/tests.yml | 2 +- pyproject.toml | 20 +++++++++++++------- setup.py | 3 --- 5 files changed, 16 insertions(+), 13 deletions(-) delete mode 100644 setup.py diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 91133ad..7f3ba56 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -33,7 +33,7 @@ jobs: # Used by ci_test.sh - name: Install dependencies in ${{ matrix.python }} run: | - python setup.py install + pip install . pip install pytest pip install pytest-cov diff --git a/.github/workflows/pytest310.yml b/.github/workflows/pytest310.yml index a632eb6..b19f477 100644 --- a/.github/workflows/pytest310.yml +++ b/.github/workflows/pytest310.yml @@ -29,7 +29,7 @@ jobs: # Used by ci_test.sh - name: Install dependencies run: | - python setup.py install + pip install . pip install pytest pip install pytest-cov pip install pyteal==0.22.0 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fe4c0ea..4e36755 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,7 +29,7 @@ jobs: # Used by ci_test.sh - name: Install dependencies run: | - python setup.py install + pip install . - name: Run Tests run: | bash scripts/test_algorand_contracts.sh diff --git a/pyproject.toml b/pyproject.toml index 74282cd..a1b65b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,14 +1,15 @@ [build-system] -requires = ["setuptools>=42", "wheel"] +requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" [project] name = "tealer" version = "0.1.1" +authors = [{ name = "Trail of Bits" }] description = "Teal analyzer." readme = "README.md" -authors = [{name = "Trail of Bits"}] -license = "AGPL-3.0" +license = { "text" = "AGPL-3.0" } +urls = { "Homepage" = "https://github.com/crytic/tealer" } requires-python = ">=3.8" dependencies = [ "prettytable>=0.7.2", @@ -19,14 +20,19 @@ dependencies = [ ] [project.optional-dependencies] -dev = ["pylint==2.13.4", "black==22.3.0", "mypy==0.942", "pytest-cov"] - -[project.urls] -homepage = "https://github.com/crytic/tealer" +dev = [ + "pylint==2.13.4", + "black==22.3.0", + "mypy==0.942", + "pytest-cov", +] [project.scripts] tealer = "tealer.__main__:main" +[tool.setuptools.packages.find] +include = ["tealer"] + [tool.black] target-version = ["py36"] line-length = 100 diff --git a/setup.py b/setup.py deleted file mode 100644 index c1057cf..0000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -import setuptools - -setuptools.setup() \ No newline at end of file From 0e3a2f24913427cbad176994fd577ac9f529d542 Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 22 Jan 2024 14:22:39 +0100 Subject: [PATCH 04/13] Remove pkg_ressources --- tealer/utils/command_line/common.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tealer/utils/command_line/common.py b/tealer/utils/command_line/common.py index 73832e2..035bc36 100644 --- a/tealer/utils/command_line/common.py +++ b/tealer/utils/command_line/common.py @@ -55,7 +55,8 @@ import argparse from typing import List, Type, Tuple, TYPE_CHECKING, Dict -from pkg_resources import iter_entry_points # type: ignore +from importlib.metadata import entry_points + from tealer.detectors.abstract_detector import ( AbstractDetector, @@ -108,7 +109,7 @@ def collect_plugins() -> Tuple[List[Type[AbstractDetector]], List[Type[AbstractP """ detector_classes: List[Type[AbstractDetector]] = [] printer_classes: List[Type[AbstractPrinter]] = [] - for entry_point in iter_entry_points(group="teal_analyzer.plugin", name=None): + for entry_point in entry_points(group="teal_analyzer.plugin"): make_plugin = entry_point.load() plugin_detectors, plugin_printers = make_plugin() From 23f752c12d451865ab88a73276f5a2f3f7f0147f Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 22 Jan 2024 14:36:49 +0100 Subject: [PATCH 05/13] Improve tests --- .github/workflows/tests.yml | 11 +++++++---- setup.py | 3 +++ 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 setup.py diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4e36755..2326d09 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,18 +18,21 @@ on: jobs: tests: runs-on: ubuntu-latest + strategy: + matrix: + python: ${{fromJSON('["3.8", "3.9", "3.10", "3.11", "3.12"]') }} steps: - uses: actions/checkout@v1 - - name: Set up Python 3.8 + - name: Set up Python ${{ matrix.python }} uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: ${{ matrix.python }} # Used by ci_test.sh - - name: Install dependencies + - name: Install dependencies in ${{ matrix.python }} run: | pip install . - - name: Run Tests + - name: Run Tests in ${{ matrix.python }} run: | bash scripts/test_algorand_contracts.sh diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..c1057cf --- /dev/null +++ b/setup.py @@ -0,0 +1,3 @@ +import setuptools + +setuptools.setup() \ No newline at end of file From 95153ad9fdddbdd0150b7eae002bcb0f5819c7ba Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 22 Jan 2024 15:00:47 +0100 Subject: [PATCH 06/13] Drop 3.8 support --- .github/workflows/pytest.yml | 4 ++-- .github/workflows/tests.yml | 2 +- pyproject.toml | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 7f3ba56..73abded 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -1,4 +1,4 @@ -name: CI +name: Pytest defaults: run: @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: ${{fromJSON('["3.8", "3.9", "3.10", "3.11", "3.12"]') }} + python: ${{fromJSON('["3.9", "3.10", "3.11", "3.12"]') }} steps: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2326d09..14b3113 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python: ${{fromJSON('["3.8", "3.9", "3.10", "3.11", "3.12"]') }} + python: ${{fromJSON('["3.9", "3.10", "3.11", "3.12"]') }} steps: - uses: actions/checkout@v1 diff --git a/pyproject.toml b/pyproject.toml index a1b65b6..fbf2d11 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ description = "Teal analyzer." readme = "README.md" license = { "text" = "AGPL-3.0" } urls = { "Homepage" = "https://github.com/crytic/tealer" } -requires-python = ">=3.8" +requires-python = ">=3.9" dependencies = [ "prettytable>=0.7.2", "py-algorand-sdk", @@ -31,10 +31,10 @@ dev = [ tealer = "tealer.__main__:main" [tool.setuptools.packages.find] -include = ["tealer"] + where = ["."] [tool.black] -target-version = ["py36"] +target-version = ["py39"] line-length = 100 [tool.pylint.messages_control] disable = """ From 6c763a886a30bc78b1f13cc0559bfc1102f8fbcd Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 22 Jan 2024 15:04:10 +0100 Subject: [PATCH 07/13] Remove pkg_ressources --- tealer/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tealer/__main__.py b/tealer/__main__.py index 3381344..79dfb80 100644 --- a/tealer/__main__.py +++ b/tealer/__main__.py @@ -71,7 +71,7 @@ from pathlib import Path from typing import List, Any, Type, Tuple, TYPE_CHECKING, Optional, Union, Sequence -from pkg_resources import require # type: ignore +from importlib.metadata import version from tealer.detectors.abstract_detector import AbstractDetector, DetectorType from tealer.exceptions import TealerException @@ -280,7 +280,7 @@ def parse_args( parser.add_argument( "--version", help="displays the current version", - version=require("tealer")[0].version, + version=version("tealer"), action="version", ) From 596dbd68e84a45aa15844b549c1eeeaa470c2ab5 Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 22 Jan 2024 15:17:47 +0100 Subject: [PATCH 08/13] minor --- .github/workflows/darglint.yml | 4 ++-- .github/workflows/linter.yml | 4 ++-- tealer/utils/command_line/common.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/darglint.yml b/.github/workflows/darglint.yml index 7aa8947..d0360f0 100644 --- a/.github/workflows/darglint.yml +++ b/.github/workflows/darglint.yml @@ -17,10 +17,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Set up Python 3.8 + - name: Set up Python 3.9 uses: actions/setup-python@v4 with: - python-version: 3.8 + python-version: 3.9 - name: Run Tests run: | bash scripts/ci_darglint.sh diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 16cdb0c..cfa4252 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -23,10 +23,10 @@ jobs: - name: Checkout Code uses: actions/checkout@v2 - - name: Set up Python 3.8 + - name: Set up Python 3.9 uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: 3.9 - name: Install dependencies run: | diff --git a/tealer/utils/command_line/common.py b/tealer/utils/command_line/common.py index 035bc36..c367124 100644 --- a/tealer/utils/command_line/common.py +++ b/tealer/utils/command_line/common.py @@ -109,7 +109,7 @@ def collect_plugins() -> Tuple[List[Type[AbstractDetector]], List[Type[AbstractP """ detector_classes: List[Type[AbstractDetector]] = [] printer_classes: List[Type[AbstractPrinter]] = [] - for entry_point in entry_points(group="teal_analyzer.plugin"): + for entry_point in entry_points().get("teal_analyzer.plugin", []): make_plugin = entry_point.load() plugin_detectors, plugin_printers = make_plugin() From 60deef5323b24f771200d8e8d57d32c2670e4d90 Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 22 Jan 2024 15:22:08 +0100 Subject: [PATCH 09/13] Improve support for entry_points --- tealer/utils/command_line/common.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/tealer/utils/command_line/common.py b/tealer/utils/command_line/common.py index c367124..692e387 100644 --- a/tealer/utils/command_line/common.py +++ b/tealer/utils/command_line/common.py @@ -54,9 +54,8 @@ import inspect import argparse -from typing import List, Type, Tuple, TYPE_CHECKING, Dict -from importlib.metadata import entry_points - +from typing import List, Type, Tuple, TYPE_CHECKING, Dict, Union +from importlib.metadata import entry_points, EntryPoints, SelectableGroups from tealer.detectors.abstract_detector import ( AbstractDetector, @@ -92,6 +91,15 @@ ) +def _get_entry_points(group: str) -> Union[EntryPoints, SelectableGroups]: + # For Python 3.10 and later + if sys.version_info >= (3, 10): + return entry_points(group=group) + + # For Python 3.9 (and 3.8) + all_entry_points = entry_points() + return all_entry_points.get(group, []) + def collect_plugins() -> Tuple[List[Type[AbstractDetector]], List[Type[AbstractPrinter]]]: """collect detectors and printers installed in form of plugins. @@ -109,7 +117,7 @@ def collect_plugins() -> Tuple[List[Type[AbstractDetector]], List[Type[AbstractP """ detector_classes: List[Type[AbstractDetector]] = [] printer_classes: List[Type[AbstractPrinter]] = [] - for entry_point in entry_points().get("teal_analyzer.plugin", []): + for entry_point in _get_entry_points("teal_analyzer.plugin"): make_plugin = entry_point.load() plugin_detectors, plugin_printers = make_plugin() From cafbbd310430e3ad05b61e6f4d16712695dc843e Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 22 Jan 2024 15:33:08 +0100 Subject: [PATCH 10/13] ignore type of entry points --- tealer/utils/command_line/common.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tealer/utils/command_line/common.py b/tealer/utils/command_line/common.py index 692e387..e1f23bf 100644 --- a/tealer/utils/command_line/common.py +++ b/tealer/utils/command_line/common.py @@ -55,7 +55,7 @@ import argparse from typing import List, Type, Tuple, TYPE_CHECKING, Dict, Union -from importlib.metadata import entry_points, EntryPoints, SelectableGroups +from importlib.metadata import entry_points from tealer.detectors.abstract_detector import ( AbstractDetector, @@ -81,7 +81,6 @@ ) from tealer.utils.command_line.group_config import USER_CONFIG_TRANSACTION_TYPES - if TYPE_CHECKING: from tealer.teal.functions import Function from tealer.teal.teal import Teal @@ -91,7 +90,7 @@ ) -def _get_entry_points(group: str) -> Union[EntryPoints, SelectableGroups]: +def _get_entry_points(group: str): # type: ignore # For Python 3.10 and later if sys.version_info >= (3, 10): return entry_points(group=group) @@ -100,6 +99,7 @@ def _get_entry_points(group: str) -> Union[EntryPoints, SelectableGroups]: all_entry_points = entry_points() return all_entry_points.get(group, []) + def collect_plugins() -> Tuple[List[Type[AbstractDetector]], List[Type[AbstractPrinter]]]: """collect detectors and printers installed in form of plugins. @@ -216,10 +216,10 @@ def print_and_exit(message: str) -> None: if args.subcommand == "detect" and args.detectors_to_run is None: if ( - args.detectors_to_exclude is not None - or args.exclude_stateless - or args.exclude_stateful - or args.filter_paths is not None + args.detectors_to_exclude is not None + or args.exclude_stateless + or args.exclude_stateful + or args.filter_paths is not None ): print_and_exit( "--exclude, --exclude-stateless, --exclude-stateful and --filter-paths options are only available when --detect is selected." @@ -249,7 +249,7 @@ def print_and_exit(message: str) -> None: def _get_function_from_config( - function_call_config: "GroupConfigFunctionCall", contracts: Dict[str, "Teal"] + function_call_config: "GroupConfigFunctionCall", contracts: Dict[str, "Teal"] ) -> "Function": if function_call_config.contract not in contracts: raise TealerException(f"{function_call_config.contract} not found in listed contracts") From 411302a1d68be90f5bedad9177fa5c632d30d9c8 Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Mon, 22 Jan 2024 15:44:43 +0100 Subject: [PATCH 11/13] linters --- setup.py | 2 +- tealer/utils/command_line/common.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index c1057cf..b908cbe 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,3 @@ import setuptools -setuptools.setup() \ No newline at end of file +setuptools.setup() diff --git a/tealer/utils/command_line/common.py b/tealer/utils/command_line/common.py index e1f23bf..7b7eb10 100644 --- a/tealer/utils/command_line/common.py +++ b/tealer/utils/command_line/common.py @@ -54,7 +54,7 @@ import inspect import argparse -from typing import List, Type, Tuple, TYPE_CHECKING, Dict, Union +from typing import List, Type, Tuple, TYPE_CHECKING, Dict from importlib.metadata import entry_points from tealer.detectors.abstract_detector import ( @@ -93,10 +93,10 @@ def _get_entry_points(group: str): # type: ignore # For Python 3.10 and later if sys.version_info >= (3, 10): - return entry_points(group=group) + return entry_points(group=group) # type: ignore # For Python 3.9 (and 3.8) - all_entry_points = entry_points() + all_entry_points = entry_points() # type: ignore return all_entry_points.get(group, []) @@ -216,10 +216,10 @@ def print_and_exit(message: str) -> None: if args.subcommand == "detect" and args.detectors_to_run is None: if ( - args.detectors_to_exclude is not None - or args.exclude_stateless - or args.exclude_stateful - or args.filter_paths is not None + args.detectors_to_exclude is not None + or args.exclude_stateless + or args.exclude_stateful + or args.filter_paths is not None ): print_and_exit( "--exclude, --exclude-stateless, --exclude-stateful and --filter-paths options are only available when --detect is selected." @@ -249,7 +249,7 @@ def print_and_exit(message: str) -> None: def _get_function_from_config( - function_call_config: "GroupConfigFunctionCall", contracts: Dict[str, "Teal"] + function_call_config: "GroupConfigFunctionCall", contracts: Dict[str, "Teal"] ) -> "Function": if function_call_config.contract not in contracts: raise TealerException(f"{function_call_config.contract} not found in listed contracts") From 2fb904ffaa9a5c2613ea7dc2dee97a46ccdfe948 Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Thu, 8 Feb 2024 11:46:51 +0100 Subject: [PATCH 12/13] Improve importlib.metadata support --- tealer/utils/command_line/common.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tealer/utils/command_line/common.py b/tealer/utils/command_line/common.py index 7b7eb10..49d81cb 100644 --- a/tealer/utils/command_line/common.py +++ b/tealer/utils/command_line/common.py @@ -55,7 +55,7 @@ import argparse from typing import List, Type, Tuple, TYPE_CHECKING, Dict -from importlib.metadata import entry_points +from importlib.metadata import entry_points, version from tealer.detectors.abstract_detector import ( AbstractDetector, @@ -91,8 +91,18 @@ def _get_entry_points(group: str): # type: ignore - # For Python 3.10 and later - if sys.version_info >= (3, 10): + + import_lib_version = version("importlib_metadata").split(".") + try: + importlib_major = import_lib_version[0] + importlib_minor = import_lib_version[1] + except IndexError: + importlib_major = "0" + importlib_minor = "0" + + # For Python 3.10 and later, or import lib >= 3.6 + # See https://pypi.org/project/backports.entry-points-selectable/ + if sys.version_info >= (3, 10) or (importlib_major >= "3" and importlib_minor >= "6"): return entry_points(group=group) # type: ignore # For Python 3.9 (and 3.8) From 034dff1616d2fcdb957df91a0cdb20fffcdb9f66 Mon Sep 17 00:00:00 2001 From: Feist Josselin Date: Thu, 8 Feb 2024 11:57:05 +0100 Subject: [PATCH 13/13] Error handling --- tealer/utils/command_line/common.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tealer/utils/command_line/common.py b/tealer/utils/command_line/common.py index 49d81cb..74d4db2 100644 --- a/tealer/utils/command_line/common.py +++ b/tealer/utils/command_line/common.py @@ -55,7 +55,7 @@ import argparse from typing import List, Type, Tuple, TYPE_CHECKING, Dict -from importlib.metadata import entry_points, version +from importlib.metadata import entry_points, version, PackageNotFoundError from tealer.detectors.abstract_detector import ( AbstractDetector, @@ -92,11 +92,11 @@ def _get_entry_points(group: str): # type: ignore - import_lib_version = version("importlib_metadata").split(".") try: + import_lib_version = version("importlib_metadata").split(".") importlib_major = import_lib_version[0] importlib_minor = import_lib_version[1] - except IndexError: + except (IndexError, PackageNotFoundError): importlib_major = "0" importlib_minor = "0"