mirror of
https://gitee.com/openharmony/ability_dmsfwk
synced 2024-11-23 14:30:21 +00:00
!464 add fuzz permission
Merge pull request !464 from yaoyao/cherry-pick-1667034363
This commit is contained in:
commit
ed1c491775
@ -42,6 +42,8 @@ dtbabilitymgr_sources = [
|
||||
|
||||
dtbabilitymgr_external_deps = [
|
||||
"access_token:libaccesstoken_sdk",
|
||||
"access_token:libnativetoken",
|
||||
"access_token:libtoken_setproc",
|
||||
"c_utils:utils",
|
||||
"device_manager:devicemanagersdk",
|
||||
"eventhandler:libeventhandler",
|
||||
@ -71,7 +73,11 @@ ohos_fuzztest("ContinuationManagerFuzzTest") {
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
|
||||
sources = [ "continuationmanager_fuzzer.cpp" ]
|
||||
sources = [
|
||||
"continuationmanager_fuzzer.cpp",
|
||||
"mock_permission.cpp",
|
||||
]
|
||||
|
||||
sources += dtbabilitymgr_sources
|
||||
|
||||
deps = [ "//foundation/ability/dmsfwk/services/base:dmsbaseinner" ]
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "distributed_ability_manager_interface.h"
|
||||
#include "distributed_ability_manager_stub.h"
|
||||
#include "distributed_ability_manager_service.h"
|
||||
#include "mock_permission.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
@ -42,6 +43,7 @@ uint32_t Convert2Uint32(const uint8_t* ptr)
|
||||
|
||||
void FuzzUnregister(const uint8_t* rawData, size_t size)
|
||||
{
|
||||
DmsMockPermission::MockPermission();
|
||||
uint32_t code = Convert2Uint32(rawData);
|
||||
rawData = rawData + OFFSET;
|
||||
size = size - OFFSET;
|
||||
|
41
test/fuzztest/continuationmanager_fuzzer/mock_permission.cpp
Normal file
41
test/fuzztest/continuationmanager_fuzzer/mock_permission.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
#include "mock_permission.h"
|
||||
|
||||
#include "nativetoken_kit.h"
|
||||
#include "token_setproc.h"
|
||||
|
||||
namespace OHOS {
|
||||
void DmsMockPermission::MockPermission()
|
||||
{
|
||||
static const char *PERMS[] = {
|
||||
"ohos.permission.DISTRIBUTED_DATASYNC"
|
||||
};
|
||||
uint64_t tokenId;
|
||||
NativeTokenInfoParams infoInstance = {
|
||||
.dcapsNum = 0,
|
||||
.permsNum = 1,
|
||||
.aclsNum = 0,
|
||||
.dcaps = nullptr,
|
||||
.perms = PERMS,
|
||||
.acls = nullptr,
|
||||
.processName = "foundation",
|
||||
.aplStr = "system_core",
|
||||
};
|
||||
tokenId = GetAccessTokenId(&infoInstance);
|
||||
SetSelfTokenID(tokenId);
|
||||
}
|
||||
}
|
25
test/fuzztest/continuationmanager_fuzzer/mock_permission.h
Normal file
25
test/fuzztest/continuationmanager_fuzzer/mock_permission.h
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
#ifndef MOCK_PERMISSION_H
|
||||
#define MOCK_PERMISSION_H
|
||||
|
||||
namespace OHOS {
|
||||
class DmsMockPermission {
|
||||
public:
|
||||
static void MockPermission();
|
||||
};
|
||||
} // namespace OHOS
|
||||
#endif // SAMGR_SERVICES_SAMGR_MOCK_PERMISSION_H
|
Loading…
Reference in New Issue
Block a user