예제 #1
0
    def loadFromXML(rootElement, namespace, version, id, timestamp, data):

        # Retrieves the lineNumber (default -1)
        msg_lineNumber = int(rootElement.find("{" + namespace + "}lineNumber").text)

        # Retrieves the filename
        msg_filename = rootElement.find("{" + namespace + "}filename").text.encode("utf-8")

        # Retrieves the creation date
        msg_creationDate = TypeConvertor.xsdDatetime2PythonDatetime(rootElement.find("{" + namespace + "}creationDate").text)

        # Retrieves the modification date
        if rootElement.find("{" + namespace + "}modificationDate").text is not None:
            msg_modificationDate = TypeConvertor.xsdDatetime2PythonDatetime(rootElement.find("{" + namespace + "}modificationDate").text)
        else:
            msg_modificationDate = msg_creationDate

        # Retrieves the owner
        msg_owner = rootElement.find("{" + namespace + "}owner").text

        # Retrieves the size
        msg_size = int(rootElement.find("{" + namespace + "}size").text)

        # TODO : verify this ! Circular imports in python !
        # WARNING : verify this ! Circular imports in python !
        from netzob.Common.Models.FileMessage import FileMessage
        result = FileMessage(id, timestamp, data, msg_filename, msg_creationDate, msg_modificationDate, msg_owner, msg_size, msg_lineNumber)

        return result
예제 #2
0
파일: Project.py 프로젝트: otetard/netzob
def loadProject_0_1(projectFile):
    # Parse the XML Document as 0.1 version
    tree = ElementTree()

    tree.parse(projectFile)

    xmlProject = tree.getroot()

    # Register the namespace
    etree.register_namespace("netzob", PROJECT_NAMESPACE)
    etree.register_namespace("netzob-common", COMMON_NAMESPACE)

    projectID = str(xmlProject.get("id"))
    projectName = xmlProject.get("name", "none")
    projectCreationDate = TypeConvertor.xsdDatetime2PythonDatetime(xmlProject.get("creation_date"))
    projectPath = xmlProject.get("path")
    project = Project(projectID, projectName, projectCreationDate, projectPath)

    description = xmlProject.get("description")
    project.setDescription(description)

    # Parse the configuration
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}configuration") is not None:
        projectConfiguration = ProjectConfiguration.loadProjectConfiguration(
            xmlProject.find("{" + PROJECT_NAMESPACE + "}configuration"), PROJECT_NAMESPACE, "0.1"
        )
        project.setConfiguration(projectConfiguration)

    # Parse the vocabulary
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}vocabulary") is not None:
        projectVocabulary = Vocabulary.loadVocabulary(
            xmlProject.find("{" + PROJECT_NAMESPACE + "}vocabulary"),
            PROJECT_NAMESPACE,
            COMMON_NAMESPACE,
            "0.1",
            project,
        )
        project.setVocabulary(projectVocabulary)

    # Parse the grammar
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}grammar") is not None:
        projectGrammar = Grammar.loadGrammar(
            xmlProject.find("{" + PROJECT_NAMESPACE + "}grammar"), projectVocabulary, PROJECT_NAMESPACE, "0.1"
        )
        if projectGrammar is not None:
            project.setGrammar(projectGrammar)

    # Parse the simulator
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}simulator") is not None:
        projectSimulator = Simulator.loadSimulator(
            xmlProject.find("{" + PROJECT_NAMESPACE + "}simulator"),
            PROJECT_NAMESPACE,
            "0.1",
            project.getGrammar().getAutomata(),
            project.getVocabulary(),
        )
        if projectSimulator is not None:
            project.setSimulator(projectSimulator)

    return project
