当前位置: 首页>>代码示例>>Python>>正文


Python Parser.suppose_type方法代码示例

本文整理汇总了Python中Parser.Parser.suppose_type方法的典型用法代码示例。如果您正苦于以下问题:Python Parser.suppose_type方法的具体用法?Python Parser.suppose_type怎么用?Python Parser.suppose_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Parser.Parser的用法示例。


在下文中一共展示了Parser.suppose_type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parse_file

# 需要导入模块: from Parser import Parser [as 别名]
# 或者: from Parser.Parser import suppose_type [as 别名]
def parse_file(file, no_confirm):
    # suppose type
    print CYAN + file + WHITE
    redirect_null()
    supposed_type = Parser.suppose_type(file)
    redirect_standard()
    if not supposed_type:
        print YELLOW + 'Detection failed\n' + WHITE
        if no_confirm:
            return None
    else:
        for i in Parser.parser_list:
            if i[0] == supposed_type:
                print GREEN + 'detected %s\n' % i[1] + WHITE
                break

    # confirm supposed type
    if not no_confirm:
        supposed_type = confirm_type(supposed_type)

    # re-ask while problems
    while not no_confirm and not supposed_type:
        print YELLOW + 'Invalid choice' + WHITE
        supposed_type = confirm_type(supposed_type)

    if not supposed_type:
        print RED + 'Critical no equipment parser found' + WHITE
        return None

    redirect_null()
    fws = Parser.parser(file, supposed_type, None)
    redirect_standard()

    return fws
开发者ID:conix-security,项目名称:springbok,代码行数:36,代码来源:springbox_cli.py

示例2: test

# 需要导入模块: from Parser import Parser [as 别名]
# 或者: from Parser.Parser import suppose_type [as 别名]
def test(file):
    ''' Cisco parse test.
    This function take a configuration file as parameter and :
    - detect the file type (Cisco Asa, Juniper, ...)
    - return rule list
    '''
    res = ''
    firewalls = Parser.parser(file, Parser.suppose_type(file), None)
    for fw in firewalls:
        for acl in fw.acl:
            for rule in acl.rules:
                res += rule.to_string(' ') + '\n'
    return res
开发者ID:conix-security,项目名称:springbok,代码行数:15,代码来源:test.py

示例3: test

# 需要导入模块: from Parser import Parser [as 别名]
# 或者: from Parser.Parser import suppose_type [as 别名]
def test(file):
    ''' Internal detection test.
    This function take a configuration file as parameter and :
    - detect the file type (Cisco Asa, Juniper, ...)
    - construct the firewall data structure
    - perform the internal detection
    - return the error list
    '''
    res = ''
    fw = Parser.parser(file, Parser.suppose_type(file), None)
    fw.build_bdd()
    error_list = InternalDetection.InternalDetection(Node.Node(fw), True).detect_anomaly()
    for elem in error_list:
        for error in elem:
            res += error
    return res
开发者ID:jogaulupeau,项目名称:springbok,代码行数:18,代码来源:test.py

示例4: test

# 需要导入模块: from Parser import Parser [as 别名]
# 或者: from Parser.Parser import suppose_type [as 别名]
def test(file):
    ''' Distributed detection test.
    This function take a configuration file as parameter and :
    - clear the graph topology
    - detect the file type (Cisco Asa, Juniper, ...)
    - construct the firewall data structure
    - construct the graph topology
    - perform the distributed anomaly detection
    - return the error list
    '''
    res = ''
    NetworkGraph().clear()
    firewalls = Parser.parser(file, Parser.suppose_type(file), None)
    for fw in firewalls:
        fw.build_bdd()
        NetworkGraph().network_graph(fw)
    error_list = DistributedDetection.DistributedDetection(False).distributed_detection()
    for k, v in error_list:
        if len(v) > 0:
            res += "\n".join(v)
    return res
开发者ID:hellox-project,项目名称:springbok,代码行数:23,代码来源:test.py

示例5: file_popup_menu2

# 需要导入模块: from Parser import Parser [as 别名]
# 或者: from Parser.Parser import suppose_type [as 别名]
    def file_popup_menu2(self, filename):
        """Detect firewall type and parse the conf file"""
        def iter_next():
            # unblock file
            self.next_file = True

        Gtk_Main.Gtk_Main().statusbar.change_message("Import %s" % (filename))
        progressBar = gtk.ProgressBar(adjustment=None)
        progressBar.set_text("Parsing File")
        progressBar.set_fraction(0)

        vbox = gtk.VBox()
        vbox.pack_start(progressBar)

        button_radio = []
        for p in Parser.parser_list:
            tmp_radio = gtk.RadioButton(button_radio[0][0] if button_radio else None, p[1])
            button_radio.append((tmp_radio, p[0]))
            vbox.pack_start(tmp_radio)

        button_cancel = gtk.Button("Cancel")
        button_start = gtk.Button("Start")
        hbox = gtk.HBox()
        hbox.pack_start(button_cancel)
        hbox.pack_start(button_start)

        popup = gtk.Window()
        popup.set_title(ntpath.basename(filename))
        popup.connect("destroy", lambda x: iter_next())

        popup.set_modal(True)
        popup.set_transient_for(Gtk_Main.Gtk_Main().window)
        popup.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)

        vbox.pack_start(hbox)
        popup.add(vbox)

        popup.show_all()

        supposed_type = Parser.suppose_type(filename)
        for p in button_radio:
            if p[1] == supposed_type:
                p[0].set_active(True)

        def on_click(widget):
            parser_module = 'Parser.CiscoAsa.CiscoAsaYacc'
            for p in button_radio:
                if p[0].get_active():
                    parser_module = p[1]

            firewalls = Parser.parser(filename, parser_module, progressBar)

            firewalls_list = []
            for fw in firewalls:
                firewalls_list.append(fw)

            if len(firewalls_list) > 1:
                fw_select = Gtk_FwSelect.Gtk_FwSelect()
                fw_select.firewalls_list = firewalls_list
                self.actives_fw = list(fw_select.firewalls_list)
                fw_select.buildWindows()
                popup.destroy()
                self.tmp_fw_list += firewalls
            else:
                self.actives_fw = list(firewalls_list)
                for fw in firewalls_list:
                    NetworkGraph.NetworkGraph().network_graph(fw)
                    Gtk_Main.Gtk_Main().lateral_pane.firewalls.add_row(fw.hostname)
                    Gtk_Main.Gtk_Main().lateral_pane.focus_firewall()
                Gtk_Main.Gtk_Main().draw()
                popup.destroy()
                self.tmp_fw_list += firewalls_list

        button_start.connect("clicked", on_click)
        button_cancel.connect("clicked", lambda x: popup.destroy())
开发者ID:conix-security,项目名称:springbok,代码行数:77,代码来源:Gtk_MenuBar.py


注:本文中的Parser.Parser.suppose_type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。