Exemple #1
0
    def __init__(self, output_mediator):
        """Initializes a Keyhole Markup Language (KML) XML file output module.

    Args:
      output_mediator (OutputMediator): an output mediator.
    """
        event_formatting_helper = rawpy.NativePythonEventFormattingHelper(
            output_mediator)
        super(KMLOutputModule, self).__init__(output_mediator,
                                              event_formatting_helper)
Exemple #2
0
    def testGetFormattedEvent(self):
        """Tests the GetFormattedEvent function."""
        output_mediator = self._CreateOutputMediator()
        event_formatting_helper = rawpy.NativePythonEventFormattingHelper(
            output_mediator)

        event, event_data, event_data_stream = (
            containers_test_lib.CreateEventFromValues(self._TEST_EVENTS[0]))
        event_string = event_formatting_helper.GetFormattedEvent(
            event, event_data, event_data_stream, None)

        if sys.platform.startswith('win'):
            # The dict comparison is very picky on Windows hence we
            # have to make sure the drive letter is in the same case.
            expected_os_location = os.path.abspath('\\{0:s}'.format(
                os.path.join('cases', 'image.dd')))
        else:
            expected_os_location = '{0:s}{1:s}'.format(
                os.path.sep, os.path.join('cases', 'image.dd'))

        expected_event_string = (
            '+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-'
            '+-+-+-+-+-+-\n'
            '[Timestamp]:\n'
            '  2012-06-27T18:17:01.000000Z\n'
            '\n'
            '[Pathspec]:\n'
            '  type: OS, location: {0:s}\n'
            '  type: TSK, inode: 15, location: /var/log/syslog.1\n'
            '\n'
            '[Reserved attributes]:\n'
            '  {{data_type}} test:output\n'
            '  {{display_name}} TSK:/var/log/syslog.1\n'
            '  {{filename}} /var/log/syslog.1\n'
            '  {{hostname}} ubuntu\n'
            '  {{inode}} 15\n'
            '  {{username}} root\n'
            '\n'
            '[Additional attributes]:\n'
            '  {{text}} Reporter <CRON> PID: |8442| (pam_unix(cron:session): '
            'session\n'
            ' closed for user root)\n').format(expected_os_location)

        # Compare the output as list of lines which makes it easier to spot
        # differences.
        self.assertEqual(event_string.split('\n'),
                         expected_event_string.split('\n'))