예제 #3
0
파일: Project.py 프로젝트: KurSh/netzob
def loadProject_0_1(projectFile):
    # Parse the XML Document as 0.1 version
    tree = ElementTree()

    tree.parse(projectFile)

    xmlProject = tree.getroot()

    # Register the namespace
    etree.register_namespace('netzob', PROJECT_NAMESPACE)
    etree.register_namespace('netzob-common', COMMON_NAMESPACE)

    projectID = xmlProject.get('id')
    projectName = xmlProject.get('name', 'none')
    projectCreationDate = TypeConvertor.xsdDatetime2PythonDatetime(xmlProject.get('creation_date'))
    projectPath = xmlProject.get('path')
    project = Project(projectID, projectName, projectCreationDate, projectPath)

    # Parse the configuration
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}configuration") != None:
        projectConfiguration = ProjectConfiguration.loadProjectConfiguration(xmlProject.find("{" + PROJECT_NAMESPACE + "}configuration"), PROJECT_NAMESPACE, "0.1")
        project.setConfiguration(projectConfiguration)

    # Parse the vocabulary
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}vocabulary") != None:
        projectVocabulary = Vocabulary.loadVocabulary(xmlProject.find("{" + PROJECT_NAMESPACE + "}vocabulary"), PROJECT_NAMESPACE, COMMON_NAMESPACE, "0.1", project)
        project.setVocabulary(projectVocabulary)

    # Parse the grammar
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}grammar") != None:
        projectGrammar = Grammar.loadGrammar(xmlProject.find("{" + PROJECT_NAMESPACE + "}grammar"), projectVocabulary, PROJECT_NAMESPACE, "0.1")
        if projectGrammar != None:
            project.setGrammar(projectGrammar)

    return project
예제 #4
0
    def loadFromXML(rootElement, namespace, version):

        # Then we verify its an IPC Message
        if rootElement.get("{http://www.w3.org/2001/XMLSchema-instance}type", "abstract") != "netzob-common:FileMessage":
            raise NameError("The parsed xml doesn't represent a File message.")

        # Verifies the data field
        if rootElement.find("{" + namespace + "}data") == None or not rootElement.find("{" + namespace + "}data").text:
            raise NameError("The parsed message has no data specified")

        # Parse the data field and transform it into a byte array
        msg_data = bytearray(rootElement.find("{" + namespace + "}data").text)

        # Retrieve the id
        msg_id = rootElement.get("id")

        # Retrieve the timestamp
        msg_timestamp = int(rootElement.get("timestamp"))

        # Retrieves the lineNumber (default -1)
        msg_lineNumber = int(rootElement.find("{" + namespace + "}lineNumber").text)

        # Retrieves the filename
        msg_filename = rootElement.find("{" + namespace + "}filename").text

        # Retrieves the creation date
        msg_creationDate = TypeConvertor.xsdDatetime2PythonDatetime(rootElement.find("{" + namespace + "}creationDate").text)

        # Retrieves the modification date
        if rootElement.find("{" + namespace + "}modificationDate").text != None:
            msg_modificationDate = TypeConvertor.xsdDatetime2PythonDatetime(rootElement.find("{" + namespace + "}modificationDate").text)
        else:
            msg_modificationDate = msg_creationDate

        # Retrieves the owner
        msg_owner = rootElement.find("{" + namespace + "}owner").text

        # Retrieves the size
        msg_size = int(rootElement.find("{" + namespace + "}size").text)

        # TODO : verify this ! Circular imports in python !
        # WARNING : verify this ! Circular imports in python !
        from netzob.Common.Models.FileMessage import FileMessage

        result = FileMessage(msg_id, msg_timestamp, msg_data, msg_filename, msg_creationDate, msg_modificationDate, msg_owner, msg_size, msg_lineNumber)

        return result
