2021-04-12 13:32:25 +00:00
|
|
|
import { flatMap, sortBy } from "lodash";
|
2022-04-22 16:45:35 +00:00
|
|
|
// @ts-ignore
|
2021-04-12 13:32:25 +00:00
|
|
|
import osqueryTablesJSON from "../osquery_tables.json";
|
2016-10-11 15:32:39 +00:00
|
|
|
|
2022-04-22 16:45:35 +00:00
|
|
|
export const normalizeTables = (
|
|
|
|
tablesJSON: Record<string, unknown> | string
|
|
|
|
) => {
|
2020-07-07 16:47:50 +00:00
|
|
|
// osquery JSON needs less parsing than it used to
|
2021-04-12 13:32:25 +00:00
|
|
|
const parsedTables =
|
|
|
|
typeof tablesJSON === "object" ? tablesJSON : JSON.parse(tablesJSON);
|
|
|
|
return sortBy(parsedTables, (table) => {
|
|
|
|
return table.name;
|
|
|
|
});
|
2016-10-11 15:32:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const osqueryTables = normalizeTables(osqueryTablesJSON);
|
|
|
|
export const osqueryTableNames = flatMap(osqueryTables, (table) => {
|
|
|
|
return table.name;
|
|
|
|
});
|