Beispiel #1
0
    def view_json(self, FERListWidget, url, id, key):
        logger.info("[Field Extraction Rules]Viewing FER(s) as JSON")
        selecteditems = FERListWidget.selectedItems()
        if len(selecteditems) > 0:  # make sure something was selected
            try:
                sumo = SumoLogic(id,
                                 key,
                                 endpoint=url,
                                 log_level=self.mainwindow.log_level)
                json_text = ''
                for selecteditem in selecteditems:
                    for object in FERListWidget.currentcontent:
                        if object['name'] == str(selecteditem.text()):
                            item_id = object['id']
                            fer = sumo.get_fer(item_id)
                            json_text = json_text + json.dumps(
                                fer, indent=4, sort_keys=True) + '\n\n'
                self.json_window = ShowTextDialog('JSON', json_text,
                                                  self.mainwindow.basedir)
                self.json_window.show()

            except Exception as e:
                logger.exception(e)
                self.mainwindow.errorbox('Something went wrong:\n\n' + str(e))
                return

        else:
            self.mainwindow.errorbox('No FER selected.')
        return
Beispiel #2
0
    def view_role_json(self, RoleListWidget, url, id, key):
        logger.info("[Users and Roles]Viewing Roles(s) JSON")
        selecteditems = RoleListWidget.selectedItems()
        if len(selecteditems) > 0:  # make sure something was selected
            try:
                sumo = SumoLogic(id,
                                 key,
                                 endpoint=url,
                                 log_level=self.mainwindow.log_level)
                json_text = ''
                for selecteditem in selecteditems:
                    role_id = selecteditem.details['id']
                    role = sumo.get_role(role_id)
                    json_text = json_text + json.dumps(
                        role, indent=4, sort_keys=True) + '\n\n'
                self.json_window = ShowTextDialog('JSON', json_text,
                                                  self.mainwindow.basedir)
                self.json_window.show()

            except Exception as e:
                logger.exception(e)
                self.mainwindow.errorbox('Something went wrong:\n\n' + str(e))
                return
        else:
            self.mainwindow.errorbox('No role selected.')
        return
    def view_source_JSON(self, CollectorListWidget, SourceListWidget, url, id,
                         key):
        logger.info("[Collectors] Viewing Source JSON")
        sourcenames = SourceListWidget.selectedItems()
        if len(sourcenames) > 0:  # make sure at least one source is selected
            try:
                sumo = SumoLogic(id,
                                 key,
                                 endpoint=url,
                                 log_level=self.mainwindow.log_level)
                json_text = ''
                collectornamesqstring = CollectorListWidget.selectedItems(
                )  # get collectors sources have been selected
                collectorname = str(collectornamesqstring[0].text())
                collector = sumo.get_collector_by_name_alternate(collectorname)
                sources = sumo.get_sources_sync(collector['id'])
                for sourcename in sourcenames:
                    for source in sources:
                        if ('name' in source
                                and str(sourcename.text()) == source['name']
                            ) or ('config' in source and str(sourcename.text())
                                  == source['config']['name']):
                            json_text = json_text + json.dumps(
                                source, indent=4, sort_keys=True) + '\n\n'
                self.json_window = ShowTextDialog('JSON', json_text,
                                                  self.mainwindow.basedir)
                self.json_window.show()

            except Exception as e:
                logger.exception(e)
                self.mainwindow.errorbox('Something went wrong:\n\n' + str(e))

        else:
            self.mainwindow.errorbox('No Source Selected.')
 def view_collector_JSON(self, CollectorListWidget, url, id, key):
     logger.info("[Collectors] Viewing Collector JSON")
     collectornamesqstring = CollectorListWidget.selectedItems(
     )  # get collectors sources have been selected
     if len(collectornamesqstring) > 0:  # make sure something was selected
         try:
             sumo = SumoLogic(id,
                              key,
                              endpoint=url,
                              log_level=self.mainwindow.log_level)
             json_text = ''
             for collectornameqstring in collectornamesqstring:
                 collector = sumo.get_collector_by_name_alternate(
                     str(collectornameqstring.text()))
                 # sources = sumo.get_sources_sync(collector['id'])
                 json_text = json_text + json.dumps(
                     collector, indent=4, sort_keys=True) + '\n\n'
                 # json_text = json_text + json.dumps(sources, indent=4, sort_keys=True) + '\n\n'
             self.json_window = ShowTextDialog('JSON', json_text,
                                               self.mainwindow.basedir)
             self.json_window.show()
         except Exception as e:
             logger.exception(e)
             self.mainwindow.errorbox('Something went wrong:\n\n' + str(e))
     else:
         self.mainwindow.errorbox('No Collector Selected.')
     return
    def view_monitor_json(self, MonitorListWidget, url, id, key):
        logger.info("[Monitors and Connections]Viewing Monitor(s) JSON")
        selecteditems = MonitorListWidget.selectedItems()
        if len(selecteditems) > 0:  # make sure something was selected
            try:
                sumo = SumoLogic(id, key, endpoint=url, log_level=self.mainwindow.log_level)
                json_text = ''
                for selecteditem in selecteditems:
                    for object in MonitorListWidget.currentcontent['children']:
                        if object['name'] == str(selecteditem.text()):
                            item_id = object['id']
                            user = sumo.export_monitor(item_id)
                            json_text = json_text + json.dumps(user, indent=4, sort_keys=True) + '\n\n'
                self.json_window = ShowTextDialog('JSON', json_text, self.mainwindow.basedir)
                self.json_window.show()

            except Exception as e:
                logger.exception(e)
                self.mainwindow.errorbox('Something went wrong:\n\n' + str(e))
                return
        else:
            self.mainwindow.errorbox('No monitor selected.')
        return