2016-10-11 15:32:39 +00:00
|
|
|
import { flatten, map, flatMap } from 'lodash';
|
2016-10-21 23:13:41 +00:00
|
|
|
import osqueryTablesJSON from '../osquery_tables.json';
|
2016-10-11 15:32:39 +00:00
|
|
|
|
|
|
|
const appendPlatformKeyToTables = (parsedTables) => {
|
|
|
|
return map(parsedTables, (platform) => {
|
2016-10-21 23:13:41 +00:00
|
|
|
return platform.tables.map((table) => {
|
2016-10-11 15:32:39 +00:00
|
|
|
table.platform = platform.key;
|
|
|
|
|
|
|
|
return table;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
export const normalizeTables = (tablesJSON) => {
|
|
|
|
const { tables: parsedTables } = typeof tablesJSON === 'object' ? tablesJSON : JSON.parse(tablesJSON);
|
|
|
|
const tablesWithPlatformKey = appendPlatformKeyToTables(parsedTables);
|
|
|
|
|
|
|
|
return flatten(tablesWithPlatformKey);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const osqueryTables = normalizeTables(osqueryTablesJSON);
|
|
|
|
export const osqueryTableNames = flatMap(osqueryTables, (table) => {
|
|
|
|
return table.name;
|
|
|
|
});
|