예제 #5
0
def loadProject_0_1(projectFile):
    # Parse the XML Document as 0.1 version
    tree = ElementTree()

    tree.parse(projectFile)

    xmlProject = tree.getroot()

    # Register the namespace
    etree.register_namespace('netzob', PROJECT_NAMESPACE)
    etree.register_namespace('netzob-common', COMMON_NAMESPACE)

    projectID = str(xmlProject.get('id'))
    projectName = xmlProject.get('name', 'none')
    projectCreationDate = TypeConvertor.xsdDatetime2PythonDatetime(
        xmlProject.get('creation_date'))
    projectPath = xmlProject.get('path')
    project = Project(projectID, projectName, projectCreationDate, projectPath)

    description = xmlProject.get('description')
    project.setDescription(description)

    # Parse the configuration
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}configuration") is not None:
        projectConfiguration = ProjectConfiguration.loadProjectConfiguration(
            xmlProject.find("{" + PROJECT_NAMESPACE + "}configuration"),
            PROJECT_NAMESPACE, "0.1")
        project.setConfiguration(projectConfiguration)

    # Parse the vocabulary
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}vocabulary") is not None:
        projectVocabulary = Vocabulary.loadVocabulary(
            xmlProject.find("{" + PROJECT_NAMESPACE + "}vocabulary"),
            PROJECT_NAMESPACE, COMMON_NAMESPACE, "0.1", project)
        project.setVocabulary(projectVocabulary)

    # Parse the grammar
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}grammar") is not None:
        projectGrammar = Grammar.loadGrammar(
            xmlProject.find("{" + PROJECT_NAMESPACE + "}grammar"),
            projectVocabulary, PROJECT_NAMESPACE, "0.1")
        if projectGrammar is not None:
            project.setGrammar(projectGrammar)

    # Parse the simulator
    if xmlProject.find("{" + PROJECT_NAMESPACE + "}simulator") is not None:
        projectSimulator = Simulator.loadSimulator(
            xmlProject.find("{" + PROJECT_NAMESPACE + "}simulator"),
            PROJECT_NAMESPACE, "0.1",
            project.getGrammar().getAutomata(), project.getVocabulary())
        if projectSimulator is not None:
            project.setSimulator(projectSimulator)

    return project
예제 #6
0
    def loadTrace(xmlRoot, namespace_workspace, namespace_common, version,
                  pathOfTraces):
        if version == "0.1":
            date = TypeConvertor.xsdDatetime2PythonDatetime(
                str(xmlRoot.get("date")))
            type = xmlRoot.get("type")
            description = xmlRoot.get("description", "")
            id = str(xmlRoot.get("id"))
            name = xmlRoot.get("name")

            importedTrace = ImportedTrace(id, date, type, description, name)
            tracesFile = os.path.join(pathOfTraces, "{0}.gz".format(id))
            if not os.path.isfile(tracesFile):
                logging.warn(
                    "The trace file {0} is referenced but doesn't exist.".
                    format(tracesFile))
            else:
                gzipFile = gzip.open(tracesFile, 'rb')
                xml_content = gzipFile.read()
                gzipFile.close()

                tree = etree.parse(StringIO(xml_content))
                xmlRoot = tree.getroot()

                # We retrieve the pool of messages
                xmlMessages = xmlRoot.find("{" + namespace_workspace +
                                           "}messages")
                if xmlMessages is not None:
                    for xmlMessage in xmlMessages.findall("{" +
                                                          namespace_common +
                                                          "}message"):
                        message = AbstractMessageFactory.loadFromXML(
                            xmlMessage, namespace_common, version)
                        if message is not None:
                            importedTrace.addMessage(message)

                # We retrieve the sessions
                if xmlRoot.find("{" + namespace_workspace +
                                "}sessions") is not None:
                    xmlSessions = xmlRoot.find("{" + namespace_workspace +
                                               "}sessions")
                    for xmlSession in xmlSessions.findall("{" +
                                                          namespace_common +
                                                          "}session"):
                        session = Session.loadFromXML(xmlSession,
                                                      namespace_workspace,
                                                      namespace_common,
                                                      version, importedTrace)
                        if session is not None:
                            importedTrace.addSession(session)
            return importedTrace
        return None
