1 # Programming interface for client
6 ## Check smack table schema
10 | subject_label | TEXT |
11 | object_label | TEXT |
12 | access_type | TEXT |
15 ## Use OsqueryManager to get smack information
17 using namespace osquerypp;
19 // 1. Write query as std::string
20 std::string query = "SELECT subject_label, object_label FROM smack WHERE access_type = 'read'";
22 // 2. Load OsqueryManager
23 auto manager = OsqueryManager::Load();
25 // 3. Execute query by using OsqueryManager
26 auto rows = OsqueryManager::executeQuery(query);
29 for (const auto& row : rows) {
30 std::string slabel = row["subject_label"];
31 std::string olabel = row["object_label];
35 # #2. Subscribe event table
36 ## Check smack_deny_events table schema
37 - The name of the event table ends with *_events.
38 ### 'smack_deny_events' table
42 | subject_label | TEXT |
43 | object_label | TEXT |
44 | access_type | TEXT |
49 ## Use OsqueryManager to subscribe smack-deny-events
51 using namespace osquerypp;
53 // 1. Write callback function
54 auto onDeny = [&](const EventContext& ec, const Row& row)
56 // get data of event table
57 std::cout << row["action"] << std::endl;
58 std::cout << row["permission"] << std::endl;
59 std::cout << row["subject_label"] << std::endl;
60 std::cout << row["object_label"] << std::endl;
63 // 2. Load OsqueryManager
64 auto manager = OsqueryManager::Load();
66 // 3. Register callback with event_table by using OsqueryManager
67 OsqueryManager::subscribe("smack_deny_events", onDeny);