kibana/x-pack/plugins/osquery/public/editor/osquery_tables.ts
Bryan Clement d6370f4e51
updated osquery autocomplete to v4.7.0 schema (#95741)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2021-03-30 12:09:23 -07:00

30 lines
877 B
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { flatMap, sortBy } from 'lodash';
type TablesJSON = Array<{
name: string;
}>;
export const normalizeTables = (tablesJSON: TablesJSON) => {
return sortBy(tablesJSON, (table) => {
return table.name;
});
};
let osqueryTables: TablesJSON | null = null;
export const getOsqueryTables = () => {
if (!osqueryTables) {
// eslint-disable-next-line @typescript-eslint/no-var-requires
osqueryTables = normalizeTables(require('./osquery_schema/v4.7.0.json'));
}
return osqueryTables;
};
export const getOsqueryTableNames = () =>
flatMap(getOsqueryTables(), (table) => {
return table.name;
});