diff --git a/tern/analyze/default/command_lib/command_lib.py b/tern/analyze/default/command_lib/command_lib.py index cc79d25b..1629b784 100644 --- a/tern/analyze/default/command_lib/command_lib.py +++ b/tern/analyze/default/command_lib/command_lib.py @@ -11,21 +11,19 @@ import os import yaml import copy -import pkg_resources + +from importlib.resources import files from tern.utils import constants from tern.report import errors # base image command library -base_file = pkg_resources.resource_filename( - 'tern', 'analyze/default/command_lib/base.yml') +base_file = str(files('tern') / 'analyze' / 'default' / 'command_lib' / 'base.yml') # general snippets in command library -snippet_file = pkg_resources.resource_filename( - 'tern', 'analyze/default/command_lib/snippets.yml') +snippet_file = str(files('tern') / 'analyze' / 'default' / 'command_lib' / 'snippets.yml') # common information -common_file = pkg_resources.resource_filename( - 'tern', 'analyze/default/command_lib/common.yml') +common_file = str(files('tern') / 'analyze' / 'default' / 'command_lib' / 'common.yml') # command library command_lib = {'common': {}, 'base': {}, 'snippets': {}} diff --git a/tern/prep.py b/tern/prep.py index d38829a0..33bfdc1d 100644 --- a/tern/prep.py +++ b/tern/prep.py @@ -9,9 +9,10 @@ import logging import os -import pkg_resources import shutil +from importlib.resources import files + from tern.utils import constants from tern.utils import general from tern.utils import rootfs @@ -34,7 +35,7 @@ def setup(working_dir=None): # load the cache cache.load() # required to run in a container natively on Windows - fs_hash_path = pkg_resources.resource_filename("tern", "tools/fs_hash.sh") + fs_hash_path = str(files("tern") / "tools" / "fs_hash.sh") rootfs.root_command(["chmod", "+x", fs_hash_path]) diff --git a/tern/utils/rootfs.py b/tern/utils/rootfs.py index 31d91727..5b1ffbb0 100644 --- a/tern/utils/rootfs.py +++ b/tern/utils/rootfs.py @@ -11,7 +11,8 @@ import os import shutil import subprocess # nosec -import pkg_resources + +from importlib.resources import files from tern.utils import constants from tern.utils import general @@ -266,8 +267,7 @@ def calc_fs_hash(fs_path): directory. Note that this file will be deleted if the -k flag is not given''' try: - fs_hash_path = pkg_resources.resource_filename( - "tern", "tools/fs_hash.sh") + fs_hash_path = str(files("tern") / "tools" / "fs_hash.sh") hash_contents = root_command( [fs_hash_path], os.path.abspath(fs_path)) file_name = hashlib.sha256(hash_contents).hexdigest()