Example #1
0
 def remove(self, id):
     servers = ServerManager(self.app)
     if servers.get_by_plugin(id) != []:
         RuleManager(self.app).remove_by_plugin(id)
         servers.remove_by_plugin(id)
         FWMonitor(self.app).regen()
         FWMonitor(self.app).save()
Example #2
0
 def add_webapp(self, d):
     servers = ServerManager(self.app)
     s = servers.add('webapps', d[0], d[0] + ' (' + d[1] + ')', 'gen-earth',
                     [('tcp', d[2])])
     RuleManager(self.app).set(s, 2)
     FWMonitor(self.app).regen()
     FWMonitor(self.app).save()
Example #3
0
 def remove_webapp(self, sid):
     servers = ServerManager(self.app)
     s = servers.get(sid)[0]
     RuleManager(self.app).remove(s)
     servers.remove(sid)
     FWMonitor(self.app).regen()
     FWMonitor(self.app).save()
Example #4
0
 def remove_webapp(self, sid):
     servers = ServerManager(self.app)
     s = servers.get(sid)
     if s:
         s = s[0]
     else:
         return
     RuleManager(self.app).remove(s)
     servers.remove(sid)
     FWMonitor(self.app).regen()
     FWMonitor(self.app).save()
Example #5
0
 def session_start(self):
     servers = ServerManager(self.app)
     servers.add('arkos', 'genesis', 'Genesis', 'gen-arkos-round',
         [('tcp', self.app.gconfig.get('genesis', 'bind_port'))])
     servers.add('arkos', 'beacon', 'Beacon', 'gen-arkos-round',
         [('tcp', '8765')])
     servers.scan_plugins()
     servers.scan_webapps()
     RuleManager(self.app).scan_servers()
     FWMonitor(self.app).regen()
     FWMonitor(self.app).save()
Example #6
0
 def change_webapp(self, old_id, new_id, type, port):
     servers = ServerManager(self.app)
     rm = RuleManager(self.app)
     s = servers.get(old_id)[0]
     r = rm.get(s)
     rm.remove(s)
     servers.update(old_id, new_id, new_id + ' (' + type + ')', 'gen-earth',
                    [('tcp', port)])
     rm.set(s, r)
     FWMonitor(self.app).regen()
     FWMonitor(self.app).save()
Example #7
0
 def change_webapp(self, oldsite, newsite):
     servers = ServerManager(self.app)
     rm = RuleManager(self.app)
     s = servers.get(oldsite.name)[0]
     r = rm.get(s)
     rm.remove(s)
     servers.update(oldsite.name, newsite.name, 
         newsite.name + ' (' + newsite.stype + ')',
         'gen-earth', [('tcp', newsite.port)])
     rm.set(s, r)
     FWMonitor(self.app).regen()
     FWMonitor(self.app).save()
Example #8
0
 def port_changed(self, s):
     sm = ServerManager(self.app)
     rm = RuleManager(self.app)
     for p in s.services:
         try:
             if p[2] != [] and sm.get(p[1]) != []:
                 sg = sm.get(p[1])[0]
                 r = rm.get(sg)
                 rm.remove(sg)
                 sm.update(p[1], p[1], p[0], s.iconfont, p[2])
                 rm.set(sg, r)
             elif p[2] != []:
                 sg = sm.get(p[1])[0]
                 sm.add(s.plugin_id, p[1], p[0], s.iconfont, p[2])
                 rm.set(sg, 2)
             FWMonitor(self.app).regen()
             FWMonitor(self.app).save()
         except IndexError:
             continue
Example #9
0
 def change_webapp(self, old_id, new_id, type, port):
     servers = ServerManager(self.app)
     rm = RuleManager(self.app)
     s = servers.get(old_id)[0]
     r = rm.get(s)
     rm.remove(s)
     servers.update(old_id, new_id, new_id + ' (' + type + ')',
         'gen-earth', [('tcp', port)])
     rm.set(s, r)
     FWMonitor(self.app).regen()
     FWMonitor(self.app).save()
Example #10
0
 def port_changed(self, s):
     sm = ServerManager(self.app)
     rm = RuleManager(self.app)
     for p in s.services:
         try:
             if p['ports'] != [] and sm.get(p['binary']) != []:
                 sg = sm.get(p['binary'])[0]
                 r = rm.get(sg)
                 rm.remove(sg)
                 sm.update(p['binary'], p['binary'], p['name'], 
                     s.icon, p['ports'])
                 rm.set(sg, r)
             elif p['ports'] != []:
                 sg = sm.get(p['binary'])[0]
                 sm.add(s.plugin_id, p['binary'], p['name'], 
                     s.icon, p['ports'])
                 rm.set(sg, 2)
             FWMonitor(self.app).regen()
             FWMonitor(self.app).save()
         except IndexError:
             continue
