IF Commons GitHub

sql/extensions/osquery/schema

Written to: 3 requirements: 3 proved, 0 partly, 0 failing, 0 with no test recorded. 0058-sql-osquery FR-003, 0058-sql-osquery FR-001, 0058-sql-osquery FR-002

The machine facts of osquery as a schema (commons data 0058-sql-osquery): the published schema of one version of osquery, read as a value and imported through the live-database path (0055) into a logical schema, so that it is never written by hand. Each table says on which platforms it exists and whether it is evented, each column says if it is hidden, required or an index and on which platforms it exists, the columns that hold personal data are marked (classify.ts), and the schema is stamped with the version of osquery it describes.

Source: commons/data/sql/extensions/osquery/schema.ts

3 of 10 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

importSchemafunction
function importSchema(schema: OsquerySchema, platform?: Platform | undefined): Result<LogicalSchema, readonly AdoptError[]>

The logical schema of a version of osquery, made through adopt and not by hand: names and types come from the published schema, each table is annotated with its platforms and whether it is evented, each column with whether it is hidden, required or an index, and each column that holds personal data with its category and what it is held for; the schema is stamped with the version.

ParameterWhat it is
schemathe published schema
platformleave out what does not exist on this platform; every platform where not given

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

osqueryconstno test imports it
const osquery: { readonly version: AnnotationKind<string>; readonly platforms: AnnotationKind<readonly Platform[]>; readonly evented: AnnotationKind<boolean>; readonly column: AnnotationKind<{ readonly hidden: boolean; readonly required: boolean; readonly index: boolean; }>; }

Where the library's own annotations of osquery are written: osquery.version on the schema, osquery.platforms and osquery.evented on a table, osquery.column on a column.

OsqueryColumninterfaceno test imports it
interface OsqueryColumn

A column as osquery publishes it.

MemberTypeWhat it is
namestring
descriptionstring
typeOsqueryType
hiddenboolean
requiredboolean
indexboolean
platforms?readonly Platform[]Where it exists, where that is fewer places than its table.
OsquerySchemainterface
interface OsquerySchema

The published schema of one version of osquery.

MemberTypeWhat it is
versionstring
source{ readonly repository: string; readonly commit: string; readonly path: string; readonly sha256: string; readonly license: string; }
tablesreadonly OsqueryTable[]

Imported by 7 tests of the run (7 passed, 0 failed): the library's results

OsqueryTableinterfaceno test imports it
interface OsqueryTable

A table as osquery publishes it.

MemberTypeWhat it is
namestring
descriptionstring
platformsreadonly Platform[]
eventedboolean
cacheableboolean
columnsreadonly OsqueryColumn[]
OsqueryTypetypeno test imports it
type OsqueryType = "text" | "integer" | "bigint" | "unsigned_bigint" | "double" | "blob";

The types of an osquery column.

Platformtypeno test imports it
type Platform = "linux" | "darwin" | "windows";

The platforms osquery runs on, as this library names them.

PLATFORMSconstno test imports it
const PLATFORMS: readonly Platform[]

The platforms osquery tables are for: linux, darwin and windows.

readSchemafunction
function readSchema(json: unknown): Result<OsquerySchema, string>

Reads the published schema file (the trimmed JSON of tools/osquery-schema.ts) into a value, or says what is wrong with it.

ParameterWhat it is
jsonthe parsed file

Imported by 14 tests of the run (14 passed, 0 failed): the library's results

toObservedfunctionno test imports it
function toObserved(schema: OsquerySchema, platform?: Platform | undefined): Observed

The schema as what a database holds (0055): the tables with their columns as osquery types them, and no key, since osquery has none. A table is left out where it does not exist on the platform asked for.

Titles, headings, exports, tables, columns and requirements. Esc closes.