コード例 #1
0
    def testScanForWindowsVolume(self):
        """Tests the ScanForWindowsVolume function."""
        test_file = self._GetTestFilePath([u'tsk_volume_system.raw'])
        test_scanner = volume_scanner.WindowsVolumeScanner()

        result = test_scanner.ScanForWindowsVolume(test_file)
        self.assertFalse(result)

        test_file = self._GetTestFilePath([u'windows_volume.qcow2'])
        test_scanner = volume_scanner.WindowsVolumeScanner()

        result = test_scanner.ScanForWindowsVolume(test_file)
        self.assertTrue(result)
コード例 #2
0
    def testGetWindowsVolumePathSpec(self):
        """Test the GetWindowsVolumePathSpec() function."""
        test_file = os.path.join(u'test_data', u'tsk_volume_system.raw')
        test_scanner = volume_scanner.WindowsVolumeScanner()

        result = test_scanner.ScanForWindowsVolume(test_file)
        self.assertFalse(result)
コード例 #3
0
    def testOpenFile(self):
        """Tests the OpenFile function."""
        test_path = self._GetTestFilePath(['windows_volume.qcow2'])
        self._SkipIfPathNotExists(test_path)

        test_mediator = TestVolumeScannerMediator()
        test_scanner = volume_scanner.WindowsVolumeScanner(
            mediator=test_mediator)

        result = test_scanner.ScanForWindowsVolume(test_path)
        self.assertTrue(result)

        file_object = test_scanner.OpenFile(
            'C:\\Windows\\System32\\config\\syslog')
        self.assertIsNotNone(file_object)
        file_object.close()

        file_object = test_scanner.OpenFile('C:\\bogus')
        self.assertIsNone(file_object)

        location = 'C:\\Windows\\System32\\config'
        if definitions.PREFERRED_NTFS_BACK_END == definitions.TYPE_INDICATOR_NTFS:
            file_object = test_scanner.OpenFile(location)
            self.assertIsNone(file_object)
        else:
            with self.assertRaises(IOError):
                test_scanner.OpenFile(location)
コード例 #4
0
    def testScanFileSystem(self):
        """Tests the _ScanFileSystem function."""
        test_mediator = TestVolumeScannerMediator()
        test_scanner = volume_scanner.WindowsVolumeScanner(
            mediator=test_mediator)

        test_path = self._GetTestFilePath(['windows_volume.qcow2'])
        self._SkipIfPathNotExists(test_path)

        test_os_path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_OS, location=test_path)
        test_qcow_path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_QCOW, parent=test_os_path_spec)
        test_tsk_path_spec = path_spec_factory.Factory.NewPathSpec(
            definitions.TYPE_INDICATOR_TSK,
            location='/',
            parent=test_qcow_path_spec)

        scan_node = source_scanner.SourceScanNode(test_tsk_path_spec)

        base_path_specs = []
        test_scanner._ScanFileSystem(scan_node, base_path_specs)
        self.assertEqual(len(base_path_specs), 1)

        # Test error conditions.
        with self.assertRaises(errors.ScannerError):
            test_scanner._ScanFileSystem(None, [])

        scan_node = source_scanner.SourceScanNode(None)
        with self.assertRaises(errors.ScannerError):
            test_scanner._ScanFileSystem(scan_node, [])
コード例 #5
0
ファイル: volume_scanner.py プロジェクト: stria/dfvfs
    def testScanForWindowsVolume(self):
        """Tests the ScanForWindowsVolume function."""
        test_path = self._GetTestFilePath(['tsk_volume_system.raw'])

        test_mediator = TestVolumeScannerMediator()
        test_scanner = volume_scanner.WindowsVolumeScanner(
            mediator=test_mediator)

        result = test_scanner.ScanForWindowsVolume(test_path)
        self.assertFalse(result)

        test_path = self._GetTestFilePath(['windows_volume.qcow2'])

        test_mediator = TestVolumeScannerMediator()
        test_scanner = volume_scanner.WindowsVolumeScanner(
            mediator=test_mediator)

        result = test_scanner.ScanForWindowsVolume(test_path)
        self.assertTrue(result)
コード例 #6
0
    def testOpenFile(self):
        """Tests the OpenFile function."""
        test_file = self._GetTestFilePath([u'windows_volume.qcow2'])
        test_scanner = volume_scanner.WindowsVolumeScanner()

        result = test_scanner.ScanForWindowsVolume(test_file)
        self.assertTrue(result)

        file_object = test_scanner.OpenFile(
            u'C:\\Windows\\System32\\config\\syslog')
        self.assertIsNotNone(file_object)
        file_object.close()

        file_object = test_scanner.OpenFile(u'C:\\bogus')
        self.assertIsNone(file_object)

        with self.assertRaises(IOError):
            test_scanner.OpenFile(u'C:\\Windows\\System32\\config')
コード例 #7
0
ファイル: volume_scanner.py プロジェクト: slad99/dfvfs
  def testOpenFile(self):
    """Tests the OpenFile function."""
    test_path = self._GetTestFilePath(['windows_volume.qcow2'])
    self._SkipIfPathNotExists(test_path)

    test_mediator = TestVolumeScannerMediator()
    test_scanner = volume_scanner.WindowsVolumeScanner(mediator=test_mediator)

    result = test_scanner.ScanForWindowsVolume(test_path)
    self.assertTrue(result)

    file_object = test_scanner.OpenFile(
        'C:\\Windows\\System32\\config\\syslog')
    self.assertIsNotNone(file_object)
    file_object.close()

    file_object = test_scanner.OpenFile('C:\\bogus')
    self.assertIsNone(file_object)

    with self.assertRaises(IOError):
      test_scanner.OpenFile('C:\\Windows\\System32\\config')
コード例 #8
0
    def testScanFileSystem(self):
        """Tests the _ScanFileSystem function."""
        test_scanner = volume_scanner.WindowsVolumeScanner()

        test_file = self._GetTestFilePath([u'windows_volume.qcow2'])
        test_os_path_spec = os_path_spec.OSPathSpec(location=test_file)
        test_qcow_path_spec = qcow_path_spec.QCOWPathSpec(
            parent=test_os_path_spec)
        test_tsk_path_spec = tsk_path_spec.TSKPathSpec(
            location=u'/', parent=test_qcow_path_spec)
        scan_node = source_scanner.SourceScanNode(test_tsk_path_spec)

        base_path_specs = []
        test_scanner._ScanFileSystem(scan_node, base_path_specs)
        self.assertEqual(len(base_path_specs), 1)

        # Test error conditions.
        with self.assertRaises(errors.ScannerError):
            test_scanner._ScanFileSystem(None, [])

        scan_node = source_scanner.SourceScanNode(None)
        with self.assertRaises(errors.ScannerError):
            test_scanner._ScanFileSystem(scan_node, [])