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

Unified Diff: plaso/cli/storage_media_tool.py

Issue 326740043: [plaso] Refactored options to CLI helpers #160 (Closed)
Patch Set: Changes after review and merge Created 6 years, 8 months 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
« no previous file with comments | « plaso/cli/psteal_tool.py ('k') | plaso/cli/tool_options.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: plaso/cli/storage_media_tool.py
diff --git a/plaso/cli/storage_media_tool.py b/plaso/cli/storage_media_tool.py
index 81b5d82cd1fd1fd2a9c65bc9f27566894197e1ec..b996b1cd945c29a953202804f420de87430bbb83 100644
--- a/plaso/cli/storage_media_tool.py
+++ b/plaso/cli/storage_media_tool.py
@@ -37,6 +37,7 @@ class StorageMediaTool(tools.CLITool):
_DEFAULT_BYTES_PER_SECTOR = 512
+ # TODO: remove this redirect.
_SOURCE_OPTION = u'source'
_BINARY_DATA_CREDENTIAL_TYPES = [u'key_data']
@@ -314,32 +315,6 @@ class StorageMediaTool(tools.CLITool):
self._credentials.append((credential_type, credential_data))
- def _ParseFilterOptions(self, options):
- """Parses the filter options.
-
- Args:
- options (argparse.Namespace): command line arguments.
-
- Raises:
- BadConfigOption: if the options are invalid.
- """
- filter_file = self.ParseStringOption(options, u'file_filter')
- if not filter_file:
- return
-
- if self._data_location:
- filter_file_base = os.path.basename(filter_file)
- filter_file_check = os.path.join(self._data_location, filter_file_base)
- if os.path.isfile(filter_file_check):
- self._filter_file = filter_file_check
- return
-
- if not os.path.isfile(filter_file):
- raise errors.BadConfigOption(
- u'No such collection filter file: {0:s}.'.format(filter_file))
-
- self._filter_file = filter_file
-
def _ParsePartitionsString(self, partitions):
"""Parses the user specified partitions string.
@@ -393,6 +368,35 @@ class StorageMediaTool(tools.CLITool):
return sorted(partition_numbers)
+ def _ParseSourcePathOption(self, options):
+ """Parses the source path option.
+
+ Args:
+ options (argparse.Namespace): command line arguments.
+
+ Raises:
+ BadConfigOption: if the options are invalid.
+ """
+ self._source_path = self.ParseStringOption(options, self._SOURCE_OPTION)
+ if not self._source_path:
+ raise errors.BadConfigOption(u'Missing source path.')
+
+ self._source_path = os.path.abspath(self._source_path)
+
+ def _ParseStorageMediaOptions(self, options):
+ """Parses the storage media options.
+
+ Args:
+ options (argparse.Namespace): command line arguments.
+
+ Raises:
+ BadConfigOption: if the options are invalid.
+ """
+ self._ParseStorageMediaImageOptions(options)
+ self._ParseVSSProcessingOptions(options)
+ self._ParseCredentialOptions(options)
+ self._ParseSourcePathOption(options)
+
def _ParseStorageMediaImageOptions(self, options):
"""Parses the storage media image options.
@@ -979,20 +983,6 @@ class StorageMediaTool(tools.CLITool):
u'line arguments can end up in logs, so use this option with '
u'care.').format(u', '.join(self._SUPPORTED_CREDENTIAL_TYPES)))
- def AddFilterOptions(self, argument_group):
- """Adds the filter options to the argument group.
-
- Args:
- argument_group (argparse._ArgumentGroup): argparse argument group.
- """
- argument_group.add_argument(
- u'-f', u'--file_filter', u'--file-filter', dest=u'file_filter',
- action=u'store', type=str, default=None, help=(
- u'List of files to include for targeted collection of files to '
- u'parse, one line per file path, setup is /path|file - where each '
- u'element can contain either a variable set in the preprocessing '
- u'stage or a regular expression.'))
-
def AddStorageMediaImageOptions(self, argument_group):
"""Adds the storage media image options to the argument group.
@@ -1066,26 +1056,6 @@ class StorageMediaTool(tools.CLITool):
u'"1,3..5". The first store is 1. All stores can be defined as: '
u'"all".'))
- def ParseOptions(self, options):
- """Parses tool specific options.
-
- Args:
- options (argparse.Namespace): command line arguments.
-
- Raises:
- BadConfigOption: if the options are invalid.
- """
- super(StorageMediaTool, self).ParseOptions(options)
- self._ParseStorageMediaImageOptions(options)
- self._ParseVSSProcessingOptions(options)
- self._ParseCredentialOptions(options)
-
- self._source_path = self.ParseStringOption(options, self._SOURCE_OPTION)
- if not self._source_path:
- raise errors.BadConfigOption(u'Missing source path.')
-
- self._source_path = os.path.abspath(self._source_path)
-
def ScanSource(self):
"""Scans the source path for volume and file systems.
« no previous file with comments | « plaso/cli/psteal_tool.py ('k') | plaso/cli/tool_options.py » ('j') | no next file with comments »

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