Skip to content

Commit

Permalink
Update artifact_filters.py
Browse files Browse the repository at this point in the history
  • Loading branch information
joachimmetz authored Jan 21, 2025
1 parent fcac56f commit 42727b7
Showing 1 changed file with 22 additions and 42 deletions.
64 changes: 22 additions & 42 deletions plaso/engine/artifact_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def __init__(self, artifacts_registry):
self.artifacts_trie = artifacts_trie.ArtifactsTrie()

def _BuildFindSpecsFromArtifact(
self, definition, environment_variables, user_accounts,
enable_artifacts_map=False,
original_registry_artifact_filter_names=None):
self, definition, environment_variables, user_accounts,
enable_artifacts_map=False,
original_registry_artifact_filter_names=None):
"""Builds find specifications from an artifact definition.
Args:
Expand All @@ -88,11 +88,8 @@ def _BuildFindSpecsFromArtifact(
if source.type_indicator == artifact_types.TYPE_INDICATOR_FILE:
for path_entry in set(source.paths):
specifications = self._BuildFindSpecsFromFileSourcePath(
definition.name,
path_entry,
source.separator,
environment_variables,
user_accounts,
definition.name, path_entry, source.separator,
environment_variables, user_accounts,
enable_artifacts_map=enable_artifacts_map,
original_registry_artifact_filter_names=(
original_registry_artifact_filter_names))
Expand Down Expand Up @@ -130,9 +127,7 @@ def _BuildFindSpecsFromArtifact(
artifact_types.TYPE_INDICATOR_ARTIFACT_GROUP):
for name in source.names:
specifications = self._BuildFindSpecsFromGroupName(
name,
environment_variables,
user_accounts,
name, environment_variables, user_accounts,
enable_artifacts_map=enable_artifacts_map,
original_registry_artifact_filter_names=(
original_registry_artifact_filter_names))
Expand All @@ -146,12 +141,9 @@ def _BuildFindSpecsFromArtifact(
return find_specs

def _BuildFindSpecsFromGroupName(
self,
group_name,
environment_variables,
user_accounts,
enable_artifacts_map=False,
original_registry_artifact_filter_names=None):
self, group_name, environment_variables, user_accounts,
enable_artifacts_map=False,
original_registry_artifact_filter_names=None):
"""Builds find specifications from a artifact group name.
Args:
Expand All @@ -176,9 +168,7 @@ def _BuildFindSpecsFromGroupName(
return None

return self._BuildFindSpecsFromArtifact(
definition,
environment_variables,
user_accounts,
definition, environment_variables, user_accounts,
enable_artifacts_map=enable_artifacts_map,
original_registry_artifact_filter_names=(
original_registry_artifact_filter_names))
Expand Down Expand Up @@ -215,12 +205,8 @@ def _BuildFindSpecsFromRegistrySourceKey(self, key_path):
return find_specs

def _BuildFindSpecsFromFileSourcePath(
self,
artifact_name,
source_path,
path_separator,
environment_variables,
user_accounts,
self, artifact_name, source_path, path_separator,
environment_variables, user_accounts,
enable_artifacts_map=False,
original_registry_artifact_filter_names=None):
"""Builds find specifications from a file source type.
Expand Down Expand Up @@ -262,19 +248,17 @@ def _BuildFindSpecsFromFileSourcePath(
find_specs.append(find_spec)

if enable_artifacts_map:
self._AddToArtifactsTrie(artifact_name,
expanded_path,
original_registry_artifact_filter_names,
path_separator)
self._AddToArtifactsTrie(
artifact_name, expanded_path,
original_registry_artifact_filter_names,
path_separator)

return find_specs

def _AddToArtifactsTrie(
self,
artifact_name,
path,
original_registry_artifact_filter_names,
path_separator):
self, artifact_name, path,
original_registry_artifact_filter_names,
path_separator):
"""Adds a path to the artifacts trie.
Args:
Expand Down Expand Up @@ -322,7 +306,6 @@ def _CreateFindSpec(self, path, path_separator):
path (str): Path to match.
path_separator (str): file system path segment separator.
Returns:
dfvfs.FindSpec: a find specification or None if one cannot be created.
"""
Expand All @@ -338,12 +321,9 @@ def _CreateFindSpec(self, path, path_separator):
return None

def BuildFindSpecs(
self,
artifact_filter_names,
environment_variables=None,
user_accounts=None,
enable_artifacts_map=False,
original_registry_artifact_filter_names=None):
self, artifact_filter_names, environment_variables=None,
user_accounts=None, enable_artifacts_map=False,
original_registry_artifact_filter_names=None):
"""Builds find specifications from artifact definitions.
Args:
Expand Down

0 comments on commit 42727b7

Please sign in to comment.