Commit 750fc2c3 authored by PidgeyL's avatar PidgeyL
Browse files

sort functions for visibility

parent c2e01951
Loading
Loading
Loading
Loading
+56 −53
Original line number Diff line number Diff line
@@ -57,19 +57,7 @@ class PluginManager():
        print("[!] Failed to load module %s: "%x[0])
        print("[!]  -> %s"%e)

  def onCVEOpen(self, cve, **args):
    for plugin in self.getWebPlugins():
      plugin.onCVEOpen(cve, **args)

  def onCVEAction(self, cve, plugin, action, **args):
    if plugin.strip() in self.plugins.keys(): # Check if plugin exists
      if self.plugins[plugin].isWebPlugin():  # Check if plugin is web plugin
        try:
          return self.plugins[plugin].onCVEAction(cve, action, **args)
        except Exception as e:
          print("[!] Failed to perform %s action on module %s: "%(action, plugin))
          print("[!]  -> %s"%e)

  # Get's - Plug-in manager
  def getPlugins(self):
    return self.plugins.values()

@@ -92,6 +80,7 @@ class PluginManager():
        print("[!]  -> %s"%e)
    return plugins

  # Get's - Plug-in specific
  def getCVEActions(self, cve, **args):
    actions = []
    for plugin in self.getWebPlugins():
@@ -112,33 +101,22 @@ class PluginManager():
      return self.plugins[plugin].requiresAuth
    else: return False

  def openPage(self, name, **args):
    if name.strip() in self.plugins.keys(): # Check if plugin exists
      if self.plugins[name].isWebPlugin():  # Check if plugin is web plugin
        pageInfo = self.plugins[name].getPage(**args)
        if type(pageInfo) == tuple:
          page, content = pageInfo
          if page: return ("plugins/%s"%page, content)
          else:    return None
        else:
          return ("error.html", {'status': {'except': 'plugin-page-missing'}})
      else:
        return ("error.html", {'status': {'except': 'plugin-not-webplugin'}})
    return ("error.html", {'status': {'except': 'plugin-not-loaded'}})

  def openSubpage(self, subpage, **args):
    if name.strip() in self.plugins.keys(): # Check if plugin exists
      if self.plugins[name].isWebPlugin():  # Check if plugin is web plugin
        pageInfo = self.plugins[name].getSubpage(subpage, **args)
        if type(pageInfo) == tuple:
          page, content = pageInfo
          if page: return ("plugins/%s"%page, content)
        # Else, the page is missing, so we send None to throw a 404
        return None
      else:
        return ("error.html", {'status': {'except': 'plugin-not-webplugin'}})
    return ("error.html", {'status': {'except': 'plugin-not-loaded'}})
  def getFilters(self, **args):
    filters = []
    for plugin in self.getWebPlugins():
      try:
        filters_ = plugin.getFilters(**args)
        if filters_:
          for filter_ in filters_:
            filter_['auth']   = plugin.requiresAuth
            filter_['plugin'] = plugin.getUID()
            filters.append(filter_)
      except Exception as e:
        print("[!] Plugin %s failed on fetching filters!"%plugin.getName())
        print("[!]  -> %s"%e)
    return filters

  # Get's - Plug-in specific with stored data
  def cvePluginInfo(self, cve, **args):
    cveInfo = []
    for plugin in self.getWebPlugins():
@@ -169,21 +147,46 @@ class PluginManager():
          result['data'].append(entry)
    return result

# Filters
  def getFilters(self, **args):
    filters = []
  # Actions
  def onCVEOpen(self, cve, **args):
    for plugin in self.getWebPlugins():
      plugin.onCVEOpen(cve, **args)

  def onCVEAction(self, cve, plugin, action, **args):
    if plugin.strip() in self.plugins.keys(): # Check if plugin exists
      if self.plugins[plugin].isWebPlugin():  # Check if plugin is web plugin
        try:
        filters_ = plugin.getFilters(**args)
        if filters_:
          for filter_ in filters_:
            filter_['auth']   = plugin.requiresAuth
            filter_['plugin'] = plugin.getUID()
            filters.append(filter_)
          return self.plugins[plugin].onCVEAction(cve, action, **args)
        except Exception as e:
        print("[!] Plugin %s failed on fetching filters!"%plugin.getName())
          print("[!] Failed to perform %s action on module %s: "%(action, plugin))
          print("[!]  -> %s"%e)
    return filters

  def openPage(self, name, **args):
    if name.strip() in self.plugins.keys(): # Check if plugin exists
      if self.plugins[name].isWebPlugin():  # Check if plugin is web plugin
        pageInfo = self.plugins[name].getPage(**args)
        if type(pageInfo) == tuple:
          page, content = pageInfo
          if page: return ("plugins/%s"%page, content)
          else:    return None
        else:
          return ("error.html", {'status': {'except': 'plugin-page-missing'}})
      else:
        return ("error.html", {'status': {'except': 'plugin-not-webplugin'}})
    return ("error.html", {'status': {'except': 'plugin-not-loaded'}})

  def openSubpage(self, subpage, **args):
    if name.strip() in self.plugins.keys(): # Check if plugin exists
      if self.plugins[name].isWebPlugin():  # Check if plugin is web plugin
        pageInfo = self.plugins[name].getSubpage(subpage, **args)
        if type(pageInfo) == tuple:
          page, content = pageInfo
          if page: return ("plugins/%s"%page, content)
        # Else, the page is missing, so we send None to throw a 404
        return None
      else:
        return ("error.html", {'status': {'except': 'plugin-not-webplugin'}})
    return ("error.html", {'status': {'except': 'plugin-not-loaded'}})

  def doFilter(self, filters, **args):
    plug_fils = {key[5:]: value for (key, value) in filters.items() if key.startswith('plug_')}