def call(self, context): """Internal routing for this plugin type. Do not override this method. """ if "action" not in context: return ExtensionResponse( status=ExtensionStatus(code=1, message=self._no_action_message,), response=[],) if context["action"] == "generate": ctx = {} if "context" in context: ctx = json.dumps(context["context"]) rows = self.generate(ctx) for i, row in enumerate(rows): for key, value in row.items(): if not isinstance(value, str): try: rows[i][key] = str(value) except ValueError as e: rows[i][key] = '' logging.error("Cannot convert key %s: %s" % ( i, key, str(e))) return ExtensionResponse( status=ExtensionStatus(code=0, message="OK",), response=rows) elif context["action"] == "columns": return ExtensionResponse( status=ExtensionStatus(code=0, message="OK",), response=self.routes(),) return ExtensionResponse(code=1, message="Unknown action",)
def call(self, context): """Internal routing for this plugin type. Do not override this method. """ if "action" not in context: return ExtensionResponse( status=ExtensionStatus( code=1, message=self._no_action_message, ), response=[], ) if context["action"] == "generate": ctx = {} if "context" in context: ctx = json.dumps(context["context"]) return ExtensionResponse( status=ExtensionStatus( code=0, message="OK", ), response=self.generate(ctx), ) elif context["action"] == "columns": return ExtensionResponse( status=ExtensionStatus( code=0, message="OK", ), response=self.routes(), )
def call(self, context): """Internal routing for this plugin type. Do not override this method. """ if "action" in context: if context["action"] == "genConfig": return ExtensionResponse(status=ExtensionStatus(code=0, message="OK",), response=self.content(),) message = "Not a valid config plugin action" return ExtensionResponse(status=ExtensionStatus(code=1, message=message,), response=[],)
def call(self, registry, item, request): """The entry-point for plugin requests When a plugin is accessed from another process, osquery core's extension manager will send a thrift request to the implementing extension manager's call method. Arguments: registry -- a string representing what registry is being accessed. for config plugins this is "config", for table plugins this is "table", etc. item -- the registry item that is being requested. this is the "name" of your plugin. for example, this would be the exact name of the SQL table, if the plugin was a table plugin. """ # this API only support plugins of the following types: # - table # - config # - logger if registry not in ["table", "config", "logger"]: message = "A registry of an unknown type was called: %s" % registry return ExtensionResponse( status=ExtensionStatus( code=1, message=message, ), response=[], ) try: return self._plugins[registry][item].call(request) except KeyError: message = "Extension registry does not contain requested plugin" return ExtensionResponse( status=ExtensionStatus( code=1, message=message, ), response=[], )
def call(self, context): """Internal routing for this plugin type. Do not override this method. """ if "string" in context: return ExtensionResponse( status=self.log_string(context["string"]), response=[], ) elif "snapshot" in context: return ExtensionResponse( status=self.log_snapshot(context["snapshot"]), response=[], ) elif "health" in context: return ExtensionResponse( status=self.log_health(context["health"]), response=[], ) elif "init" in context: return ExtensionResponse( status=ExtensionStatus( code=1, message=self._use_glog_message, ), response=[], ) elif "status" in context: return ExtensionResponse( status=ExtensionStatus( code=1, message=self._use_glog_message, ), response=[], ) else: return ExtensionResponse( status=ExtensionStatus( code=1, message=self._invalid_action_message, ), response=[], )