Example #11
0
File: api.py Project: ajvb/genesis
        def get_ui(self):
            from genesis.plugins.security.firewall import RuleManager, FWMonitor

            mgr = self.app.get_backend(apis.services.IServiceManager)
            rum = RuleManager(self.app)
            self._rules_list = rum.get_by_plugin(self.plugin_id)
            fwm = FWMonitor(self.app)

            res = UI.DT(UI.DTR(
                    UI.DTH(width=20),
                    UI.DTH(UI.Label(text='Service')),
                    UI.DTH(width=20),
                    header=True
                  ), width='100%', noborder=True)

            alert = False

            for s in self.services:
                ctl = UI.HContainer()

                try:
                    st = mgr.get_status(s[1])
                except:
                    st = 'failed'
                    alert = True
                try:
                    en = mgr.get_enabled(s[1])
                except:
                    en = 'failed'

                if st == 'running':
                    ctl.append(UI.TipIcon(text='Stop', cls='servicecontrol', iconfont='gen-stop', id='stop/' + s[1]))
                    ctl.append(UI.TipIcon(text='Restart', cls='servicecontrol', iconfont='gen-loop-2', id='restart/' + s[1]))
                else:
                    ctl.append(UI.TipIcon(text='Start', cls='servicecontrol', iconfont='gen-play-2', id='start/' + s[1]))
                    alert = True
                if en == 'enabled':
                    ctl.append(UI.TipIcon(text='Disable', cls='servicecontrol', iconfont='gen-minus-circle', id='disable/' + s[1]))
                else:
                    ctl.append(UI.TipIcon(text='Enable', cls='servicecontrol', iconfont='gen-plus-circle', id='enable/' + s[1]))
                
                t = UI.DTR(
                        UI.HContainer(
                            UI.IconFont(iconfont='gen-' + ('play-2' if st == 'running' else 'stop')),
                            UI.IconFont(iconfont='gen-' + ('checkmark' if en == 'enabled' else 'close-2')),
                        ),
                        UI.Label(text='%s (%s)'%(s[0], s[1])),
                        ctl
                    )
                res.append(t)

            ptalert = False

            if self._rules_list != []:
                pts = UI.DT(UI.DTR(
                        UI.DTH(width=20),
                        UI.DTH(UI.Label(text='Application')),
                        UI.DTH(UI.Label(text='Ports')),
                        UI.DTH(UI.Label(text='Authorization')),
                        UI.DTH(width=20),
                        header=True
                      ), width='100%', noborder=True)
                for p in self._rules_list:
                    if p[1] == 1:
                        perm, ic, show = 'Local', 'gen-home', [2, 0]
                    elif p[1] == 2:
                        perm, ic, show = 'All', 'gen-earth', [1, 0]
                    else:
                        perm, ic, show = 'None', 'gen-close', [2, 1]
                        ptalert = True
                    pts.append(UI.DTR(
                        UI.IconFont(iconfont=p[0].icon),
                        UI.Label(text=p[0].name),
                        UI.Label(text=', '.join(str(x[1]) for x in p[0].ports)),
                        UI.HContainer(
                            UI.IconFont(iconfont=ic),
                            UI.Label(text=' '),
                            UI.Label(text=perm),
                            ),
                        UI.HContainer(
                            (UI.TipIcon(iconfont='gen-earth',
                                text='Allow All', cls='servicecontrol', 
                                id='2/' + str(self._rules_list.index(p))) if 2 in show else None),
                            (UI.TipIcon(iconfont='gen-home',
                                text='Local Only', cls='servicecontrol',
                                id='1/' + str(self._rules_list.index(p))) if 1 in show else None),
                            (UI.TipIcon(iconfont='gen-close', 
                                text='Deny All', cls='servicecontrol',
                                id='0/' + str(self._rules_list.index(p)),
                                warning='Are you sure you wish to deny all access to %s? '
                                'This will prevent anyone (including you) from connecting to it.' 
                                % p[0].name) if 0 in show else None),
                            ),
                       ))
            
            panel = UI.ServicePluginPanel(
                alert=('True' if alert else 'False'),
                ports=('True' if self._rules_list != [] else 'False'),
                ptalert=('True' if ptalert else 'False'),
            )

            if self.display:
                dlg = UI.DialogBox(
                        UI.ScrollContainer(res, width=300, height=300),
                        id='dlgServices',
                        hidecancel='True'
                    )
                return UI.Container(panel, dlg, self.get_main_ui())
            elif self.disports:
                dlg = UI.DialogBox(
                        UI.ScrollContainer(pts, width=300, height=300),
                        id='dlgPorts',
                        hidecancel='True'
                    )
                return UI.Container(panel, dlg, self.get_main_ui())
            else:
                return UI.Container(panel, self.get_main_ui())
