Beispiel #1
0
    def loadGrammar(xmlRoot, vocabulary, namespace, version):
        if version == "0.1":
            automata = None
            sequences = []

            if xmlRoot.find("{" + namespace + "}automata") != None:
                xmlAutomata = xmlRoot.find("{" + namespace + "}automata")
                automata = Automata.loadFromXML(xmlAutomata, vocabulary, namespace, version)

            if xmlRoot.find("{" + namespace + "}sequences") != None:
                xmlSequences = xmlRoot.find("{" + namespace + "}sequences")
                for xmlSequence in xmlSequences.findall("{" + namespace + "}sequence"):
                    sequence = Sequence.loadFromXML(xmlSequence, vocabulary, namespace, version)
                    sequences.append(sequence)

            grammar = None
            if automata != None or len(sequences) > 0:
                grammar = Grammar()
                if automata != None:
                    grammar.setAutomata(automata)
                if len(sequences) > 0:
                    grammar.setSequences(sequences)

            return grammar

        return None
Beispiel #2
0
    def loadGrammar(xmlRoot, vocabulary, namespace, version):
        if version == "0.1":
            automata = None
            sequences = []

            if xmlRoot.find("{" + namespace + "}automata") is not None:
                xmlAutomata = xmlRoot.find("{" + namespace + "}automata")
                automata = Automata.loadFromXML(xmlAutomata, vocabulary,
                                                namespace, version)

            if xmlRoot.find("{" + namespace + "}sequences") is not None:
                xmlSequences = xmlRoot.find("{" + namespace + "}sequences")
                for xmlSequence in xmlSequences.findall("{" + namespace +
                                                        "}sequence"):
                    sequence = Sequence.loadFromXML(xmlSequence, vocabulary,
                                                    namespace, version)
                    sequences.append(sequence)

            grammar = None
            if automata is not None or len(sequences) > 0:
                grammar = Grammar()
                if automata is not None:
                    grammar.setAutomata(automata)
                if len(sequences) > 0:
                    grammar.setSequences(sequences)

            return grammar

        return None
Beispiel #3
0
    def __init__(self, initialState, vocabulary):
        Automata.__init__(self, MMSTD.TYPE)

        # create logger with the given configuration
        self.log = logging.getLogger('netzob.Common.MMSTD.MMSTD.py')

        # Initial state
        self.initialState = initialState

        # The states of the automata
        self.states = []

        # The transitions
        self.transitions = []

        # The dictionary
        self.vocabulary = vocabulary
Beispiel #4
0
    def __init__(self, initialState, vocabulary):
        Automata.__init__(self, MMSTD.TYPE)

        # create logger with the given configuration
        self.log = logging.getLogger('netzob.Common.MMSTD.MMSTD.py')

        # Initial state
        self.initialState = initialState

        # The states of the automata
        self.states = []

        # The transitions
        self.transitions = []

        # The dictionary
        self.vocabulary = vocabulary