mirror of
https://github.com/fleetdm/fleet
synced 2026-05-24 09:28:54 +00:00
26 lines
849 B
JavaScript
26 lines
849 B
JavaScript
import { flatten, map, flatMap, sortBy } from 'lodash';
|
|
import osqueryTablesJSON from '../osquery_tables.json';
|
|
|
|
const appendPlatformKeyToTables = (parsedTables) => {
|
|
return map(parsedTables, (platform) => {
|
|
return platform.tables.map((table) => {
|
|
table.platform = platform.key;
|
|
|
|
return table;
|
|
});
|
|
});
|
|
};
|
|
|
|
export const normalizeTables = (tablesJSON) => {
|
|
const { tables: parsedTables } = typeof tablesJSON === 'object' ? tablesJSON : JSON.parse(tablesJSON);
|
|
const tablesWithPlatformKey = appendPlatformKeyToTables(parsedTables);
|
|
|
|
const flattenedTables = flatten(tablesWithPlatformKey);
|
|
|
|
return sortBy(flattenedTables, (table) => { return table.name; });
|
|
};
|
|
|
|
export const osqueryTables = normalizeTables(osqueryTablesJSON);
|
|
export const osqueryTableNames = flatMap(osqueryTables, (table) => {
|
|
return table.name;
|
|
});
|