mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-07 09:58:54 +00:00
Fix JSON output from --json (#4134)
This commit is contained in:
parent
f89392bdb4
commit
94b48ea87f
@ -137,7 +137,6 @@ void jsonPrint(const QueryData& q) {
|
||||
std::string row_string;
|
||||
|
||||
if (serializeRowJSON(q[i], row_string).ok()) {
|
||||
row_string.pop_back();
|
||||
printf(" %s", row_string.c_str());
|
||||
if (i < q.size() - 1) {
|
||||
printf(",\n");
|
||||
|
@ -181,6 +181,24 @@ class OsqueryiTest(unittest.TestCase):
|
||||
result = self.osqueryi.run_command(command)
|
||||
pass
|
||||
|
||||
def test_json_output(self):
|
||||
'''Test that the output of --json is valid json'''
|
||||
proc = test_base.TimeoutRunner([
|
||||
self.binary,
|
||||
"select 0",
|
||||
"--disable_extensions",
|
||||
"--json",
|
||||
],
|
||||
SHELL_TIMEOUT
|
||||
)
|
||||
if os.name == "nt":
|
||||
self.assertEqual(proc.stdout, "[\r\n {\"0\":\"0\"}\r\n]\r\n")
|
||||
else:
|
||||
self.assertEqual(proc.stdout, "[\n {\"0\":\"0\"}\n]\n")
|
||||
print(proc.stdout)
|
||||
print(proc.stderr)
|
||||
self.assertEqual(proc.proc.poll(), 0)
|
||||
|
||||
@test_base.flaky
|
||||
def test_time(self):
|
||||
'''Demonstrating basic usage of OsqueryWrapper with the time table'''
|
||||
|
Loading…
Reference in New Issue
Block a user