From: i.metelytsia Date: Tue, 6 Mar 2018 12:14:12 +0000 (+0200) Subject: [SECARSP-135] - DPM integration X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3760a58db9bc3dcd417c058090ba256dcc99d43c;p=platform%2Fcore%2Fsecurity%2Fsuspicious-activity-monitor.git [SECARSP-135] - DPM integration Change-Id: I8ae0a20f09cefabf46c6d9b92b4fc25fc9331f6d --- diff --git a/device-agent/samonitor/application_service.cpp b/device-agent/samonitor/application_service.cpp index d40ea86..c15d64e 100644 --- a/device-agent/samonitor/application_service.cpp +++ b/device-agent/samonitor/application_service.cpp @@ -36,6 +36,7 @@ int ApplicationService::install(const std::string& package_path_name) device_policy_manager_h handle = dpm_manager_create(); if (handle) { res = dpm_application_install_package(handle, package_path_name.c_str()); + LOG_D(TAG, "dpm_application_install_package returned %d", res); dpm_manager_destroy(handle); } return res; diff --git a/device-agent/samonitor/dpm/dpm_api_mapper.cpp b/device-agent/samonitor/dpm/dpm_api_mapper.cpp index 8e5c6c0..78d1f79 100644 --- a/device-agent/samonitor/dpm/dpm_api_mapper.cpp +++ b/device-agent/samonitor/dpm/dpm_api_mapper.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "logging.h" #include "samonitor_tag.h" @@ -42,15 +43,15 @@ typedef function ApiStr; typedef function ApiIntStr; const map m = { - {"lockout-screen", dpm_security_lockout_screen}, + {"lockout-screen", dpm_security_lockout_screen}, }; const map mi = { - {"sound", dpm_restriction_set_sound_state}, + {"sound", dpm_tv_set_sound_state}, {"bluetooth", dpm_restriction_set_bluetooth_mode_change_state}, {"wifi", dpm_restriction_set_wifi_state}, {"usb", dpm_restriction_set_usb_client_state}, - {"dtv-tunner", dpm_restriction_set_tuner_state}, + {"dtv-tunner", dpm_tv_set_tuner_state}, {"camera", dpm_restriction_set_camera_state}, {"microphone", dpm_restriction_set_microphone_state}, @@ -85,19 +86,6 @@ const map ms = { }; -#ifdef USE_MIS -const map mis; -#endif - - -// {"wipe external data", dpm_security_wipe_data}, -// {"wipe internal data", dpm_security_wipe_data}, -// {"messaging", dpm_restriction_set_messaging_state}, -// {"privil-add", dpm_application_add_privilege_to_blacklist}, -// {"privil-del", dpm_application_remove_privilege_from_blacklist}, -// {"package-set", dpm_application_set_mode_restriction}, -// {"package-unset", dpm_application_unset_mode_restriction}, - Mapper::Mapper() : handle(nullptr) { } @@ -201,11 +189,7 @@ dpm_api::ErrorCode Mapper::apply(const std::string& name, const int param, const uid_t owner; try { -#ifndef __MOCK_THIRDPARTY__ owner = getUidByName("owner"); -#else - owner = root; -#endif } catch (std::runtime_error& e) { LOG_E(TAG, "getUidByName(): %s", e.what()); return NO_DATA; @@ -260,18 +244,5 @@ dpm_api::ErrorCode Mapper::work(const std::string& name, const int param, const return convert_err(res); } -#ifdef USE_MIS - auto itis = mis.find(name); - if (itis != mis.end()) { - for (auto& item : items) { - res = itis->second((dpmh)handle, param, item.c_str()); - if (res != DPM_ERROR_NONE) { - break; - } - } - return convert_err(res); - } -#endif - return NAME_NOT_FOUND; } diff --git a/device-agent/scripts/gbs.conf b/device-agent/scripts/gbs.conf index c1e0eef..49f3070 100644 --- a/device-agent/scripts/gbs.conf +++ b/device-agent/scripts/gbs.conf @@ -56,12 +56,12 @@ buildroot = ~/gbs_root_tm1_tizen4 url=http://10.103.211.119/220svr/releases/adv-tizen-4.0-product-migration/KantM_ATSC/latest/repos/product/armv7l/packages/ [repo.base_Main2017_KantM_4.0] url=http://10.103.211.119/220svr/base/adv-tizen-4.0-base-migration/standard/latest/repos/base/armv7l/packages -[repo.KantM_4.0_srk] -url = http://52.71.167.178:8803/repo/kantm4.0/packages/ +[repo.KantM_4.0_2018_srk] +url = http://52.71.167.178:8803/repo/kantm4.0_2018/packages/ [profile.kantm_tizen4] obs = obs.tizen_org -repos = repo.base_Main2017_KantM_4.0, repo.KantM_4.0_srk, repo.product_Main2017_KantM_4.0 +repos = repo.base_Main2017_KantM_4.0, repo.KantM_4.0_2018_srk, repo.product_Main2017_KantM_4.0 buildroot = ~/gbs_root_kantm_tizen4 ############################################# Profile [profile.kantm2_tizen5] diff --git a/device-agent/utest/mock/device_policy_manager_mock.h b/device-agent/utest/mock/device_policy_manager_mock.h index 4a05c1d..72299a3 100644 --- a/device-agent/utest/mock/device_policy_manager_mock.h +++ b/device-agent/utest/mock/device_policy_manager_mock.h @@ -67,10 +67,10 @@ public: MOCK_METHOD1(dpm_restriction_set_usb_client_state, int(int allow)); MOCK_METHOD1(dpm_restriction_get_usb_client_state, int(int* is_allowed)); - MOCK_METHOD1(dpm_restriction_set_sound_state, int(int allow)); - MOCK_METHOD1(dpm_restriction_get_sound_state, int(int* is_allowed)); - MOCK_METHOD1(dpm_restriction_set_tuner_state, int(int allow)); - MOCK_METHOD1(dpm_restriction_get_tuner_state, int(int* is_allowed)); + MOCK_METHOD1(dpm_tv_set_sound_state, int(int allow)); + MOCK_METHOD1(dpm_tv_get_sound_state, int(int* is_allowed)); + MOCK_METHOD1(dpm_tv_set_tuner_state, int(int allow)); + MOCK_METHOD1(dpm_tv_get_tuner_state, int(int* is_allowed)); }; #endif // DEVICEPOLICYMANAGERMOCK_H diff --git a/device-agent/utest/mock/device_policy_manager_stub.cpp b/device-agent/utest/mock/device_policy_manager_stub.cpp index db2c476..b655571 100644 --- a/device-agent/utest/mock/device_policy_manager_stub.cpp +++ b/device-agent/utest/mock/device_policy_manager_stub.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include "device_policy_manager_stub.h" @@ -244,23 +245,23 @@ int dpm_restriction_get_usb_client_state(device_policy_manager_h handle, int* is assert(handle != nullptr); return reinterpret_cast(handle)->dpm_restriction_get_usb_client_state(is_allowed); } -int dpm_restriction_set_sound_state(device_policy_manager_h handle, int allow) +int dpm_tv_set_sound_state(device_policy_manager_h handle, int allow) { assert(handle != nullptr); - return reinterpret_cast(handle)->dpm_restriction_set_sound_state(allow); + return reinterpret_cast(handle)->dpm_tv_set_sound_state(allow); } -int dpm_restriction_get_sound_state(device_policy_manager_h handle, int* is_allowed) +int dpm_tv_get_sound_state(device_policy_manager_h handle, int* is_allowed) { assert(handle != nullptr); - return reinterpret_cast(handle)->dpm_restriction_get_sound_state(is_allowed); + return reinterpret_cast(handle)->dpm_tv_get_sound_state(is_allowed); } -int dpm_restriction_set_tuner_state(device_policy_manager_h handle, int allow) +int dpm_tv_set_tuner_state(device_policy_manager_h handle, int allow) { assert(handle != nullptr); - return reinterpret_cast(handle)->dpm_restriction_set_tuner_state(allow); + return reinterpret_cast(handle)->dpm_tv_set_tuner_state(allow); } -int dpm_restriction_get_tuner_state(device_policy_manager_h handle, int* is_allowed) +int dpm_tv_get_tuner_state(device_policy_manager_h handle, int* is_allowed) { assert(handle != nullptr); - return reinterpret_cast(handle)->dpm_restriction_get_tuner_state(is_allowed); + return reinterpret_cast(handle)->dpm_tv_get_tuner_state(is_allowed); } diff --git a/device-agent/utest/mock/device_policy_manager_stub.h b/device-agent/utest/mock/device_policy_manager_stub.h index 97d2404..9e6ed50 100644 --- a/device-agent/utest/mock/device_policy_manager_stub.h +++ b/device-agent/utest/mock/device_policy_manager_stub.h @@ -63,10 +63,10 @@ public: virtual int dpm_restriction_set_usb_client_state(int allow) = 0; virtual int dpm_restriction_get_usb_client_state(int* is_allowed) = 0; - virtual int dpm_restriction_set_sound_state(int allow) = 0; - virtual int dpm_restriction_get_sound_state(int* is_allowed) = 0; - virtual int dpm_restriction_set_tuner_state(int allow) = 0; - virtual int dpm_restriction_get_tuner_state(int* is_allowed) = 0; + virtual int dpm_tv_set_sound_state(int allow) = 0; + virtual int dpm_tv_get_sound_state(int* is_allowed) = 0; + virtual int dpm_tv_set_tuner_state(int allow) = 0; + virtual int dpm_tv_get_tuner_state(int* is_allowed) = 0; }; /** @@ -245,19 +245,19 @@ public: { return 0; } - int dpm_restriction_set_sound_state(int allow) override + int dpm_tv_set_sound_state(int allow) override { return 0; } - int dpm_restriction_get_sound_state(int* is_allowed) override + int dpm_tv_get_sound_state(int* is_allowed) override { return 0; } - int dpm_restriction_set_tuner_state(int allow) override + int dpm_tv_set_tuner_state(int allow) override { return 0; } - int dpm_restriction_get_tuner_state(int* is_allowed) override + int dpm_tv_get_tuner_state(int* is_allowed) override { return 0; } diff --git a/device-agent/utest/test_common_enforce.cpp b/device-agent/utest/test_common_enforce.cpp index f7897c8..e9d4ce2 100644 --- a/device-agent/utest/test_common_enforce.cpp +++ b/device-agent/utest/test_common_enforce.cpp @@ -21,7 +21,7 @@ TEST(Test_CommonPolicyEnforce, test_ParseGroup) EXPECT_CALL(dpm, dpm_manager_create()).WillOnce(Return(&dpm)); - EXPECT_CALL(dpm, dpm_restriction_set_sound_state(1)).WillOnce(Return(0)); + EXPECT_CALL(dpm, dpm_tv_set_sound_state(1)).WillOnce(Return(0)); EXPECT_CALL(dpm, dpm_restriction_set_camera_state(0)).WillOnce(Return(0)); EXPECT_CALL(dpm, dpm_manager_destroy()).Times(1); diff --git a/device-agent/utest/test_tvext_policy_enforce.cpp b/device-agent/utest/test_tvext_policy_enforce.cpp index 061ca0b..5be0f82 100644 --- a/device-agent/utest/test_tvext_policy_enforce.cpp +++ b/device-agent/utest/test_tvext_policy_enforce.cpp @@ -24,12 +24,12 @@ TEST(Test_TvExtPolicyEnforce, test_ParseGroup) EXPECT_CALL(dpm, dpm_manager_create()).WillOnce(Return(&dpm)); - EXPECT_CALL(dpm, dpm_restriction_set_sound_state(1)).WillOnce(Return(0)); + EXPECT_CALL(dpm, dpm_tv_set_sound_state(1)).WillOnce(Return(0)); EXPECT_CALL(dpm, dpm_restriction_set_bluetooth_mode_change_state(1)).WillOnce(Return(0)); EXPECT_CALL(dpm, dpm_restriction_set_wifi_state(0)).WillOnce(Return(0)); EXPECT_CALL(dpm, dpm_restriction_set_usb_client_state(0)).WillOnce(Return(0)); - EXPECT_CALL(dpm, dpm_restriction_set_tuner_state(1)).WillOnce(Return(0)); + EXPECT_CALL(dpm, dpm_tv_set_tuner_state(1)).WillOnce(Return(0)); EXPECT_CALL(dpm, dpm_manager_destroy()).Times(1); EXPECT_CALL(dpm, dpm_firewall_flush_deny_rules()).WillOnce(Return(0)); EXPECT_CALL(dpm, dpm_firewall_apply_deny_rules(_)).Times(3).WillRepeatedly(Return(0));