mirror of
https://gitee.com/openharmony/security_security_guard
synced 2024-11-23 14:39:47 +00:00
Merge https://gitee.com/wang-yi201/security_security_guard into wangyi
Change-Id: I81600088a9f943252e57888f4edae7f2894e60e9
This commit is contained in:
commit
5881696690
28
OAT.xml
Normal file
28
OAT.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
|
||||
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.
|
||||
|
||||
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
|
||||
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<oatconfig>
|
||||
<filefilterlist>
|
||||
<filefilter name="defaultFilter" desc="Files not to check">
|
||||
<filteritem type="filename" name="*.png|*.jpg" desc="Allow open source ux images"/>
|
||||
</filefilter>
|
||||
</filefilterlist>
|
||||
</oatconfig>
|
||||
</configuration>
|
@ -223,7 +223,8 @@ void DatabaseManager::DbChanged(int32_t optType, const SecEvent &event)
|
||||
if (listeners.empty()) {
|
||||
return;
|
||||
}
|
||||
SGLOGI("eventId=%{public}" PRId64 ", listener size=%{public}u", event.eventId, static_cast<int32_t>(listeners.size()));
|
||||
SGLOGI("eventId=%{public}" PRId64 ", listener size=%{public}u",
|
||||
event.eventId, static_cast<int32_t>(listeners.size()));
|
||||
SecurityGuard::TaskHandler::Task task = [listeners, optType, event] () {
|
||||
for (auto &listener : listeners) {
|
||||
if (listener != nullptr) {
|
||||
|
@ -29,7 +29,7 @@ namespace OHOS::Security::SecurityGuard {
|
||||
std::shared_ptr<IModelManager> ModelManager::modelManagerApi_ = std::make_shared<ModelManagerImpl>();
|
||||
|
||||
namespace {
|
||||
constexpr const char *PREFIX_MODEL_PATH = "/system/lib64/lib";
|
||||
constexpr const char *PREFIX_MODEL_PATH = "/system/lib";
|
||||
constexpr uint32_t AUDIT_MODEL = 3001000003;
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ ErrorCode LibLoader::LoadLib()
|
||||
{
|
||||
LOGI("LoadLib start");
|
||||
std::string realPath;
|
||||
if (!PathToRealPath(m_libPath, realPath) || realPath.find("/system/lib64") != 0) {
|
||||
if (!PathToRealPath(m_libPath, realPath) || realPath.find("/system/lib") != 0) {
|
||||
LOGE("LoadLib m_libPath error, realPath: %{public}s", realPath.c_str());
|
||||
m_isLoaded = false;
|
||||
return RET_DLOPEN_LIB_FAIL;
|
||||
|
@ -173,9 +173,7 @@ bool SecurityCollectorSubscriberManager::UnsubscribeCollector(const sptr<IRemote
|
||||
eventToSubscribers_[eventId].erase(subscriber);
|
||||
if (eventToSubscribers_[eventId].size() == 0) {
|
||||
LOGI("Scheduling stop collector, eventId:%{public}" PRId64 "", eventId);
|
||||
if (!DataCollection::GetInstance().StopCollectors(std::vector<int64_t>{eventId})) {
|
||||
LOGE("failed to stop collectors");
|
||||
}
|
||||
(void) DataCollection::GetInstance().StopCollectors(std::vector<int64_t>{eventId});
|
||||
eventToSubscribers_.erase(eventId);
|
||||
eventToListenner_.erase(eventId);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
static void ReportScUnsubscribeEvent(const ScUnsubscribeEvent &event);
|
||||
private:
|
||||
static std::string GetAppName();
|
||||
static int32_t HasPermission();
|
||||
static int32_t HasPermission(const std::string &permission);
|
||||
bool SetDeathRecipient(const sptr<IRemoteObject> &remote);
|
||||
void UnsetDeathRecipient(const sptr<IRemoteObject> &remote);
|
||||
void CleanSubscriber(const sptr<IRemoteObject> &remote);
|
||||
|
@ -47,6 +47,7 @@ namespace OHOS {
|
||||
Security::AccessToken::TokenIdKit::instance_ = nullptr;
|
||||
std::mutex Security::AccessToken::AccessTokenKit::mutex_ {};
|
||||
std::mutex Security::AccessToken::TokenIdKit::mutex_ {};
|
||||
constexpr char PERMISSION[] = "ohos.permission.securityguard.REQUEST_SECURITY_EVENT_INFO";
|
||||
}
|
||||
|
||||
namespace OHOS::Security::SecurityCollectorTest {
|
||||
@ -134,21 +135,21 @@ HWTEST_F(SecurityCollectorTest, HasPermission01, TestSize.Level1)
|
||||
{
|
||||
EXPECT_CALL(*(AccessToken::AccessTokenKit::GetInterface()), VerifyAccessToken).WillOnce(
|
||||
Return(AccessToken::PermissionState::PERMISSION_DENIED));
|
||||
EXPECT_EQ(SecurityCollectorManagerService::HasPermission(), SecurityCollector::ErrorCode::NO_PERMISSION);
|
||||
EXPECT_EQ(SecurityCollectorManagerService::HasPermission(PERMISSION), SecurityCollector::ErrorCode::NO_PERMISSION);
|
||||
}
|
||||
|
||||
HWTEST_F(SecurityCollectorTest, HasPermission02, TestSize.Level1)
|
||||
{
|
||||
EXPECT_CALL(*(AccessToken::AccessTokenKit::GetInterface()), VerifyAccessToken).WillOnce(
|
||||
Return(AccessToken::PermissionState::PERMISSION_GRANTED));
|
||||
EXPECT_EQ(SecurityCollectorManagerService::HasPermission(), SecurityCollector::ErrorCode::SUCCESS);
|
||||
EXPECT_EQ(SecurityCollectorManagerService::HasPermission(PERMISSION), SecurityCollector::ErrorCode::SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(SecurityCollectorTest, HasPermission03, TestSize.Level1)
|
||||
{
|
||||
EXPECT_CALL(*(AccessToken::AccessTokenKit::GetInterface()), VerifyAccessToken).WillOnce(
|
||||
Return(AccessToken::PermissionState::PERMISSION_GRANTED));
|
||||
EXPECT_EQ(SecurityCollectorManagerService::HasPermission(), SecurityCollector::ErrorCode::SUCCESS);
|
||||
EXPECT_EQ(SecurityCollectorManagerService::HasPermission(PERMISSION), SecurityCollector::ErrorCode::SUCCESS);
|
||||
}
|
||||
|
||||
HWTEST_F(SecurityCollectorTest, Subscribe01, TestSize.Level1)
|
||||
|
Loading…
Reference in New Issue
Block a user