Beispiel #1
0
    def testCopyAttributesFromSessionConfiguration(self):
        """Tests the CopyAttributesFromSessionConfiguration function."""
        attribute_container = sessions.Session()

        session_configuration = sessions.SessionConfiguration(
            identifier=attribute_container.identifier)
        attribute_container.CopyAttributesFromSessionConfiguration(
            session_configuration)

        with self.assertRaises(ValueError):
            session_configuration = sessions.SessionConfiguration()
            attribute_container.CopyAttributesFromSessionConfiguration(
                session_configuration)
Beispiel #2
0
    def _CreateExtractionSessionConfiguration(self, session,
                                              enabled_parser_names):
        """Creates an extraction session configuration.

    Args:
      session (Session): session in which the sources are processed.
      enabled_parser_names (list[str]): enabled parser names.

    Returns:
      SessionConfiguration: extraction session configuration.
    """
        session_configuration = sessions.SessionConfiguration()
        session_configuration.artifact_filters = self._artifact_filters
        session_configuration.command_line_arguments = self._command_line_arguments
        session_configuration.debug_mode = self._debug_mode
        session_configuration.enabled_parser_names = enabled_parser_names
        session_configuration.extract_winevt_resources = (
            self._extract_winevt_resources)
        session_configuration.filter_file_path = self._filter_file
        session_configuration.identifier = session.identifier
        session_configuration.parser_filter_expression = (
            self._parser_filter_expression)
        session_configuration.preferred_encoding = self.preferred_encoding
        session_configuration.preferred_language = (self._preferred_language
                                                    or 'en-US')
        session_configuration.preferred_time_zone = self._preferred_time_zone
        session_configuration.preferred_year = self._preferred_year
        session_configuration.text_prepend = self._text_prepend

        return session_configuration
Beispiel #3
0
    def testGetAttributeNames(self):
        """Tests the GetAttributeNames function."""
        attribute_container = sessions.SessionConfiguration()

        expected_attribute_names = [
            'artifact_filters', 'command_line_arguments', 'debug_mode',
            'enabled_parser_names', 'filter_file', 'identifier',
            'parser_filter_expression', 'preferred_encoding',
            'preferred_time_zone', 'preferred_year', 'source_configurations',
            'text_prepend'
        ]

        attribute_names = sorted(attribute_container.GetAttributeNames())

        self.assertEqual(attribute_names, expected_attribute_names)
Beispiel #4
0
    def _CreateAnalysisSessionConfiguration(self, session):
        """Creates an analysis session configuration.

    Args:
      session (Session): session in which the events are analyzed.

    Returns:
      SessionConfiguration: extraction session configuration.
    """
        session_configuration = sessions.SessionConfiguration()
        session_configuration.command_line_arguments = self._command_line_arguments
        session_configuration.debug_mode = self._debug_mode
        session_configuration.identifier = session.identifier

        return session_configuration
Beispiel #5
0
    def testWriteSessionStartConfigurationAndCompletion(self):
        """Tests the WriteSessionStart, Configuration and Completion functions."""
        session = sessions.Session()
        session_start = sessions.SessionStart(identifier=session.identifier)
        session_configuration = sessions.SessionConfiguration(
            identifier=session.identifier)
        session_completion = sessions.SessionCompletion(
            identifier=session.identifier)

        with shared_test_lib.TempDirectory() as temp_directory:
            temp_file = os.path.join(temp_directory, 'plaso.sqlite')
            storage_file = sqlite_file.SQLiteStorageFile(
                storage_type=definitions.STORAGE_TYPE_SESSION)
            storage_file.Open(path=temp_file, read_only=False)

            storage_file.WriteSessionStart(session_start)
            storage_file.WriteSessionConfiguration(session_configuration)
            storage_file.WriteSessionCompletion(session_completion)

            storage_file.Close()