policy: Draft bluetooth virtual table
authorSangwan Kwon <sangwan.kwon@samsung.com>
Thu, 20 Feb 2020 04:33:06 +0000 (13:33 +0900)
committer권상완/Security 2Lab(SR)/Engineer/삼성전자 <sangwan.kwon@samsung.com>
Tue, 25 Feb 2020 05:08:55 +0000 (14:08 +0900)
Signed-off-by: Sangwan Kwon <sangwan.kwon@samsung.com>
policy/bluetooth.md [new file with mode: 0644]

diff --git a/policy/bluetooth.md b/policy/bluetooth.md
new file mode 100644 (file)
index 0000000..15fa684
--- /dev/null
@@ -0,0 +1,63 @@
+# Bluetooth Policy Virtual Table
+
+| Table  | Column | Type | Value |
+|---|---|---|---|
+| bluetooth | state | int | 0 = off , 1 = on |
+|   | desktop_connectivity | int | 0 = off , 1 = on |
+|   | tethering | int | 0 = off , 1 = on |
+|   | pairing | int | 0 = off , 1 = on |
+
+## Get bluetooth policies
+```sql
+  SELECT * FROM bluetooth
+  SELECT state FROM bluetooth
+  SELECT desktop_connectivity FROM bluetooth
+  SELECT pairing FROM bluetooth
+  SELECT tethering FROM bluetooth
+```
+
+## Set bluetooth policies
+```sql
+  UPDATE bluetooth SET state = 1 # on
+  UPDATE bluetooth SET desktop_connectivity = 0 # off
+  UPDATE bluetooth SET pairing = 1 # on
+  UPDATE bluetooth SET tethering = 0 # off
+  UPDATE bluetooth SET state = 1, pairing = 0
+```
+
+# Query Builder
+## Schema
+```cpp
+  struct Bluetooth {
+    int state;
+    int desktopConnectivity;
+    int pairing;
+    int tethering; 
+
+    DECLARE_COLUMN(State, "state", &Bluetooth::state);
+    DECLARE_COLUMN(DesktopConnectivity, "desktop_connectivity", &Bluetooth::DesktopConnectivity);
+    DECLARE_COLUMN(Pairing, "pairing", &Bluetooth::pairing);
+    DECLARE_COLUMN(Tethering, "tethering", &Bluetooth::tethering);
+  };
+  
+  DECLARE_TABLE(bluetoothTable, "bluetooth", Bluetooth::State,
+                                             Bluetooth::DesktopConnectivity,
+                                             Bluetooth::Pairing,
+                                             Bluetooth::Tethering);
+```
+
+## Generate type-safed query
+
+```cpp
+// SELECT * FROM bluetooth
+  bluetoothTable.selectAll();
+  
+// SELECT state FROM bluetooth
+  bluetoothTable.selectAll(Bluetooth::State);
+
+// UPDATE bluetooth SET state = 1
+  bluetoothTable.update(Bluetooth::State = 1);
+
+// UPDATE bluetooth SET state = 1, pairing = 0
+  bluetoothTable.update(Bluetooth::State = 1, Bluetooth::Pairing = 0);
+```