예제 #7
0
    def loadFromXML(rootElement, namespace, version, id, timestamp, data):

        # Retrieves the lineNumber (default -1)
        msg_lineNumber = int(
            rootElement.find("{" + namespace + "}lineNumber").text)

        # Retrieves the filename
        msg_filename = rootElement.find("{" + namespace +
                                        "}filename").text.encode("utf-8")

        # Retrieves the creation date
        msg_creationDate = TypeConvertor.xsdDatetime2PythonDatetime(
            rootElement.find("{" + namespace + "}creationDate").text)

        # Retrieves the modification date
        if rootElement.find("{" + namespace +
                            "}modificationDate").text is not None:
            msg_modificationDate = TypeConvertor.xsdDatetime2PythonDatetime(
                rootElement.find("{" + namespace + "}modificationDate").text)
        else:
            msg_modificationDate = msg_creationDate

        # Retrieves the owner
        msg_owner = rootElement.find("{" + namespace + "}owner").text

        # Retrieves the size
        msg_size = int(rootElement.find("{" + namespace + "}size").text)

        # TODO : verify this ! Circular imports in python !
        # WARNING : verify this ! Circular imports in python !
        from netzob.Common.Models.FileMessage import FileMessage
        result = FileMessage(id, timestamp, data, msg_filename,
                             msg_creationDate, msg_modificationDate, msg_owner,
                             msg_size, msg_lineNumber)

        return result
예제 #8
0
파일: Workspace.py 프로젝트: KurSh/netzob
def loadWorkspace_0_1(workspacePath, workspaceFile):

    # Parse the XML Document as 0.1 version
    tree = ElementTree()

    tree.parse(workspaceFile)
    xmlWorkspace = tree.getroot()
    wsName = xmlWorkspace.get('name', 'none')
    wsCreationDate = TypeConvertor.xsdDatetime2PythonDatetime(xmlWorkspace.get('creation_date'))

    # Parse the configuration to retrieve the main paths
    xmlWorkspaceConfig = xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}configuration")
    pathOfTraces = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}traces").text

    pathOfLogging = None
    if xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}logging") != None and xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}logging").text != None and len(xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}logging").text) > 0:
        pathOfLogging = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}logging").text

    pathOfPrototypes = None
    if xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}prototypes") != None and xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}prototypes").text != None and len(xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}prototypes").text) > 0:
        pathOfPrototypes = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}prototypes").text

    lastProject = None
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}projects") != None:
        xmlProjects = xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}projects")
        if xmlProjects.get("last", "none") != "none":
            lastProject = xmlProjects.get("last", "none")

    # Instantiation of the workspace
    workspace = Workspace(wsName, wsCreationDate, workspacePath, pathOfTraces, pathOfLogging, pathOfPrototypes)

    # Load the already imported traces
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}traces") != None:
        xmlTraces = xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}traces")
        for xmlTrace in xmlTraces.findall("{" + WORKSPACE_NAMESPACE + "}trace"):
            trace = ImportedTrace.loadTrace(xmlTrace, WORKSPACE_NAMESPACE, COMMON_NAMESPACE, "0.1", workspace.getPathOfTraces())
            if trace != None:
                workspace.addImportedTrace(trace)

    # Reference the projects
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}projects") != None:
        for xmlProject in xmlWorkspace.findall("{" + WORKSPACE_NAMESPACE + "}projects/{" + WORKSPACE_NAMESPACE + "}project"):
            project_path = xmlProject.get("path")
            workspace.referenceProject(project_path)
            if project_path == lastProject and lastProject != None:
                workspace.referenceLastProject(lastProject)

    return workspace
