diff --git a/dissect/target/helpers/record_modifier.py b/dissect/target/helpers/record_modifier.py index 52a734abe..492779ad5 100644 --- a/dissect/target/helpers/record_modifier.py +++ b/dissect/target/helpers/record_modifier.py @@ -1,3 +1,4 @@ +import logging from functools import partial from typing import Callable, Iterable, Iterator @@ -95,13 +96,16 @@ def modify_record(target: Target, record: Record, modifier_function: ModifierFun try: _record = modifier_function(field_name, resolved_path) except FilesystemError as e: - target.log.warning( + level = logging.INFO if isinstance(e, FileNotFoundError) else logging.WARNING + target.log.log( + level, "Unable to modify record '%s' with function '%s': %s", record._desc.name, modifier_function.__name__, e, ) target.log.debug("", exc_info=e) + else: additional_records.append(_record) diff --git a/dissect/target/target.py b/dissect/target/target.py index 73a44c86b..9d581e26a 100644 --- a/dissect/target/target.py +++ b/dissect/target/target.py @@ -19,6 +19,7 @@ VolumeSystemError, ) from dissect.target.helpers import config +from dissect.target.helpers.fsutil import TargetPath from dissect.target.helpers.loaderutil import extract_path_info from dissect.target.helpers.record import ChildTargetRecord from dissect.target.helpers.utils import StrEnum, parse_path_uri, slugify @@ -86,8 +87,13 @@ def __init__(self, path: Union[str, Path] = None): self._errors = [] self._applied = False + # We do not want to look for config files at the Target path if it is actually a child Target. + config_paths = [Path.cwd(), Path.home()] + if not isinstance(path, TargetPath): + config_paths = [self.path] + config_paths + try: - self._config = config.load([self.path, Path.cwd(), Path.home()]) + self._config = config.load(config_paths) except Exception as e: self.log.warning("Error loading config file: %s", self.path) self.log.debug("", exc_info=e)