Skip to content

Commit

Permalink
Unified "partitions" and "partition" log2timeline.py options (log2tim…
Browse files Browse the repository at this point in the history
  • Loading branch information
Onager authored and joachimmetz committed Jul 20, 2018
1 parent 19d603d commit a932c2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 43 deletions.
27 changes: 4 additions & 23 deletions plaso/cli/storage_media_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,16 +416,6 @@ def _ParseStorageMediaImageOptions(self, options):
partitions = getattr(options, 'partitions', None)
self._partitions = self._ParsePartitionsString(partitions)

partition = getattr(options, 'partition', None)

if self._partitions and partition is not None:
raise errors.BadConfigOption((
'Option "--partition" can not be used in combination '
'with "--partitions".'))

if not self._partitions and partition is not None:
self._partitions = self._ParsePartitionsString(partition)

image_offset_bytes = getattr(options, 'image_offset_bytes', None)

if self._partitions and image_offset_bytes is not None:
Expand Down Expand Up @@ -939,7 +929,6 @@ def _ScanVolumeScanNodeVSS(self, volume_scan_node, selected_vss_stores):
"""Scans a VSS volume scan node for volume and file systems.
Args:
scan_context (dfvfs.SourceScannerContext): source scanner context.
volume_scan_node (dfvfs.SourceScanNode): volume scan node.
selected_vss_stores (list[str]): selected VSS store identifiers.
Expand Down Expand Up @@ -1003,21 +992,13 @@ def AddStorageMediaImageOptions(self, argument_group):
argument_group (argparse._ArgumentGroup): argparse argument group.
"""
argument_group.add_argument(
'--partition', dest='partition', action='store', type=str,
default=None, help=(
'Choose a partition number from a disk image. This partition '
'number should correspond to the partition number on the disk '
'image, starting from partition 1. All partitions can be '
'defined as: "all".'))

argument_group.add_argument(
'--partitions', dest='partitions', action='store', type=str,
default=None, help=(
'Define partitions that need to be processed. A range of '
'--partitions', '--partition', dest='partitions', action='store',
type=str, default=None, help=(
'Define partitions to be processed. A range of '
'partitions can be defined as: "3..5". Multiple partitions can '
'be defined as: "1,3,5" (a list of comma separated values). '
'Ranges and lists can also be combined as: "1,3..5". The first '
'partition is 1. All partitions can be defined as: "all".'))
'partition is 1. All partitions can be specified with: "all".'))

argument_group.add_argument(
'--offset', dest='image_offset', action='store', default=None,
Expand Down
25 changes: 5 additions & 20 deletions tests/cli/storage_media_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ class StorageMediaToolTest(test_lib.CLIToolTestCase):
''])

_EXPECTED_OUTPUT_STORAGE_MEDIA_OPTIONS = """\
usage: storage_media_tool_test.py [--partition PARTITION]
[--partitions PARTITIONS]
usage: storage_media_tool_test.py [--partitions PARTITIONS]
[--offset IMAGE_OFFSET]
[--ob IMAGE_OFFSET_BYTES]
[--sector_size BYTES_PER_SECTOR]
Expand All @@ -68,18 +67,13 @@ class StorageMediaToolTest(test_lib.CLIToolTestCase):
image in number of sectors. A sector is 512 bytes in
size by default this can be overwritten with the
--sector_size option.
--partition PARTITION
Choose a partition number from a disk image. This
partition number should correspond to the partition
number on the disk image, starting from partition 1.
All partitions can be defined as: "all".
--partitions PARTITIONS
Define partitions that need to be processed. A range
of partitions can be defined as: "3..5". Multiple
--partitions PARTITIONS, --partition PARTITIONS
Define partitions to be processed. A range of
partitions can be defined as: "3..5". Multiple
partitions can be defined as: "1,3,5" (a list of comma
separated values). Ranges and lists can also be
combined as: "1,3..5". The first partition is 1. All
partitions can be defined as: "all".
partitions can be specified with: "all".
--sector_size BYTES_PER_SECTOR, --sector-size BYTES_PER_SECTOR
The number of bytes per sector, which is 512 by
default.
Expand Down Expand Up @@ -395,15 +389,6 @@ def testParseStorageMediaImageOptions(self):

test_tool._ParseStorageMediaImageOptions(options)

# Test if 'partition' option raises in combination with
# 'partitions' option.
options = test_lib.TestOptions()
options.partitions = 'all'
options.partition = '1'

with self.assertRaises(errors.BadConfigOption):
test_tool._ParseStorageMediaImageOptions(options)

# Test if 'image_offset_bytes' option raises in combination with
# 'partitions' option.
options = test_lib.TestOptions()
Expand Down

0 comments on commit a932c2f

Please sign in to comment.