예제 #9
0
    def loadTrace(xmlRoot, namespace_workspace, namespace_common, version, pathOfTraces):

        if version == "0.1":
            date = TypeConvertor.xsdDatetime2PythonDatetime(str(xmlRoot.get("date")))
            type = xmlRoot.get("type")
            description = xmlRoot.get("description", "")
            id = xmlRoot.get("id")
            name = xmlRoot.get("name")

            importedTrace = ImportedTrace(id, date, type, description, name)
            tracesFile = os.path.join(pathOfTraces, str(id) + ".gz")
            if not os.path.isfile(tracesFile):
                logging.warn("The trace file " + str(tracesFile) + " is referenced but doesn't exist.")
            else:
                gzipFile = gzip.open(tracesFile, 'rb')
                xml_content = gzipFile.read()
                gzipFile.close()

                tree = etree.parse(StringIO(xml_content))
                xmlRoot = tree.getroot()

                # We retrieve the pool of messages
                if xmlRoot.find("{" + namespace_workspace + "}messages") != None:
                    xmlMessages = xmlRoot.find("{" + namespace_workspace + "}messages")
                    for xmlMessage in xmlMessages.findall("{" + namespace_common + "}message"):
                        message = AbstractMessageFactory.loadFromXML(xmlMessage, namespace_common, version)
                        if message != None:
                            importedTrace.addMessage(message)

                # We retrieve the sessions
                if xmlRoot.find("{" + namespace_workspace + "}sessions") != None:
                    xmlSessions = xmlRoot.find("{" + namespace_workspace + "}sessions")
                    for xmlSession in xmlSessions.findall("{" + namespace_common + "}session"):
                        session = Session.loadFromXML(xmlSession, namespace_workspace, namespace_common, version, importedTrace)
                        if session != None:
                            importedTrace.addSession(session)
            return importedTrace
        return None
예제 #10
0
def loadWorkspace_0_1(workspacePath, workspaceFile):

    # Parse the XML Document as 0.1 version
    tree = ElementTree()

    tree.parse(workspaceFile)
    xmlWorkspace = tree.getroot()
    wsName = xmlWorkspace.get('name', 'none')
    wsCreationDate = TypeConvertor.xsdDatetime2PythonDatetime(xmlWorkspace.get('creation_date'))

    # Parse the configuration to retrieve the main paths
    xmlWorkspaceConfig = xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}configuration")
    pathOfTraces = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}traces").text

    pathOfLogging = None
    if xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}logging") is not None and xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}logging").text is not None and len(xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}logging").text) > 0:
        pathOfLogging = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}logging").text

    pathOfPrototypes = None
    if xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}prototypes") is not None and xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}prototypes").text is not None and len(xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}prototypes").text) > 0:
        pathOfPrototypes = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}prototypes").text

    lastProject = None
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}projects") is not None:
        xmlProjects = xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}projects")
        if xmlProjects.get("last", "none") != "none":
            lastProject = xmlProjects.get("last", "none")

    # Instantiation of the workspace
    workspace = Workspace(wsName, wsCreationDate, workspacePath, pathOfTraces, pathOfLogging, pathOfPrototypes)

    # Load the already imported traces
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}traces") is not None:
        xmlTraces = xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}traces")
        for xmlTrace in xmlTraces.findall("{" + WORKSPACE_NAMESPACE + "}trace"):
            trace = ImportedTrace.loadTrace(xmlTrace, WORKSPACE_NAMESPACE, COMMON_NAMESPACE, "0.1", workspace.getPathOfTraces())
            if trace is not None:
                workspace.addImportedTrace(trace)

    # Reference the projects
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}projects") is not None:
        for xmlProject in xmlWorkspace.findall("{" + WORKSPACE_NAMESPACE + "}projects/{" + WORKSPACE_NAMESPACE + "}project"):
            project_path = xmlProject.get("path")
            workspace.referenceProject(project_path)
            if project_path == lastProject and lastProject is not None:
                workspace.referenceLastProject(lastProject)

    # Reference the functions
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}functions") is not None:
        for xmlFunction in xmlWorkspace.findall("{" + WORKSPACE_NAMESPACE + "}functions/{" + WORKSPACE_NAMESPACE + "}function"):
            function = RenderingFunction.loadFromXML(xmlFunction, WORKSPACE_NAMESPACE, "0.1")
            if function is not None:
                workspace.addCustomTransformationFunction(function)

    enableBugReporting = False
    if xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}enable_bug_reporting") is not None and xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}enable_bug_reporting").text is not None and len(xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}enable_bug_reporting").text) > 0:
        val = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE + "}enable_bug_reporting").text
        if val == "true":
            enableBugReporting = True
    workspace.setEnableBugReporting(enableBugReporting)

    return workspace
