13
13
from abc import ABCMeta , abstractmethod
14
14
from collections import namedtuple
15
15
import json
16
+ import logging
16
17
17
18
from osquery .extensions .ttypes import ExtensionResponse , ExtensionStatus
18
19
from osquery .plugin import BasePlugin
@@ -38,13 +39,24 @@ def call(self, context):
38
39
ctx = {}
39
40
if "context" in context :
40
41
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 )))
41
52
return ExtensionResponse (
42
53
status = ExtensionStatus (code = 0 , message = "OK" ,),
43
- response = self . generate ( ctx ), )
54
+ response = rows )
44
55
elif context ["action" ] == "columns" :
45
56
return ExtensionResponse (
46
57
status = ExtensionStatus (code = 0 , message = "OK" ,),
47
58
response = self .routes (),)
59
+ return ExtensionResponse (code = 1 , message = "Unknown action" ,)
48
60
49
61
def registry_name (self ):
50
62
"""The name of the registry type for table plugins.
0 commit comments