From 67e99c29690d947cbd88aba28e9a4a0c6c086153 Mon Sep 17 00:00:00 2001 From: Joachim Metz Date: Fri, 24 Jan 2025 06:02:21 +0100 Subject: [PATCH] Update artifacts_trie.py --- plaso/engine/artifacts_trie.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/plaso/engine/artifacts_trie.py b/plaso/engine/artifacts_trie.py index a634e3250c..3539bd1c9a 100644 --- a/plaso/engine/artifacts_trie.py +++ b/plaso/engine/artifacts_trie.py @@ -151,26 +151,27 @@ def _SearchTrie( # the tree to the path segment from to the tool output as it # sanitizes path segments before writing data to disk. sanitized_child_segment = path_helper.PathHelper.SanitizePathSegments( - [child_segment]).pop() + [child_segment]).pop() + + # If the child is an exact match, continue traversal. if segment in (child_segment, sanitized_child_segment): - # If the child is an exact match, continue traversal. - self._SearchTrie(child_node, self._CustomPathJoin( - path_separator, - current_path, child_segment), remaining_segments, path_separator, + custom_path = _CustomPathJoin( + path_separator, current_path, child_segment) + self._SearchTrie( + child_node, custom_path, remaining_segments, path_separator, matching_artifacts) + # If the child is a glob, see if it matches. elif glob.has_magic(child_segment): if self._MatchesGlobPattern( child_segment, segment, child_node.path_separator): - self._SearchTrie(child_node, self._CustomPathJoin( - path_separator, - current_path, segment), remaining_segments, path_separator, + custom_path = _CustomPathJoin( + path_separator, current_path, segment) + self._SearchTrie( + child_node, custom_path, remaining_segments, path_separator, matching_artifacts) self._SearchTrie( - node, - self._CustomPathJoin( - path_separator, - current_path, segment), remaining_segments, path_separator, + node, custom_path, remaining_segments, path_separator, matching_artifacts) def _ComparePathIfSanitized(