Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions tern/analyze/default/command_lib/command_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': {}}
Expand Down
5 changes: 3 additions & 2 deletions tern/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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])


Expand Down
6 changes: 3 additions & 3 deletions tern/utils/rootfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down