1313from abc import ABCMeta , abstractmethod
1414from collections import namedtuple
1515import json
16+ import logging
1617
1718from osquery .extensions .ttypes import ExtensionResponse , ExtensionStatus
1819from osquery .plugin import BasePlugin
@@ -38,13 +39,24 @@ def call(self, context):
3839 ctx = {}
3940 if "context" in context :
4041 ctx = json .dumps (context ["context" ])
42+ rows = self .generate (ctx )
43+ for i , row in enumerate (rows ):
44+ for key , value in row .items ():
45+ if not isinstance (value , basestring ):
46+ try :
47+ rows [i ][key ] = str (value )
48+ except ValueError as e :
49+ rows [i ][key ] = ''
50+ logging .error ("Cannot convert key %s: %s" % (
51+ i , key , str (e )))
4152 return ExtensionResponse (
4253 status = ExtensionStatus (code = 0 , message = "OK" ,),
43- response = self . generate ( ctx ), )
54+ response = rows )
4455 elif context ["action" ] == "columns" :
4556 return ExtensionResponse (
4657 status = ExtensionStatus (code = 0 , message = "OK" ,),
4758 response = self .routes (),)
59+ return ExtensionResponse (code = 1 , message = "Unknown action" ,)
4860
4961 def registry_name (self ):
5062 """The name of the registry type for table plugins.
0 commit comments