예제 #11
0
def loadWorkspace_0_1(workspacePath, workspaceFile):

    # Parse the XML Document as 0.1 version
    tree = ElementTree()

    tree.parse(workspaceFile)
    xmlWorkspace = tree.getroot()
    wsName = xmlWorkspace.get('name', 'none')
    wsCreationDate = TypeConvertor.xsdDatetime2PythonDatetime(
        xmlWorkspace.get('creation_date'))

    # Parse the configuration to retrieve the main paths
    xmlWorkspaceConfig = xmlWorkspace.find("{" + WORKSPACE_NAMESPACE +
                                           "}configuration")
    pathOfTraces = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE +
                                           "}traces").text

    pathOfLogging = None
    if xmlWorkspaceConfig.find(
            "{" + WORKSPACE_NAMESPACE +
            "}logging") is not None and xmlWorkspaceConfig.find(
                "{" + WORKSPACE_NAMESPACE +
                "}logging").text is not None and len(
                    xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE +
                                            "}logging").text) > 0:
        pathOfLogging = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE +
                                                "}logging").text

    pathOfPrototypes = None
    if xmlWorkspaceConfig.find(
            "{" + WORKSPACE_NAMESPACE +
            "}prototypes") is not None and xmlWorkspaceConfig.find(
                "{" + WORKSPACE_NAMESPACE +
                "}prototypes").text is not None and len(
                    xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE +
                                            "}prototypes").text) > 0:
        pathOfPrototypes = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE +
                                                   "}prototypes").text

    lastProject = None
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}projects") is not None:
        xmlProjects = xmlWorkspace.find("{" + WORKSPACE_NAMESPACE +
                                        "}projects")
        if xmlProjects.get("last", "none") != "none":
            lastProject = xmlProjects.get("last", "none")

    # Instantiation of the workspace
    workspace = Workspace(wsName, wsCreationDate, workspacePath, pathOfTraces,
                          pathOfLogging, pathOfPrototypes)

    # Load the already imported traces
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}traces") is not None:
        xmlTraces = xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}traces")
        for xmlTrace in xmlTraces.findall("{" + WORKSPACE_NAMESPACE +
                                          "}trace"):
            trace = ImportedTrace.loadTrace(xmlTrace, WORKSPACE_NAMESPACE,
                                            COMMON_NAMESPACE, "0.1",
                                            workspace.getPathOfTraces())
            if trace is not None:
                workspace.addImportedTrace(trace)

    # Reference the projects
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}projects") is not None:
        for xmlProject in xmlWorkspace.findall("{" + WORKSPACE_NAMESPACE +
                                               "}projects/{" +
                                               WORKSPACE_NAMESPACE +
                                               "}project"):
            project_path = xmlProject.get("path")
            workspace.referenceProject(project_path)
            if project_path == lastProject and lastProject is not None:
                workspace.referenceLastProject(lastProject)

    # Reference the functions
    if xmlWorkspace.find("{" + WORKSPACE_NAMESPACE + "}functions") is not None:
        for xmlFunction in xmlWorkspace.findall("{" + WORKSPACE_NAMESPACE +
                                                "}functions/{" +
                                                WORKSPACE_NAMESPACE +
                                                "}function"):
            function = RenderingFunction.loadFromXML(xmlFunction,
                                                     WORKSPACE_NAMESPACE,
                                                     "0.1")
            if function is not None:
                workspace.addCustomTransformationFunction(function)

    enableBugReporting = False
    if xmlWorkspaceConfig.find(
            "{" + WORKSPACE_NAMESPACE +
            "}enable_bug_reporting") is not None and xmlWorkspaceConfig.find(
                "{" + WORKSPACE_NAMESPACE +
                "}enable_bug_reporting").text is not None and len(
                    xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE +
                                            "}enable_bug_reporting").text) > 0:
        val = xmlWorkspaceConfig.find("{" + WORKSPACE_NAMESPACE +
                                      "}enable_bug_reporting").text
        if val == "true":
            enableBugReporting = True
    workspace.setEnableBugReporting(enableBugReporting)

    return workspace