Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(845)

Unified Diff: tests/parsers/winreg_plugins/test_lib.py

Issue 333570043: [plaso] Added Window Registry parser plugin filters tests #1668 (Closed)
Patch Set: Changes after review Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/parsers/winreg_plugins/test_lib.py
diff --git a/tests/parsers/winreg_plugins/test_lib.py b/tests/parsers/winreg_plugins/test_lib.py
index 78200d5d457511618775e295e3aa359478161234..e1651eb1f596a774638a4bc3d8fa2c5064e69569 100644
--- a/tests/parsers/winreg_plugins/test_lib.py
+++ b/tests/parsers/winreg_plugins/test_lib.py
@@ -3,6 +3,7 @@
from __future__ import unicode_literals
+from dfwinreg import fake as dfwinreg_fake
from dfwinreg import registry as dfwinreg_registry
from plaso.containers import sessions
@@ -17,6 +18,50 @@ class RegistryPluginTestCase(test_lib.ParserTestCase):
# pylint: disable=protected-access
+ def _AssertFiltersOnKeyPath(self, plugin, key_path):
+ """Asserts if the key path matches one of the plugin filters.
+
+ Args:
+ plugin (WindowsRegistryPlugin): Windows Registry plugin.
+ key_path (str): Windows Registry key path.
+ """
+ _, _, key_name = key_path.rpartition('\\')
+ registry_key = dfwinreg_fake.FakeWinRegistryKey(key_name, key_path=key_path)
+
+ result = self._CheckFiltersOnKeyPath(plugin, registry_key)
+ self.assertTrue(result)
+
+ def _AssertNotFiltersOnKeyPath(self, plugin, key_path):
+ """Asserts if the key path does not match one of the plugin filters.
+
+ Args:
+ plugin (WindowsRegistryPlugin): Windows Registry plugin.
+ key_path (str): Windows Registry key path.
+ """
+ _, _, key_name = key_path.rpartition('\\')
+ registry_key = dfwinreg_fake.FakeWinRegistryKey(key_name, key_path=key_path)
+
+ result = self._CheckFiltersOnKeyPath(plugin, registry_key)
+ self.assertFalse(result)
+
+ def _CheckFiltersOnKeyPath(self, plugin, registry_key):
+ """Checks if the key path matches one of the plugin filters.
+
+ Args:
+ plugin (WindowsRegistryPlugin): Windows Registry plugin.
+ registry_key (dfwinreg.WinRegistryKey): Windows Registry key.
+
+ Returns:
+ bool: True if the key path matches one of the plugin filters,
+ False otherwise.
+ """
+ result = False
+ for path_filter in plugin.FILTERS:
+ if path_filter.Match(registry_key):
+ result = True
+
+ return result
+
def _GetWinRegistryFromFileEntry(self, file_entry):
"""Retrieves a Windows Registry from a file entry.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b