Draft bluetooth and usb policy
authorSangwan Kwon <sangwan.kwon@samsung.com>
Thu, 1 Aug 2019 02:09:38 +0000 (11:09 +0900)
committer권상완/Security 2Lab(SR)/Engineer/삼성전자 <sangwan.kwon@samsung.com>
Tue, 6 Aug 2019 04:20:50 +0000 (13:20 +0900)
Signed-off-by: Sangwan Kwon <sangwan.kwon@samsung.com>
osquery/tizen/device_policy/bluetooth_policy.h [new file with mode: 0644]
osquery/tizen/device_policy/usb_policy.h [new file with mode: 0644]

diff --git a/osquery/tizen/device_policy/bluetooth_policy.h b/osquery/tizen/device_policy/bluetooth_policy.h
new file mode 100644 (file)
index 0000000..4367893
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ *  Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+#pragma once
+
+#include <string>
+
+#include <bluetooth.h>
+#include <bluetooth-api.h>
+#include <bluetooth_internal.h>
+
+/// TODO(Sangwan): Move rmi header to policy-model
+#include <klay/rmi/service.h>
+#include <dpm/pil/policy-model.h>
+
+namespace osquery {
+
+/*
+       TODO List:
+               1. Change VLOG to LOG(ERROR).
+               2. Make sure that privilege model works with cynara.
+               3. Consider policy-violation model.
+               4. Unify exeception handling among getter/setter APIs.
+               5. Verify with full-DPM at runtime.
+*/
+
+class BluetoothPolicy final : public AbstractPolicyProvider {
+public:
+       struct Bluetooth : public GlobalPolicy<DataSetInt> {
+               Bluetooth();
+               bool apply(const DataType&) override;
+       };
+
+       struct DesktopConnectivity : public GlobalPolicy<DataSetInt> {
+               DesktopConnectivity();
+               bool apply(const DataType&) override;
+       };
+
+       struct Paring : public GlobalPolicy<DataSetInt> {
+               Paring();
+               bool apply(const DataType&) override;
+       };
+
+       struct Tethering : public GlobalPolicy<DataSetInt> {
+               Tethering();
+               bool apply(const DataType&) override;
+       };
+
+       BluetoothPolicy();
+       ~BluetoothPolicy();
+
+       BluetoothPolicy(const BluetoothPolicy&) = delete;
+       BluetoothPolicy& operator=(const BluetoothPolicy&) = delete;
+
+/* TODO: Support move semantic from parent class (GlobalPolicy)
+       BluetoothPolicy(BluetoothPolicy&&) noexcept;
+       BluetoothPolicy& operator=(BluetoothPolicy&&) noexcept;
+*/
+       void setBluetooth(bool enable);
+       bool getBluetooth(void);
+
+       void setDesktopConnectivity(bool enable);
+       bool getDesktopConnectivity(void);
+
+       void setParing(bool enable);
+       bool getParing(void);
+
+       void setTethering(bool enable);
+       bool getTethering(void);
+
+       static void onConnection(int result, bt_adapter_state_e state, void *user_data);
+
+       static const std::string PRIVILEGE;
+
+private:
+       Bluetooth bluetooth;
+       DesktopConnectivity desktopConnectivity;
+       Paring Paring;
+       Tethering tethering;
+
+};
+
+} // namespace osquery
diff --git a/osquery/tizen/device_policy/usb_policy.h b/osquery/tizen/device_policy/usb_policy.h
new file mode 100644 (file)
index 0000000..777b470
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ *  Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+#pragma once
+
+#include <string>
+
+/// TODO(Sangwan): Move rmi header to policy-model
+#include <klay/rmi/service.h>
+#include <dpm/pil/policy-model.h>
+
+namespace osquery {
+
+/*
+       TODO List:
+               1. Change VLOG to LOG(ERROR).
+               2. Make sure that privilege model works with cynara.
+               3. Consider policy-violation model.
+               4. Unify exeception handling among getter/setter APIs.
+               5. Verify with full-DPM at runtime.
+*/
+
+class UsbPolicy final : public AbstractPolicyProvider {
+public:
+       /// usb-client
+       struct Usb : public GlobalPolicy<DataSetInt> {
+               Usb();
+               bool apply(const DataType&) override;
+       };
+
+       struct Debugging : public GlobalPolicy<DataSetInt> {
+               Debugging();
+               bool apply(const DataType&) override;
+       };
+
+       struct Tethering : public GlobalPolicy<DataSetInt> {
+               Tethering();
+               bool apply(const DataType&) override;
+       };
+
+       UsbPolicy() = default;
+       ~UsbPolicy() = default;
+
+       UsbPolicy(const UsbPolicy&) = delete;
+       UsbPolicy& operator=(const UsbPolicy&) = delete;
+
+/* TODO: Support move semantic from parent class (GlobalPolicy)
+       UsbPolicy(UsbPolicy&&) noexcept;
+       UsbPolicy& operator=(UsbPolicy&&) noexcept;
+*/
+       void setUsb(bool enable);
+       bool getUsb(void);
+
+       void setDebugging(bool enable);
+       bool getDebugging(void);
+
+       void setTethering(bool enable);
+       bool getTethering(void);
+
+       static const std::string PRIVILEGE;
+
+private:
+       Usb Usb;
+       Debugging debugging;
+       Tethering tethering;
+};
+
+} // namespace osquery