1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "addcoreservicetoken_fuzzer.h"
17 
18 #include <iostream>
19 
20 #include "nativetoken_kit.h"
21 #include "token_setproc.h"
22 
23 namespace OHOS {
24 const int PERMS_NUM = 11;
25 
AddCoreServiceTokenFuzzer()26 AddCoreServiceTokenFuzzer::AddCoreServiceTokenFuzzer()
27 {
28     const char *perms[PERMS_NUM] = {
29         "ohos.permission.WRITE_CONTACTS",
30         "ohos.permission.SET_TELEPHONY_STATE",
31         "ohos.permission.GET_TELEPHONY_STATE",
32         "ohos.permission.READ_CONTACTS",
33         "ohos.permission.WRITE_CONTACTS",
34         "ohos.permission.LOCATION",
35         "ohos.permission.COMMONEVENT_STICKY",
36         "ohos.permission.CONNECTIVITY_INTERNAL",
37         "ohos.permission.PERMISSION_USED_STATS",
38         "ohos.permission.RECEIVE_SMS",
39         "ohos.permission.MANAGE_SECURE_SETTINGS",
40     };
41 
42     NativeTokenInfoParams testCoreServiceInfoParams = {
43         .dcapsNum = 0,
44         .permsNum = PERMS_NUM,
45         .aclsNum = 0,
46         .dcaps = nullptr,
47         .perms = perms,
48         .acls = nullptr,
49         .processName = "core_service_fuzzer",
50         .aplStr = "system_basic",
51     };
52     currentID_ = GetAccessTokenId(&testCoreServiceInfoParams);
53     SetSelfTokenID(currentID_);
54     Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
55 }
~AddCoreServiceTokenFuzzer()56 AddCoreServiceTokenFuzzer::~AddCoreServiceTokenFuzzer() {}
57 } // namespace OHOS