Example #12
0
        def get_ui(self):
            from genesis.plugins.security.firewall import RuleManager, FWMonitor

            mgr = self.app.get_backend(apis.services.IServiceManager)
            rum = RuleManager(self.app)
            self._rules_list = rum.get_by_plugin(self.plugin_id)
            fwm = FWMonitor(self.app)

            res = UI.DT(UI.DTR(UI.DTH(width=20),
                               UI.DTH(UI.Label(text='Service')),
                               UI.DTH(width=20),
                               header=True),
                        width='100%',
                        noborder=True)

            alert = False

            services = self.plugin_info.services if hasattr(
                self.plugin_info, 'services') else self.services
            for s in services:
                ctl = UI.HContainer()

                try:
                    st = mgr.get_status(s['binary'])
                except:
                    st = 'failed'
                    alert = True
                try:
                    en = mgr.get_enabled(s['binary'])
                except:
                    en = 'failed'

                if st == 'running':
                    ctl.append(
                        UI.TipIcon(text='Stop',
                                   cls='servicecontrol',
                                   iconfont='gen-stop',
                                   id='stop/' + s['binary']))
                    ctl.append(
                        UI.TipIcon(text='Restart',
                                   cls='servicecontrol',
                                   iconfont='gen-loop-2',
                                   id='restart/' + s['binary']))
                else:
                    ctl.append(
                        UI.TipIcon(text='Start',
                                   cls='servicecontrol',
                                   iconfont='gen-play-2',
                                   id='start/' + s['binary']))
                    alert = True
                if en == 'enabled':
                    ctl.append(
                        UI.TipIcon(text='Disable',
                                   cls='servicecontrol',
                                   iconfont='gen-minus-circle',
                                   id='disable/' + s['binary']))
                else:
                    ctl.append(
                        UI.TipIcon(text='Enable',
                                   cls='servicecontrol',
                                   iconfont='gen-plus-circle',
                                   id='enable/' + s['binary']))

                t = UI.DTR(
                    UI.HContainer(
                        UI.IconFont(iconfont='gen-' +
                                    ('play-2' if st == 'running' else 'stop')),
                        UI.IconFont(
                            iconfont='gen-' +
                            ('checkmark' if en == 'enabled' else 'close-2')),
                    ), UI.Label(text='%s (%s)' % (s['name'], s['binary'])),
                    ctl)
                res.append(t)

            ptalert = False

            if self._rules_list != []:
                pts = UI.DT(UI.DTR(UI.DTH(width=20),
                                   UI.DTH(UI.Label(text='Application')),
                                   UI.DTH(UI.Label(text='Ports')),
                                   UI.DTH(UI.Label(text='Authorization')),
                                   UI.DTH(width=20),
                                   header=True),
                            width='100%',
                            noborder=True)
                for p in self._rules_list:
                    if p[1] == 1:
                        perm, ic, show = 'Local', 'gen-home', [2, 0]
                    elif p[1] == 2:
                        perm, ic, show = 'All', 'gen-earth', [1, 0]
                    else:
                        perm, ic, show = 'None', 'gen-close', [2, 1]
                        ptalert = True
                    pts.append(
                        UI.DTR(
                            UI.IconFont(iconfont=p[0].icon),
                            UI.Label(text=p[0].name),
                            UI.Label(text=', '.join(
                                str(x[1]) for x in p[0].ports)),
                            UI.HContainer(
                                UI.IconFont(iconfont=ic),
                                UI.Label(text=' '),
                                UI.Label(text=perm),
                            ),
                            UI.HContainer(
                                (UI.TipIcon(iconfont='gen-earth',
                                            text='Allow All',
                                            cls='servicecontrol',
                                            id='2/' +
                                            str(self._rules_list.index(p)))
                                 if 2 in show else None),
                                (UI.TipIcon(iconfont='gen-home',
                                            text='Local Only',
                                            cls='servicecontrol',
                                            id='1/' +
                                            str(self._rules_list.index(p)))
                                 if 1 in show else None),
                                (UI.TipIcon(
                                    iconfont='gen-close',
                                    text='Deny All',
                                    cls='servicecontrol',
                                    id='0/' + str(self._rules_list.index(p)),
                                    warning=
                                    'Are you sure you wish to deny all access to %s? '
                                    'This will prevent anyone (including you) from connecting to it.'
                                    % p[0].name) if 0 in show else None),
                            ),
                        ))

            panel = UI.ServicePluginPanel(
                alert=('True' if alert else 'False'),
                ports=('True' if self._rules_list != [] else 'False'),
                ptalert=('True' if ptalert else 'False'),
            )

            if self.display:
                dlg = UI.DialogBox(UI.ScrollContainer(res,
                                                      width=300,
                                                      height=300),
                                   id='dlgServices',
                                   hidecancel='True')
                return UI.Container(panel, dlg, self.get_main_ui())
            elif self.disports:
                dlg = UI.DialogBox(UI.ScrollContainer(pts,
                                                      width=300,
                                                      height=300),
                                   id='dlgPorts',
                                   hidecancel='True')
                return UI.Container(panel, dlg, self.get_main_ui())
            else:
                return UI.Container(panel, self.get_main_ui())
Example #13
0
 def refresh(self):
     servers = ServerManager(self.app)
     servers.scan_plugins()
     RuleManager(self.app).scan_servers()
     FWMonitor(self.app).regen()
     FWMonitor(self.app).save()