From 3ae88386638e7f543240059f5740d2af239a6335 Mon Sep 17 00:00:00 2001 From: Sangwan Kwon Date: Fri, 28 Feb 2020 14:18:50 +0900 Subject: [PATCH] Add schema API and query-builder API to README Signed-off-by: Sangwan Kwon --- README.md | 88 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index c4feae7..e11985e 100644 --- a/README.md +++ b/README.md @@ -5,13 +5,13 @@ Query-based Universial Security API --- -> Project ViST is inspired by [osquery](https://osquery.io/). +> Project ViST is forked from [osquery](https://osquery.io/). The purpose of ViST project is **"Provide unified interface to security software designer and developer -via type-safe query".** +via type-safe query".** For this we must achieve two things: 1. Provide **unified interface via query** 2. Generate **type-safe query via query-builder** @@ -64,51 +64,59 @@ ViST takes below features. # Architecture (Layered View) layered architecture -# Programming Abstraction -ViST provides three types of API. -One is for data structure and the other is for functional. +# Design +## Programming Abstraction +- Struct-based schema +1. query builder +2. query parser +3. virtual table -### Schema API -Schema API represents the data structure of Virtua Tables. -This is referred to by Client API and Admin API. +## Programming Interface +ViST provides three types of API. +One is for data structure(schema) +and the other is for functional. + +### Schema API (Header only library) +Schema API is a data structure API +to represent struct-based schema +referred by query builder API. +This inform virtual table schema to client and make type-safe query possible. + +- The schema of virtual table is correspond with struct. +- The column of schema is correspond with struct member. + +#### Table schema +| Table | Column | Type | +|---|---|---| +| ${TABLE_NAME} | ${COLUMN_NAME_1} | ${COLUMN_TYPE} | +| | ${COLUMN_NAME_2} | ${COLUMN_TYPE} | +| | ${COLUMN_NAME_3} | ${COLUMN_TYPE} | + +#### Struct-based schema ```cpp -/// policy schema API -template -struct Policy { - std::string name; - T value; -}; - -/// process schema API -struct Processes { - long long int pid; - std::string name; - std::string path; - std::string cmdline; - long long int uid; - long long int gid; - long long int euid; - long long int egid; - int on_disk; - long long int resident_size; - long long int parent; +struct ${TABLE_NAME} { + ${COLUMN_TYPE} ${COLUMN_NAME_1}; + ${COLUMN_TYPE} ${COLUMN_NAME_2}; + ${COLUMN_TYPE} ${COLUMN_NAME_3}; }; ``` -### Client API (SELECT) -Client API is a functioanl API for monitoring Virtual Tables. -Since Client API generates 'select query' by using query-builder, it doesn't need to write a query directly. -```cpp - /// Querying device policies using Client API - vist::VirtualTable> table; - for (const auto& row : table) { - vist::schema::Policy policy = { row[&Policy::name], row[&Policy::value] }; - std::cout << "Policy name: " << policy.name << ", "; - std::cout << "Policy value: " << policy.value << "\n"; - } +### Query builder API (Header only library) +Query builder API is a functioanl API to generate type-safed query. +This generate query statement via Schema API and check type-error for type-safe query. + +The CRUD clause is provided at ViST v1. + ``` +DECLARE_COLUMN(${COLUMN_INSTANCE}, ${COLUMN_NAME}, ${COLUMN_IDENTIFIER}); +DECLARE_TABLE(${TABLE_INSTANCE}, ${TABLE_NAME}, ${COLUMN_INSTANCE}); -### Admin API (SELECT, INSERT, UPDATE, DELETE) +%{TABLE_INSTANCE}.select(${COLUMN_INSTANCE}); +%{TABLE_INSTANCE}.insert(${COLUMN_INSTANCE} = ${COLUMN_VALUE}); +%{TABLE_INSTANCE}.update(${COLUMN_INSTANCE} = ${COLUMN_VALUE}); +%{TABLE_INSTANCE}.remove(${COLUMN_INSTANCE}); +``` +### Query execution API Admin API is a functioanl API for manipulating Virtual Tables. This executes the query statement for the virtual table. ```cpp -- 2.34.1