Example #1
0
    def init_UI(self):
        # Main layout
        main_layout = QGridLayout()
        main_layout.setSpacing(0)

        # Top layout
        top_layout = QVBoxLayout()
        top_layout.setContentsMargins(5, 0, 0, 0)

        self.b1 = QRadioButton(u"Optional Modules")
        self.b1.setChecked(True)
        self.b1.setFont(QFont('SansSerif', 15))
        self.b1.clicked.connect(partial(self.change_all, False))

        path_layout = QHBoxLayout()
        lable = QLabel(u"Directory to load modules:")
        self.location = QLabel()
        additional_path = QPushButton(u"Select Directory")
        additional_path.clicked.connect(self.path)

        path_layout.addWidget(additional_path)
        path_layout.addWidget(self.location, alignment=Qt.AlignRight)
        path_layout.addWidget(lable, alignment=Qt.AlignRight)

        self.b2 = QRadioButton(u"All Modules")
        self.b2.setFont(QFont('SansSerif', 15))
        self.b2.clicked.connect(partial(self.change_all, True))

        top_layout.addWidget(self.b1, alignment=Qt.AlignRight)
        top_layout.addWidget(self.b2, alignment=Qt.AlignRight)
        top_layout.addLayout(path_layout)

        # Middle layout
        middle_layout = QVBoxLayout()
        m = Modules(self)

        btn_layout = QHBoxLayout()
        btn_layout.setAlignment(Qt.AlignRight)
        run_btn = QPushButton("Run")
        run_btn.clicked.connect(partial(self.call_run, m))
        btn_layout.addWidget(run_btn)

        middle_layout.addWidget(m)
        middle_layout.addLayout(btn_layout)

        main_layout.addLayout(top_layout, 0, 0)
        main_layout.addLayout(middle_layout, 1, 0)
        self.setLayout(main_layout)
Example #2
0
    def build_pipeline(self, modules):
        """
        Setup Modules to built the modules pipeline.

        Args:
            modules ([Module]): list of Module instances
        """
        assert isinstance(modules, list), modules

        for md in modules:
            self.Check_Module(md)

        # some final operations that might modify the pipeline
        logger.logger.info("Build Modules pipeline ...")
        self._modules = Modules(self._modules)
        self._modules.register_to_controller(weakref.proxy(self))
        self._modules = self._modules.get_modules()
    def start(self):
        """
        Starts the Application
        :return:
        """
        appcontext_tearing_down.connect(self.stop, self.app)
        appcontext_pushed.connect(self.app_pushed, self.app)

        self.fake_module = Thread(target=run_fake_module,
                                  args=(self.startapp, self.runapp))

        self.channels = Channels(self)
        self.channels.register_api()

        self.sensors = Sensors(self)
        # self.sensors.register_api()

        self.modules = Modules(self)
        self.modules.register_api()

        self.website = Website(self)
        self.website.register_url()
Example #4
0
    def do_modules(self, args):
        """
Shows all the modules present in the Modules directory
	    """
        subconsole = Modules(self.connected, self.session)
        subconsole.cmdloop()
Example #5
0
	def BtnModuleSettingsCB(self):
		modules = Modules()
		modules.show()
Example #6
0
    #construction email subject using configuration
    for key in mail_keys:
        t_val = document.get(key, "{%s}" % key)
        subject = subject.replace("{%s}" % key, str(t_val))

    #construction email title using configuration
    mail_keys = re.findall("{(.+?)}", mail_title)
    for key in mail_keys:
        t_val = document.get(key, "{%s}" % key)
        mail_title = mail_title.replace("{%s}" % key, str(t_val))

    mail_html = ""

    #getting list of enrichment modules for the email alert
    modu = Modules(mail_config.get("custom_enrichment_data", {}), document)

    if mail_config["enrichment"]:
        if mail_config["enrichment_conditional"]:
            for i, j in mail_config["enrichments"].iteritems():
                if eval(i):
                    any_cond_match = True
                    for e in j:
                        e_enable = e.get("enabled", True)
                        if e_enable:
                            params = e["e_key"].split(",")
                            fn_params = []
                            for p in params:
                                if p.strip():
                                    fn_params.append(document[p.strip()])
                            e_func = getattr(modu, e['e_func'])
Example #7
0
    def do_modules(self, _args):
        """
Interact with custom Mercury modules
        """
        subconsole = Modules(self.session)
        subconsole.cmdloop()
Example #8
0
 def modules(self):
     modules = []
     for module in Modules(self.cfg).enabled().values():
         modules.append(module(self))
     return modules
Example #9
0
 def __init__(self) -> None:
     app = QApplication(sys.argv)
     self.modules = Modules()
     sys.exit(app.exec_())