diff --git a/OAT.xml b/OAT.xml
index c30889645a7c1973c78f604e326c39ebf99098f2..b6be19ee8d452ebd4e14bdb925b99f09342261b8 100644
--- a/OAT.xml
+++ b/OAT.xml
@@ -79,6 +79,7 @@
+
diff --git a/test/fuzztest/common/accesstoken_fuzzdata.h b/test/fuzztest/common/accesstoken_fuzzdata.h
index 8502c135813a884cb97d3d5574e1f6c40228b6cb..9d3b6a6205525b5d43717a85ab450014a2298b7f 100644
--- a/test/fuzztest/common/accesstoken_fuzzdata.h
+++ b/test/fuzztest/common/accesstoken_fuzzdata.h
@@ -17,10 +17,83 @@
#define ACCESSTOKEN_FUZZDATA_TEMPLATE_H
#include
+#include
+#include
#include
+#include "fuzzer/FuzzedDataProvider.h"
+#include "accesstoken_kit.h"
+#include "permission_map.h"
#include "securec.h"
+static OHOS::Security::AccessToken::AccessTokenID TransfterStrToAccesstokenID(const std::string& numStr)
+{
+ size_t index = 0;
+ while (index < numStr.length()) {
+ if (!std::isdigit(numStr[index])) {
+ break;
+ }
+ ++index;
+ }
+ if (index != numStr.length()) {
+ return 0;
+ }
+ OHOS::Security::AccessToken::AccessTokenID id =
+ static_cast(std::stoi(numStr));
+ return id;
+}
+
+void GetTokenIdList(std::vector &tokenIdList)
+{
+ std::string dumpInfo;
+ OHOS::Security::AccessToken::AtmToolsParamInfo info;
+ OHOS::Security::AccessToken::AccessTokenKit::DumpTokenInfo(info, dumpInfo);
+ std::istringstream iss(dumpInfo);
+ std::string line;
+ while (std::getline(iss, line)) {
+ size_t pos = line.find(':');
+ if (pos != std::string::npos) {
+ std::string numStr = line.substr(0, pos);
+ OHOS::Security::AccessToken::AccessTokenID id = TransfterStrToAccesstokenID(numStr);
+ if (id != OHOS::Security::AccessToken::INVALID_TOKENID) {
+ tokenIdList.push_back(id);
+ }
+ }
+ }
+}
+
+OHOS::Security::AccessToken::AccessTokenID ConsumeTokenId(FuzzedDataProvider &provider)
+{
+ static std::vector tokenIdList;
+ static bool isIntialize = false;
+ if (!isIntialize) {
+ GetTokenIdList(tokenIdList);
+ isIntialize = true;
+ }
+ OHOS::Security::AccessToken::AccessTokenID tokenId = 0;
+ if (provider.ConsumeBool() || tokenIdList.empty()) {
+ tokenId = provider.ConsumeIntegral();
+ } else {
+ tokenId = tokenIdList[
+ provider.ConsumeIntegralInRange(0, static_cast(tokenIdList.size() - 1))];
+ }
+
+ return tokenId;
+}
+
+std::string ConsumePermissionName(FuzzedDataProvider &provider)
+{
+ std::string permissionName;
+ if (provider.ConsumeBool()) {
+ permissionName = provider.ConsumeRandomLengthString();
+ } else {
+ permissionName = OHOS::Security::AccessToken::TransferOpcodeToPermission(
+ provider.ConsumeIntegralInRange(
+ 0, static_cast(OHOS::Security::AccessToken::GetDefPermissionsSize()) - 1), permissionName);
+ }
+ return permissionName;
+}
+
namespace OHOS {
namespace Security {
namespace AccessToken {
diff --git a/test/fuzztest/innerkits/accesstoken/accesstokenkitcoverage_fuzzer/BUILD.gn b/test/fuzztest/innerkits/accesstoken/accesstokenkitcoverage_fuzzer/BUILD.gn
index ad40c619262cd051343baea676cbd9285c19144d..1dbc99062d88d6f4440cc32a416c7f3637688d71 100644
--- a/test/fuzztest/innerkits/accesstoken/accesstokenkitcoverage_fuzzer/BUILD.gn
+++ b/test/fuzztest/innerkits/accesstoken/accesstokenkitcoverage_fuzzer/BUILD.gn
@@ -20,6 +20,7 @@ ohos_fuzztest("AccessTokenKitCoverageFuzzTest") {
fuzz_config_file = "."
include_dirs = [
+ "${access_token_path}/frameworks/common/include",
"${access_token_path}/interfaces/innerkits/accesstoken/include",
"${access_token_path}/test/fuzztest/common",
]
diff --git a/test/fuzztest/innerkits/accesstoken/allochaptoken_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/allochaptoken_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/allochaptoken_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/allochaptoken_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/allochaptoken_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..07e8732f9bdcab54fc163cc20eacad1019ddda02
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/allochaptoken_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/alloclocaltokenid_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/alloclocaltokenid_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/alloclocaltokenid_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/alloclocaltokenid_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/alloclocaltokenid_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..016554c8ff7e8f693810e7c32b169f32424ac8e4
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/alloclocaltokenid_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/clearusergrantedpermissionstate_fuzzer/BUILD.gn b/test/fuzztest/innerkits/accesstoken/clearusergrantedpermissionstate_fuzzer/BUILD.gn
index 460d5c90e564d2af36c52696da4c9b705b691a52..4f8e58dd55b1e4ee6a9443aedf2e9f2b37c8e363 100644
--- a/test/fuzztest/innerkits/accesstoken/clearusergrantedpermissionstate_fuzzer/BUILD.gn
+++ b/test/fuzztest/innerkits/accesstoken/clearusergrantedpermissionstate_fuzzer/BUILD.gn
@@ -19,6 +19,7 @@ ohos_fuzztest("ClearUserGrantedPermissionStateFuzzTest") {
module_out_path = module_output_path_interface_access_token
fuzz_config_file = "."
include_dirs = [
+ "${access_token_path}/frameworks/common/include",
"${access_token_path}/interfaces/innerkits/accesstoken/include",
"${access_token_path}/test/fuzztest/common",
]
diff --git a/test/fuzztest/innerkits/accesstoken/clearusergrantedpermissionstate_fuzzer/clearusergrantedpermissionstate_fuzzer.cpp b/test/fuzztest/innerkits/accesstoken/clearusergrantedpermissionstate_fuzzer/clearusergrantedpermissionstate_fuzzer.cpp
index 2d73c463511288d990bc0293722e0f7cb00af65b..e9e09fdcf6527a0aeaf483155ee70919d2181dc8 100644
--- a/test/fuzztest/innerkits/accesstoken/clearusergrantedpermissionstate_fuzzer/clearusergrantedpermissionstate_fuzzer.cpp
+++ b/test/fuzztest/innerkits/accesstoken/clearusergrantedpermissionstate_fuzzer/clearusergrantedpermissionstate_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_kit.h"
#include "fuzzer/FuzzedDataProvider.h"
@@ -34,8 +35,8 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- return AccessTokenKit::ClearUserGrantedPermissionState(
- provider.ConsumeIntegral()) == RET_SUCCESS;
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ return AccessTokenKit::ClearUserGrantedPermissionState(tokenId) == RET_SUCCESS;
}
}
diff --git a/test/fuzztest/innerkits/accesstoken/deleteremotetoken_fuzzer/BUILD.gn b/test/fuzztest/innerkits/accesstoken/deleteremotetoken_fuzzer/BUILD.gn
index 2937d5c6d04ea013961b1ff2dfda558c4ea41040..14ff8cbb43c12402f0ab24405b9f9537471e0868 100644
--- a/test/fuzztest/innerkits/accesstoken/deleteremotetoken_fuzzer/BUILD.gn
+++ b/test/fuzztest/innerkits/accesstoken/deleteremotetoken_fuzzer/BUILD.gn
@@ -19,6 +19,7 @@ ohos_fuzztest("DeleteRemoteTokenFuzzTest") {
module_out_path = module_output_path_interface_access_token
fuzz_config_file = "."
include_dirs = [
+ "${access_token_path}/frameworks/common/include",
"${access_token_path}/interfaces/innerkits/accesstoken/include",
"${access_token_path}/test/fuzztest/common",
]
diff --git a/test/fuzztest/innerkits/accesstoken/deleteremotetoken_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/deleteremotetoken_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/deleteremotetoken_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/deleteremotetoken_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/deleteremotetoken_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..86d830374f3be9b1916e3cf36733799eced92be2
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/deleteremotetoken_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/deleteremotetoken_fuzzer/deleteremotetoken_fuzzer.cpp b/test/fuzztest/innerkits/accesstoken/deleteremotetoken_fuzzer/deleteremotetoken_fuzzer.cpp
index 955a23c3615b995ff5cb91315e408c3108ca1cf5..3dca83e99db1d4c344e9f2f715912a2a7c4e6250 100644
--- a/test/fuzztest/innerkits/accesstoken/deleteremotetoken_fuzzer/deleteremotetoken_fuzzer.cpp
+++ b/test/fuzztest/innerkits/accesstoken/deleteremotetoken_fuzzer/deleteremotetoken_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_kit.h"
#include "fuzzer/FuzzedDataProvider.h"
@@ -35,8 +36,8 @@ namespace OHOS {
#ifdef TOKEN_SYNC_ENABLE
FuzzedDataProvider provider(data, size);
- return AccessTokenKit::DeleteRemoteToken(provider.ConsumeRandomLengthString(),
- provider.ConsumeIntegral()) == RET_SUCCESS;
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ return AccessTokenKit::DeleteRemoteToken(provider.ConsumeRandomLengthString(), tokenId) == RET_SUCCESS;
#else
return true;
#endif
diff --git a/test/fuzztest/innerkits/accesstoken/getdefpermission_fuzzer/BUILD.gn b/test/fuzztest/innerkits/accesstoken/getdefpermission_fuzzer/BUILD.gn
index 838fa2cd79cac5007b895274db69856893387266..360738f32c2b8e0fa2db0b6e950a19488a382eca 100644
--- a/test/fuzztest/innerkits/accesstoken/getdefpermission_fuzzer/BUILD.gn
+++ b/test/fuzztest/innerkits/accesstoken/getdefpermission_fuzzer/BUILD.gn
@@ -31,6 +31,7 @@ ohos_fuzztest("GetDefPermissionFuzzTest") {
sources = [ "getdefpermission_fuzzer.cpp" ]
deps = [
+ "${access_token_path}/frameworks/common:accesstoken_common_cxx",
"${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
]
diff --git a/test/fuzztest/innerkits/accesstoken/getdefpermission_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/getdefpermission_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/getdefpermission_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/getdefpermission_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/getdefpermission_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..a7de26a739ccc0f585159c1036c7d8e37d75c5b7
--- /dev/null
+++ b/test/fuzztest/innerkits/accesstoken/getdefpermission_fuzzer/corpus/init0
@@ -0,0 +1 @@
+҉(_ĝ)Ymjz]>[\K UȹB
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/getdefpermission_fuzzer/getdefpermission_fuzzer.cpp b/test/fuzztest/innerkits/accesstoken/getdefpermission_fuzzer/getdefpermission_fuzzer.cpp
index 2143937de208cab98049986caa3bc071c196211e..cb79fbceefa435bb61e44cfbb09a95ae08604197 100644
--- a/test/fuzztest/innerkits/accesstoken/getdefpermission_fuzzer/getdefpermission_fuzzer.cpp
+++ b/test/fuzztest/innerkits/accesstoken/getdefpermission_fuzzer/getdefpermission_fuzzer.cpp
@@ -21,6 +21,7 @@
#include "fuzzer/FuzzedDataProvider.h"
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_kit.h"
#include "permission_def.h"
@@ -37,7 +38,8 @@ namespace OHOS {
FuzzedDataProvider provider(data, size);
PermissionDef def;
- return AccessTokenKit::GetDefPermission(provider.ConsumeRandomLengthString(), def) == RET_SUCCESS;
+ std::string permissionName = ConsumePermissionName(provider);
+ return AccessTokenKit::GetDefPermission(permissionName, def) == RET_SUCCESS;
}
}
diff --git a/test/fuzztest/innerkits/accesstoken/gethaptokenid_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/gethaptokenid_fuzzer/corpus/init
deleted file mode 100644
index c49c21aa8683c4d54af710059267afe15db14f96..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/gethaptokenid_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/gethaptokenid_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/gethaptokenid_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..d77f9491c933682a5a9a05101dccb26c0c3714ca
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/gethaptokenid_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/getnativetokenid_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/getnativetokenid_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/getnativetokenid_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/getnativetokenid_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/getnativetokenid_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..78779e2e2ce8bb524950ccae5de5895ce8d7e711
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/getnativetokenid_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/getpermissionflags_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/getpermissionflags_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/getpermissionflags_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/getpermissionflags_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/getpermissionflags_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..291d17696893b6eed3ac9c20c4e54b2b9cf0fb5e
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/getpermissionflags_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/getpermissionrequesttogglestatus_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/getpermissionrequesttogglestatus_fuzzer/corpus/init
deleted file mode 100644
index 61a7da989b6badef958ee1eb0856df4a2477cda4..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/getpermissionrequesttogglestatus_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
diff --git a/test/fuzztest/innerkits/accesstoken/getpermissionrequesttogglestatus_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/getpermissionrequesttogglestatus_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..291d17696893b6eed3ac9c20c4e54b2b9cf0fb5e
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/getpermissionrequesttogglestatus_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/getpermissionsstatus_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/getpermissionsstatus_fuzzer/corpus/init
deleted file mode 100644
index f7880ef1a502193121ec4b74e27bfc616e66cd26..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/getpermissionsstatus_fuzzer/corpus/init
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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.
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/getpermissionsstatus_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/getpermissionsstatus_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..291d17696893b6eed3ac9c20c4e54b2b9cf0fb5e
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/getpermissionsstatus_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/getpermissionusedtype_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/getpermissionusedtype_fuzzer/corpus/init
deleted file mode 100644
index e7c3fecd8d4d4816e40088113a2316bb9eb2e13f..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/getpermissionusedtype_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/getpermissionusedtype_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/getpermissionusedtype_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..291d17696893b6eed3ac9c20c4e54b2b9cf0fb5e
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/getpermissionusedtype_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/getremotenativetokenid_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/getremotenativetokenid_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/getremotenativetokenid_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/getremotenativetokenid_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/getremotenativetokenid_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..291d17696893b6eed3ac9c20c4e54b2b9cf0fb5e
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/getremotenativetokenid_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/getselfpermissionsstate_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/getselfpermissionsstate_fuzzer/corpus/init
deleted file mode 100644
index 1b910144fb1ff33a40a44b1d2a491b1ab05b598b..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/getselfpermissionsstate_fuzzer/corpus/init
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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.
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/getselfpermissionsstate_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/getselfpermissionsstate_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..291d17696893b6eed3ac9c20c4e54b2b9cf0fb5e
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/getselfpermissionsstate_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/BUILD.gn b/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/BUILD.gn
index 2968c428b3267f517ad03b977414b4e8eb61401b..f7927965f5185ba125293ba05a1bbdae84db3cf3 100644
--- a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/BUILD.gn
+++ b/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/BUILD.gn
@@ -19,6 +19,7 @@ ohos_fuzztest("GetSelfPermissionStatusFuzzTest") {
module_out_path = module_output_path_interface_access_token
fuzz_config_file = "."
include_dirs = [
+ "${access_token_path}/frameworks/common/include",
"${access_token_path}/interfaces/innerkits/accesstoken/include",
"${access_token_path}/test/fuzztest/common",
]
@@ -30,6 +31,7 @@ ohos_fuzztest("GetSelfPermissionStatusFuzzTest") {
]
sources = [ "getselfpermissionstatus_fuzzer.cpp" ]
deps = [
+ "${access_token_path}/frameworks/common:accesstoken_common_cxx",
"${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
]
diff --git a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/corpus/init
deleted file mode 100644
index 8f37f09254457133cae0f828d0a5faee7dcbd779..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/corpus/init
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright (c) 2025 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.
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..a168e9ed5b82e46f596235154fc4958ce4051df2
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/getselfpermissionstatus_fuzzer.cpp b/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/getselfpermissionstatus_fuzzer.cpp
index 481318729f660a716fce5a7f7d0ab18cb08f7912..136d7cf7d052a6119ab914343085f0064a35c98f 100644
--- a/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/getselfpermissionstatus_fuzzer.cpp
+++ b/test/fuzztest/innerkits/accesstoken/getselfpermissionstatus_fuzzer/getselfpermissionstatus_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_kit.h"
#include "fuzzer/FuzzedDataProvider.h"
@@ -35,7 +36,8 @@ namespace OHOS {
FuzzedDataProvider provider(data, size);
PermissionOper status;
- return AccessTokenKit::GetSelfPermissionStatus(provider.ConsumeRandomLengthString(), status) == RET_SUCCESS;
+ std::string permissionName = ConsumePermissionName(provider);
+ return AccessTokenKit::GetSelfPermissionStatus(permissionName, status) == RET_SUCCESS;
}
}
diff --git a/test/fuzztest/innerkits/accesstoken/grantpermission_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/grantpermission_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/grantpermission_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/grantpermission_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/grantpermission_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..d77f9491c933682a5a9a05101dccb26c0c3714ca
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/grantpermission_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/grantpermission_fuzzer/grantpermission_fuzzer.cpp b/test/fuzztest/innerkits/accesstoken/grantpermission_fuzzer/grantpermission_fuzzer.cpp
index 6c06718677f19fe7153a9e194240e1a686c3f3d7..5482a2ceb169b91a7adcf70b31a047b9b92cd676 100644
--- a/test/fuzztest/innerkits/accesstoken/grantpermission_fuzzer/grantpermission_fuzzer.cpp
+++ b/test/fuzztest/innerkits/accesstoken/grantpermission_fuzzer/grantpermission_fuzzer.cpp
@@ -23,6 +23,8 @@
#include "accesstoken_kit.h"
#include "fuzzer/FuzzedDataProvider.h"
+const static int32_t FLAG_SIZE = 16;
+
using namespace std;
using namespace OHOS::Security::AccessToken;
@@ -35,7 +37,8 @@ namespace OHOS {
FuzzedDataProvider provider(data, size);
return AccessTokenKit::GrantPermission(provider.ConsumeIntegral(),
- provider.ConsumeRandomLengthString(), provider.ConsumeIntegral()) == RET_SUCCESS;
+ provider.ConsumeRandomLengthString(),
+ 1 << (provider.ConsumeIntegral() % FLAG_SIZE)) == RET_SUCCESS;
}
}
diff --git a/test/fuzztest/innerkits/accesstoken/grantpermissionforspecifiedtime_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/grantpermissionforspecifiedtime_fuzzer/corpus/init
deleted file mode 100644
index e7c3fecd8d4d4816e40088113a2316bb9eb2e13f..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/grantpermissionforspecifiedtime_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/grantpermissionforspecifiedtime_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/grantpermissionforspecifiedtime_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..d77f9491c933682a5a9a05101dccb26c0c3714ca
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/grantpermissionforspecifiedtime_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/inithaptoken_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/inithaptoken_fuzzer/corpus/init
deleted file mode 100644
index e7c3fecd8d4d4816e40088113a2316bb9eb2e13f..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/inithaptoken_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/inithaptoken_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/inithaptoken_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..d77f9491c933682a5a9a05101dccb26c0c3714ca
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/inithaptoken_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/registerpermstatechangecallback_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/registerpermstatechangecallback_fuzzer/corpus/init
deleted file mode 100644
index 1b910144fb1ff33a40a44b1d2a491b1ab05b598b..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/registerpermstatechangecallback_fuzzer/corpus/init
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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.
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/registerpermstatechangecallback_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/registerpermstatechangecallback_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..d77f9491c933682a5a9a05101dccb26c0c3714ca
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/registerpermstatechangecallback_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/revokeusergrantedpermission_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/revokeusergrantedpermission_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/revokeusergrantedpermission_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/revokeusergrantedpermission_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/revokeusergrantedpermission_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..d77f9491c933682a5a9a05101dccb26c0c3714ca
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/revokeusergrantedpermission_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/revokeusergrantedpermission_fuzzer/revokeusergrantedpermission_fuzzer.cpp b/test/fuzztest/innerkits/accesstoken/revokeusergrantedpermission_fuzzer/revokeusergrantedpermission_fuzzer.cpp
index 45ad4e878176d251722adfc6622a044b1bf3c970..4ed3a8723b0f34c794e9b44bed48648e52c48b7b 100644
--- a/test/fuzztest/innerkits/accesstoken/revokeusergrantedpermission_fuzzer/revokeusergrantedpermission_fuzzer.cpp
+++ b/test/fuzztest/innerkits/accesstoken/revokeusergrantedpermission_fuzzer/revokeusergrantedpermission_fuzzer.cpp
@@ -25,6 +25,7 @@
using namespace std;
using namespace OHOS::Security::AccessToken;
+const static int32_t FLAG_SIZE = 16;
namespace OHOS {
bool RevokeUserGrantedPermissionFuzzTest(const uint8_t* data, size_t size)
@@ -34,8 +35,7 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- uint32_t flag = provider.ConsumeIntegralInRange(
- 0, static_cast(PermissionFlag::PERMISSION_ALLOW_THIS_TIME));
+ uint32_t flag = 1 << (provider.ConsumeIntegral() % FLAG_SIZE);
return AccessTokenKit::RevokePermission(provider.ConsumeIntegral(),
provider.ConsumeRandomLengthString(), flag) == RET_SUCCESS;
}
diff --git a/test/fuzztest/innerkits/accesstoken/setpermdialogcap_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/setpermdialogcap_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/setpermdialogcap_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/setpermdialogcap_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/setpermdialogcap_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..d77f9491c933682a5a9a05101dccb26c0c3714ca
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/setpermdialogcap_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/setpermissionrequesttogglestatus_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/setpermissionrequesttogglestatus_fuzzer/corpus/init
deleted file mode 100644
index 61a7da989b6badef958ee1eb0856df4a2477cda4..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/setpermissionrequesttogglestatus_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
diff --git a/test/fuzztest/innerkits/accesstoken/setpermissionrequesttogglestatus_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/setpermissionrequesttogglestatus_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..d77f9491c933682a5a9a05101dccb26c0c3714ca
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/setpermissionrequesttogglestatus_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/setpermissionrequesttogglestatus_fuzzer/setpermissionrequesttogglestatus_fuzzer.cpp b/test/fuzztest/innerkits/accesstoken/setpermissionrequesttogglestatus_fuzzer/setpermissionrequesttogglestatus_fuzzer.cpp
index 3ddfd3c7757d45f8bcb7baeb916d90ced3242052..0e98219a703e2dffad67ce17745599642bc6e72a 100644
--- a/test/fuzztest/innerkits/accesstoken/setpermissionrequesttogglestatus_fuzzer/setpermissionrequesttogglestatus_fuzzer.cpp
+++ b/test/fuzztest/innerkits/accesstoken/setpermissionrequesttogglestatus_fuzzer/setpermissionrequesttogglestatus_fuzzer.cpp
@@ -22,6 +22,7 @@
#undef private
#include "accesstoken_kit.h"
#include "fuzzer/FuzzedDataProvider.h"
+const static int32_t STATUS_SIZE = 3;
using namespace std;
using namespace OHOS::Security::AccessToken;
@@ -35,7 +36,7 @@ namespace OHOS {
FuzzedDataProvider provider(data, size);
return AccessTokenKit::SetPermissionRequestToggleStatus(provider.ConsumeRandomLengthString(),
- provider.ConsumeIntegral(), provider.ConsumeIntegral()) == RET_SUCCESS;
+ provider.ConsumeIntegral() % STATUS_SIZE, provider.ConsumeIntegral()) == RET_SUCCESS;
}
}
diff --git a/test/fuzztest/innerkits/accesstoken/setpermissionstatuswithpolicy_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/setpermissionstatuswithpolicy_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/setpermissionstatuswithpolicy_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/setpermissionstatuswithpolicy_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/setpermissionstatuswithpolicy_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..d77f9491c933682a5a9a05101dccb26c0c3714ca
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/setpermissionstatuswithpolicy_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/setpermissionstatuswithpolicy_fuzzer/setpermissionstatuswithpolicy_fuzzer.cpp b/test/fuzztest/innerkits/accesstoken/setpermissionstatuswithpolicy_fuzzer/setpermissionstatuswithpolicy_fuzzer.cpp
index 2c8131413d05ed710ee163c82271b192079e4e13..0153b9fcb13fbc5f40893cedc59bc6296c84cf1c 100644
--- a/test/fuzztest/innerkits/accesstoken/setpermissionstatuswithpolicy_fuzzer/setpermissionstatuswithpolicy_fuzzer.cpp
+++ b/test/fuzztest/innerkits/accesstoken/setpermissionstatuswithpolicy_fuzzer/setpermissionstatuswithpolicy_fuzzer.cpp
@@ -18,7 +18,7 @@
#include
#include
#include
-#include "accesstoken_fuzzdata.h"
+#include "fuzzer/FuzzedDataProvider.h"
#undef private
#include "accesstoken_kit.h"
@@ -32,10 +32,10 @@ namespace OHOS {
return false;
}
- AccessTokenFuzzData fuzzData(data, size);
- std::vector permList = {fuzzData.GenerateStochasticString()};
+ FuzzedDataProvider provider(data, size);
+ std::vector permList = {provider.ConsumeRandomLengthString()};
int32_t result = AccessTokenKit::SetPermissionStatusWithPolicy(
- fuzzData.GetData(), permList, 0, 128);
+ provider.ConsumeIntegral(), permList, 0, 128);
return result == RET_SUCCESS;
}
}
diff --git a/test/fuzztest/innerkits/accesstoken/updatehaptoken_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/updatehaptoken_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/updatehaptoken_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/updatehaptoken_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/updatehaptoken_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..600c49776b326136c67fec13237a9dad9f3be463
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/updatehaptoken_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/verifyaccesstoken001_fuzzer/BUILD.gn b/test/fuzztest/innerkits/accesstoken/verifyaccesstoken001_fuzzer/BUILD.gn
index 84e8bd51cc5018fde08cfd6a3e10fbeb7a8aeb62..6866ad0427fe2639862db88a9f0bff94d42155ea 100644
--- a/test/fuzztest/innerkits/accesstoken/verifyaccesstoken001_fuzzer/BUILD.gn
+++ b/test/fuzztest/innerkits/accesstoken/verifyaccesstoken001_fuzzer/BUILD.gn
@@ -19,6 +19,7 @@ ohos_fuzztest("VerifyAccessToken001FuzzTest") {
module_out_path = module_output_path_interface_access_token
fuzz_config_file = "."
include_dirs = [
+ "${access_token_path}/frameworks/common/include",
"${access_token_path}/interfaces/innerkits/accesstoken/include",
"${access_token_path}/test/fuzztest/common",
]
@@ -31,6 +32,7 @@ ohos_fuzztest("VerifyAccessToken001FuzzTest") {
sources = [ "verifyaccesstoken001_fuzzer.cpp" ]
deps = [
+ "${access_token_path}/frameworks/common:accesstoken_common_cxx",
"${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
]
diff --git a/test/fuzztest/innerkits/accesstoken/verifyaccesstoken001_fuzzer/verifyaccesstoken001_fuzzer.cpp b/test/fuzztest/innerkits/accesstoken/verifyaccesstoken001_fuzzer/verifyaccesstoken001_fuzzer.cpp
index 3bdc61791891fd28343a2b934db65406e574d72c..1c410618fac5c240243a265b0d7c42b720c7eb80 100644
--- a/test/fuzztest/innerkits/accesstoken/verifyaccesstoken001_fuzzer/verifyaccesstoken001_fuzzer.cpp
+++ b/test/fuzztest/innerkits/accesstoken/verifyaccesstoken001_fuzzer/verifyaccesstoken001_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_kit.h"
#include "fuzzer/FuzzedDataProvider.h"
@@ -34,8 +35,10 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- return AccessTokenKit::VerifyAccessToken(provider.ConsumeIntegral(),
- provider.ConsumeIntegral(), provider.ConsumeRandomLengthString(),
+ AccessTokenID callerTokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
+ AccessTokenID firstTokenId = ConsumeTokenId(provider);
+ return AccessTokenKit::VerifyAccessToken(callerTokenId, firstTokenId, permissionName,
provider.ConsumeBool()) == RET_SUCCESS;
}
}
diff --git a/test/fuzztest/innerkits/accesstoken/verifyaccesstoken_fuzzer/BUILD.gn b/test/fuzztest/innerkits/accesstoken/verifyaccesstoken_fuzzer/BUILD.gn
index 35127ce11c9e907f17b7da1d6fabdb125485240e..9c29a70022bf3014583786071a9b14257b8143d3 100644
--- a/test/fuzztest/innerkits/accesstoken/verifyaccesstoken_fuzzer/BUILD.gn
+++ b/test/fuzztest/innerkits/accesstoken/verifyaccesstoken_fuzzer/BUILD.gn
@@ -19,6 +19,7 @@ ohos_fuzztest("VerifyAccessTokenFuzzTest") {
module_out_path = module_output_path_interface_access_token
fuzz_config_file = "."
include_dirs = [
+ "${access_token_path}/frameworks/common/include",
"${access_token_path}/interfaces/innerkits/accesstoken/include",
"${access_token_path}/test/fuzztest/common",
]
@@ -31,6 +32,7 @@ ohos_fuzztest("VerifyAccessTokenFuzzTest") {
sources = [ "verifyaccesstoken_fuzzer.cpp" ]
deps = [
+ "${access_token_path}/frameworks/common:accesstoken_common_cxx",
"${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
]
diff --git a/test/fuzztest/innerkits/accesstoken/verifyaccesstoken_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/verifyaccesstoken_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/verifyaccesstoken_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/verifyaccesstoken_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/verifyaccesstoken_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/verifyaccesstoken_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/verifyaccesstoken_fuzzer/verifyaccesstoken_fuzzer.cpp b/test/fuzztest/innerkits/accesstoken/verifyaccesstoken_fuzzer/verifyaccesstoken_fuzzer.cpp
index 0c2a0464deb1f485ac4ee5bf1e68aa05147df39a..51a96b9df91fae698ac1be948429f313980a3cc3 100644
--- a/test/fuzztest/innerkits/accesstoken/verifyaccesstoken_fuzzer/verifyaccesstoken_fuzzer.cpp
+++ b/test/fuzztest/innerkits/accesstoken/verifyaccesstoken_fuzzer/verifyaccesstoken_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_kit.h"
#include "fuzzer/FuzzedDataProvider.h"
@@ -34,8 +35,9 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- return AccessTokenKit::VerifyAccessToken(provider.ConsumeIntegral(),
- provider.ConsumeRandomLengthString(), provider.ConsumeBool()) == RET_SUCCESS;
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
+ return AccessTokenKit::VerifyAccessToken(tokenId, permissionName, provider.ConsumeBool()) == RET_SUCCESS;
}
}
diff --git a/test/fuzztest/innerkits/accesstoken/verifyaccesstokenwithlist_fuzzer/BUILD.gn b/test/fuzztest/innerkits/accesstoken/verifyaccesstokenwithlist_fuzzer/BUILD.gn
index 200fd1490160d8bc1e1959af22fdea812d1c57b7..6ff5e7ab4edbb67c0927366772c91198189dc953 100644
--- a/test/fuzztest/innerkits/accesstoken/verifyaccesstokenwithlist_fuzzer/BUILD.gn
+++ b/test/fuzztest/innerkits/accesstoken/verifyaccesstokenwithlist_fuzzer/BUILD.gn
@@ -19,6 +19,7 @@ ohos_fuzztest("VerifyAccessTokenWithListFuzzTest") {
module_out_path = module_output_path_interface_access_token
fuzz_config_file = "."
include_dirs = [
+ "${access_token_path}/frameworks/common/include",
"${access_token_path}/interfaces/innerkits/accesstoken/include",
"${access_token_path}/test/fuzztest/common",
]
@@ -31,6 +32,7 @@ ohos_fuzztest("VerifyAccessTokenWithListFuzzTest") {
sources = [ "verifyaccesstokenwithlist_fuzzer.cpp" ]
deps = [
+ "${access_token_path}/frameworks/common:accesstoken_common_cxx",
"${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
]
diff --git a/test/fuzztest/innerkits/accesstoken/verifyaccesstokenwithlist_fuzzer/corpus/init b/test/fuzztest/innerkits/accesstoken/verifyaccesstokenwithlist_fuzzer/corpus/init
deleted file mode 100644
index e7c3fecd8d4d4816e40088113a2316bb9eb2e13f..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/accesstoken/verifyaccesstokenwithlist_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/accesstoken/verifyaccesstokenwithlist_fuzzer/corpus/init0 b/test/fuzztest/innerkits/accesstoken/verifyaccesstokenwithlist_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..a8f0906299856ee9e912d4a6aad0cf27a2f9ebef
Binary files /dev/null and b/test/fuzztest/innerkits/accesstoken/verifyaccesstokenwithlist_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/accesstoken/verifyaccesstokenwithlist_fuzzer/verifyaccesstokenwithlist_fuzzer.cpp b/test/fuzztest/innerkits/accesstoken/verifyaccesstokenwithlist_fuzzer/verifyaccesstokenwithlist_fuzzer.cpp
index a621f7f0002937114f39dc3c5b5c6012d9524919..543a994aae29edb13e71af7b2f180631b31a0dcd 100644
--- a/test/fuzztest/innerkits/accesstoken/verifyaccesstokenwithlist_fuzzer/verifyaccesstokenwithlist_fuzzer.cpp
+++ b/test/fuzztest/innerkits/accesstoken/verifyaccesstokenwithlist_fuzzer/verifyaccesstokenwithlist_fuzzer.cpp
@@ -20,12 +20,12 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_kit.h"
#include "fuzzer/FuzzedDataProvider.h"
using namespace std;
using namespace OHOS::Security::AccessToken;
-const int32_t MAX_PERMISSION_SIZE = 1100;
namespace OHOS {
bool VerifyAccessTokenWithListFuzzTest(const uint8_t* data, size_t size)
@@ -35,14 +35,16 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- int32_t permSize = provider.ConsumeIntegral() % MAX_PERMISSION_SIZE;
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ int32_t permSize = provider.ConsumeIntegral() %
+ (static_cast(OHOS::Security::AccessToken::GetDefPermissionsSize()) - 1);
std::vector permissionList;
for (int32_t i = 0; i < permSize; ++i) {
- permissionList.emplace_back(provider.ConsumeRandomLengthString());
+ permissionList.emplace_back(ConsumePermissionName(provider));
}
std::vector permStateList;
- return AccessTokenKit::VerifyAccessToken(provider.ConsumeIntegral(), permissionList,
+ return AccessTokenKit::VerifyAccessToken(tokenId, permissionList,
permStateList, provider.ConsumeBool()) == RET_SUCCESS;
}
}
diff --git a/test/fuzztest/innerkits/privacy/addpermissionusedrecord_fuzzer/corpus/init b/test/fuzztest/innerkits/privacy/addpermissionusedrecord_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/privacy/addpermissionusedrecord_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/privacy/addpermissionusedrecord_fuzzer/corpus/init0 b/test/fuzztest/innerkits/privacy/addpermissionusedrecord_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..cb0a738b2f82974dc220178eac7d9ec4ce0c6d79
Binary files /dev/null and b/test/fuzztest/innerkits/privacy/addpermissionusedrecord_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/privacy/addpermissionusedrecordasync_fuzzer/corpus/init b/test/fuzztest/innerkits/privacy/addpermissionusedrecordasync_fuzzer/corpus/init
deleted file mode 100644
index 65af8ee8d11bf23407ea34d4de49f7cbb6a2b791..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/privacy/addpermissionusedrecordasync_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2025 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/privacy/addpermissionusedrecordasync_fuzzer/corpus/init0 b/test/fuzztest/innerkits/privacy/addpermissionusedrecordasync_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..cb0a738b2f82974dc220178eac7d9ec4ce0c6d79
Binary files /dev/null and b/test/fuzztest/innerkits/privacy/addpermissionusedrecordasync_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/privacy/getpermissionusedrecords_fuzzer/corpus/init b/test/fuzztest/innerkits/privacy/getpermissionusedrecords_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/privacy/getpermissionusedrecords_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/privacy/getpermissionusedrecords_fuzzer/corpus/init0 b/test/fuzztest/innerkits/privacy/getpermissionusedrecords_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..75caee3207bd30513fcfd67b43e2b3669e4e9011
Binary files /dev/null and b/test/fuzztest/innerkits/privacy/getpermissionusedrecords_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/privacy/getpermissionusedtypeinfos_fuzzer/BUILD.gn b/test/fuzztest/innerkits/privacy/getpermissionusedtypeinfos_fuzzer/BUILD.gn
index ac6c1d4f4998aba178db02485e3d8d43a74660da..207addef788495bed2fa2918210669c99f391c85 100644
--- a/test/fuzztest/innerkits/privacy/getpermissionusedtypeinfos_fuzzer/BUILD.gn
+++ b/test/fuzztest/innerkits/privacy/getpermissionusedtypeinfos_fuzzer/BUILD.gn
@@ -19,6 +19,7 @@ ohos_fuzztest("GetPermissionUsedTypeInfosFuzzTest") {
module_out_path = module_output_path_interface_privacy
fuzz_config_file = "."
include_dirs = [
+ "${access_token_path}/frameworks/common/include",
"${access_token_path}/interfaces/innerkits/accesstoken/include",
"${access_token_path}/test/fuzztest/common",
]
@@ -30,7 +31,11 @@ ohos_fuzztest("GetPermissionUsedTypeInfosFuzzTest") {
]
sources = [ "getpermissionusedtypeinfos_fuzzer.cpp" ]
- deps = [ "${access_token_path}/interfaces/innerkits/privacy:libprivacy_sdk" ]
+ deps = [
+ "${access_token_path}/frameworks/common:accesstoken_common_cxx",
+ "${access_token_path}/interfaces/innerkits/accesstoken:libaccesstoken_sdk",
+ "${access_token_path}/interfaces/innerkits/privacy:libprivacy_sdk",
+ ]
configs = [ "${access_token_path}/config:coverage_flags" ]
diff --git a/test/fuzztest/innerkits/privacy/getpermissionusedtypeinfos_fuzzer/corpus/init b/test/fuzztest/innerkits/privacy/getpermissionusedtypeinfos_fuzzer/corpus/init
deleted file mode 100644
index e7c3fecd8d4d4816e40088113a2316bb9eb2e13f..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/privacy/getpermissionusedtypeinfos_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/privacy/getpermissionusedtypeinfos_fuzzer/corpus/init0 b/test/fuzztest/innerkits/privacy/getpermissionusedtypeinfos_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/innerkits/privacy/getpermissionusedtypeinfos_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/privacy/getpermissionusedtypeinfos_fuzzer/getpermissionusedtypeinfos_fuzzer.cpp b/test/fuzztest/innerkits/privacy/getpermissionusedtypeinfos_fuzzer/getpermissionusedtypeinfos_fuzzer.cpp
index 5bfb041926b9a76d65ce7d7112c47a72a8d32cff..fabd6b34fc3f5fe77e1b0b729b5066bb3875a487 100644
--- a/test/fuzztest/innerkits/privacy/getpermissionusedtypeinfos_fuzzer/getpermissionusedtypeinfos_fuzzer.cpp
+++ b/test/fuzztest/innerkits/privacy/getpermissionusedtypeinfos_fuzzer/getpermissionusedtypeinfos_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#include
+#include "accesstoken_fuzzdata.h"
#include "fuzzer/FuzzedDataProvider.h"
#undef private
#include "privacy_kit.h"
@@ -36,8 +37,9 @@ namespace OHOS {
FuzzedDataProvider provider(data, size);
std::vector results;
- return PrivacyKit::GetPermissionUsedTypeInfos(provider.ConsumeIntegral(),
- provider.ConsumeRandomLengthString(), results) == 0;
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
+ return PrivacyKit::GetPermissionUsedTypeInfos(tokenId, permissionName, results) == 0;
}
}
diff --git a/test/fuzztest/innerkits/privacy/isallowedusingpermission_fuzzer/corpus/init b/test/fuzztest/innerkits/privacy/isallowedusingpermission_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/privacy/isallowedusingpermission_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/privacy/isallowedusingpermission_fuzzer/corpus/init0 b/test/fuzztest/innerkits/privacy/isallowedusingpermission_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..795d1be7830d42a6c398573865ca7ca87e7474ac
Binary files /dev/null and b/test/fuzztest/innerkits/privacy/isallowedusingpermission_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/privacy/registerpermactivestatuscallback_fuzzer/corpus/init b/test/fuzztest/innerkits/privacy/registerpermactivestatuscallback_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/privacy/registerpermactivestatuscallback_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/privacy/registerpermactivestatuscallback_fuzzer/corpus/init0 b/test/fuzztest/innerkits/privacy/registerpermactivestatuscallback_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..8308e087de3c590f2eef9a708f047cf2e6c6effb
Binary files /dev/null and b/test/fuzztest/innerkits/privacy/registerpermactivestatuscallback_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/privacy/setmutepolicy_fuzzer/setmutepolicy_fuzzer.cpp b/test/fuzztest/innerkits/privacy/setmutepolicy_fuzzer/setmutepolicy_fuzzer.cpp
index 90e4271712165fe350b69dcba426a4b3079cefd6..6e32b41d3814d0d68b1aa943634824cdc8db40c9 100644
--- a/test/fuzztest/innerkits/privacy/setmutepolicy_fuzzer/setmutepolicy_fuzzer.cpp
+++ b/test/fuzztest/innerkits/privacy/setmutepolicy_fuzzer/setmutepolicy_fuzzer.cpp
@@ -26,6 +26,8 @@
using namespace std;
using namespace OHOS::Security::AccessToken;
+static const uint32_t ACTIVE_CHANGE_CHANGE_TYPE_MAX = 4;
+static const uint32_t CALLER_TYPE_MAX = 2;
namespace OHOS {
bool SetMutePolicyFuzzTest(const uint8_t* data, size_t size)
@@ -35,7 +37,8 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- return PrivacyKit::SetMutePolicy(provider.ConsumeIntegral(), provider.ConsumeIntegral(),
+ return PrivacyKit::SetMutePolicy(provider.ConsumeIntegralInRange(0, ACTIVE_CHANGE_CHANGE_TYPE_MAX),
+ provider.ConsumeIntegralInRange(0, CALLER_TYPE_MAX),
provider.ConsumeBool(), provider.ConsumeIntegral()) == 0;
}
}
diff --git a/test/fuzztest/innerkits/privacy/setpermissionusedrecordtogglestatus_fuzzer/corpus/init b/test/fuzztest/innerkits/privacy/setpermissionusedrecordtogglestatus_fuzzer/corpus/init
deleted file mode 100644
index 65af8ee8d11bf23407ea34d4de49f7cbb6a2b791..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/privacy/setpermissionusedrecordtogglestatus_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2025 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/privacy/setpermissionusedrecordtogglestatus_fuzzer/corpus/init0 b/test/fuzztest/innerkits/privacy/setpermissionusedrecordtogglestatus_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..229e16eeeccbef9365e77c270ff8c73e98e145fa
Binary files /dev/null and b/test/fuzztest/innerkits/privacy/setpermissionusedrecordtogglestatus_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/privacy/startusingpermission001_fuzzer/corpus/init b/test/fuzztest/innerkits/privacy/startusingpermission001_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/privacy/startusingpermission001_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/privacy/startusingpermission001_fuzzer/corpus/init0 b/test/fuzztest/innerkits/privacy/startusingpermission001_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..80bc12d5f063d0522db0d7b08883841c5722a754
Binary files /dev/null and b/test/fuzztest/innerkits/privacy/startusingpermission001_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/privacy/startusingpermission_fuzzer/corpus/init b/test/fuzztest/innerkits/privacy/startusingpermission_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/privacy/startusingpermission_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/privacy/startusingpermission_fuzzer/corpus/init0 b/test/fuzztest/innerkits/privacy/startusingpermission_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..d99dde3bff7aa3e49926726739d837dc93b8af7e
Binary files /dev/null and b/test/fuzztest/innerkits/privacy/startusingpermission_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/privacy/stopusingpermission_fuzzer/corpus/init b/test/fuzztest/innerkits/privacy/stopusingpermission_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/privacy/stopusingpermission_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/privacy/stopusingpermission_fuzzer/corpus/init0 b/test/fuzztest/innerkits/privacy/stopusingpermission_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..80bc12d5f063d0522db0d7b08883841c5722a754
Binary files /dev/null and b/test/fuzztest/innerkits/privacy/stopusingpermission_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/innerkits/privacy/unregisterpermactivestatuscallback_fuzzer/corpus/init b/test/fuzztest/innerkits/privacy/unregisterpermactivestatuscallback_fuzzer/corpus/init
deleted file mode 100644
index bc977bd9738ee9a70b362067f57a9c63d3adb801..0000000000000000000000000000000000000000
--- a/test/fuzztest/innerkits/privacy/unregisterpermactivestatuscallback_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/innerkits/privacy/unregisterpermactivestatuscallback_fuzzer/corpus/init0 b/test/fuzztest/innerkits/privacy/unregisterpermactivestatuscallback_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..8308e087de3c590f2eef9a708f047cf2e6c6effb
Binary files /dev/null and b/test/fuzztest/innerkits/privacy/unregisterpermactivestatuscallback_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/normalize_service/accesstoken/allochaptokenservice_fuzzer/allochaptokenservice_fuzzer.cpp b/test/fuzztest/normalize_service/accesstoken/allochaptokenservice_fuzzer/allochaptokenservice_fuzzer.cpp
index a0f47030165448892b635d061b4ead757ae6d877..04f851c8fc4a918b91290f848893fc72a9e27355 100644
--- a/test/fuzztest/normalize_service/accesstoken/allochaptokenservice_fuzzer/allochaptokenservice_fuzzer.cpp
+++ b/test/fuzztest/normalize_service/accesstoken/allochaptokenservice_fuzzer/allochaptokenservice_fuzzer.cpp
@@ -18,6 +18,7 @@
#include
#include "accesstoken_manager_service.h"
+#include "accesstoken_fuzzdata.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "hap_info_parcel.h"
#include "iaccess_token_manager.h"
@@ -26,6 +27,7 @@ using namespace std;
using namespace OHOS::Security::AccessToken;
const int CONSTANTS_NUMBER_TEN = 10;
static const int32_t ROOT_UID = 0;
+const static int32_t FLAG_SIZE = 16;
namespace OHOS {
void InitHapInfoParams(const std::string& bundleName, FuzzedDataProvider& provider, HapInfoParams& param)
@@ -40,7 +42,7 @@ void InitHapInfoParams(const std::string& bundleName, FuzzedDataProvider& provid
param.isSystemApp = provider.ConsumeBool();
param.appDistributionType = provider.ConsumeRandomLengthString();
param.isRestore = provider.ConsumeBool();
- param.tokenID = provider.ConsumeIntegral();
+ param.tokenID = ConsumeTokenId(provider);
param.isAtomicService = provider.ConsumeBool();
}
@@ -70,8 +72,7 @@ void InitHapPolicy(const std::string& permissionName, const std::string& bundleN
.permissionName = permissionName,
.grantStatus = static_cast(provider.ConsumeIntegralInRange(
0, static_cast(PermissionState::PERMISSION_GRANTED))),
- .grantFlag = provider.ConsumeIntegralInRange(
- 0, static_cast(PermissionFlag::PERMISSION_ALLOW_THIS_TIME)),
+ .grantFlag = 1 << (provider.ConsumeIntegral() % FLAG_SIZE),
};
PreAuthorizationInfo info = {
@@ -84,7 +85,8 @@ void InitHapPolicy(const std::string& permissionName, const std::string& bundleN
policy.domain = provider.ConsumeRandomLengthString();
policy.permList = { def };
policy.permStateList = { state };
- policy.aclRequestedList = {provider.ConsumeRandomLengthString()};
+ std::string aclPermissionName = ConsumePermissionName(provider);
+ policy.aclRequestedList = {aclPermissionName};
policy.preAuthorizationInfo = { info };
policy.checkIgnore = static_cast(provider.ConsumeIntegralInRange(
0, static_cast(HapPolicyCheckIgnore::ACL_IGNORE_CHECK)));
@@ -99,7 +101,7 @@ bool AllocHapTokenServiceFuzzTest(const uint8_t* data, size_t size)
}
FuzzedDataProvider provider(data, size);
- std::string permissionName = provider.ConsumeRandomLengthString();
+ std::string permissionName = ConsumePermissionName(provider);
std::string bundleName = provider.ConsumeRandomLengthString();
HapInfoParcel hapInfoParcel;
diff --git a/test/fuzztest/normalize_service/accesstoken/allochaptokenservice_fuzzer/corpus/init b/test/fuzztest/normalize_service/accesstoken/allochaptokenservice_fuzzer/corpus/init
deleted file mode 100644
index 65af8ee8d11bf23407ea34d4de49f7cbb6a2b791..0000000000000000000000000000000000000000
--- a/test/fuzztest/normalize_service/accesstoken/allochaptokenservice_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2025 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/normalize_service/accesstoken/allochaptokenservice_fuzzer/corpus/init0 b/test/fuzztest/normalize_service/accesstoken/allochaptokenservice_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..729b2390a9e7f70f13ce5c0fdd6462d583e0c840
Binary files /dev/null and b/test/fuzztest/normalize_service/accesstoken/allochaptokenservice_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/normalize_service/accesstoken/gethaptokenidservice_fuzzer/corpus/init b/test/fuzztest/normalize_service/accesstoken/gethaptokenidservice_fuzzer/corpus/init
deleted file mode 100644
index f3c5c238f0704c0c9ac8637db30d9908d6d5e30c..0000000000000000000000000000000000000000
--- a/test/fuzztest/normalize_service/accesstoken/gethaptokenidservice_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2025 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.
-
-0x6f0x680x6f0x730x2e0x670x6c0x6f0x620x610x6c0x2e0x730x790x730x740x650x6d0x720x650x735c0000000000
\ No newline at end of file
diff --git a/test/fuzztest/normalize_service/accesstoken/gethaptokenidservice_fuzzer/corpus/init0 b/test/fuzztest/normalize_service/accesstoken/gethaptokenidservice_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..c5517a61662c3fb2fb60cad61f133760b39b5254
Binary files /dev/null and b/test/fuzztest/normalize_service/accesstoken/gethaptokenidservice_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/corpus/init b/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/corpus/init
deleted file mode 100644
index f8e3e81a3dc1af0749aab618bd724303b3ee5c1a..0000000000000000000000000000000000000000
--- a/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2025 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.
-
-15460020
\ No newline at end of file
diff --git a/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/corpus/init0 b/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..a185f0e056360a9eeb041b5e2f1a36b2592081b5
--- /dev/null
+++ b/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/corpus/init0
@@ -0,0 +1 @@
+w#6ËUZ&qj|ȯz~9IU` S
\ No newline at end of file
diff --git a/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/gethaptokeninfoservice_fuzzer.cpp b/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/gethaptokeninfoservice_fuzzer.cpp
index dc9307835bdfa16aae3cfa13b23736fba2ade699..7ae56714db1ed99c30c5022cd8732b83d00fcc15 100644
--- a/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/gethaptokeninfoservice_fuzzer.cpp
+++ b/test/fuzztest/normalize_service/accesstoken/gethaptokeninfoservice_fuzzer/gethaptokeninfoservice_fuzzer.cpp
@@ -15,6 +15,7 @@
#include "gethaptokeninfoservice_fuzzer.h"
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -34,7 +35,7 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
if (!datas.WriteUint32(tokenId)) {
diff --git a/test/fuzztest/normalize_service/accesstoken/getpermissionflagservice_fuzzer/corpus/init b/test/fuzztest/normalize_service/accesstoken/getpermissionflagservice_fuzzer/corpus/init
deleted file mode 100644
index 65af8ee8d11bf23407ea34d4de49f7cbb6a2b791..0000000000000000000000000000000000000000
--- a/test/fuzztest/normalize_service/accesstoken/getpermissionflagservice_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2025 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/normalize_service/accesstoken/getpermissionflagservice_fuzzer/corpus/init0 b/test/fuzztest/normalize_service/accesstoken/getpermissionflagservice_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/normalize_service/accesstoken/getpermissionflagservice_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/normalize_service/accesstoken/getpermissionflagservice_fuzzer/getpermissionflagservice_fuzzer.cpp b/test/fuzztest/normalize_service/accesstoken/getpermissionflagservice_fuzzer/getpermissionflagservice_fuzzer.cpp
index b96edd3fb5d39f0acd7fa441284c2fba6b431643..f3fca708e1d671bf58bccf7583ebbc133aa71285 100644
--- a/test/fuzztest/normalize_service/accesstoken/getpermissionflagservice_fuzzer/getpermissionflagservice_fuzzer.cpp
+++ b/test/fuzztest/normalize_service/accesstoken/getpermissionflagservice_fuzzer/getpermissionflagservice_fuzzer.cpp
@@ -22,6 +22,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -39,8 +40,8 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
- std::string permissionName = provider.ConsumeRandomLengthString();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
MessageParcel sendData;
sendData.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
if (!sendData.WriteUint32(tokenId) || !sendData.WriteString(permissionName)) {
diff --git a/test/fuzztest/normalize_service/accesstoken/grantpermissionservice_fuzzer/corpus/init b/test/fuzztest/normalize_service/accesstoken/grantpermissionservice_fuzzer/corpus/init
deleted file mode 100644
index 65af8ee8d11bf23407ea34d4de49f7cbb6a2b791..0000000000000000000000000000000000000000
--- a/test/fuzztest/normalize_service/accesstoken/grantpermissionservice_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2025 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/normalize_service/accesstoken/grantpermissionservice_fuzzer/corpus/init0 b/test/fuzztest/normalize_service/accesstoken/grantpermissionservice_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/normalize_service/accesstoken/grantpermissionservice_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/normalize_service/accesstoken/grantpermissionservice_fuzzer/grantpermissionservice_fuzzer.cpp b/test/fuzztest/normalize_service/accesstoken/grantpermissionservice_fuzzer/grantpermissionservice_fuzzer.cpp
index ff212044b4be1a2e571a931472dcfcef0a70988a..887d806b915159ab6def36036a795f7445122d13 100644
--- a/test/fuzztest/normalize_service/accesstoken/grantpermissionservice_fuzzer/grantpermissionservice_fuzzer.cpp
+++ b/test/fuzztest/normalize_service/accesstoken/grantpermissionservice_fuzzer/grantpermissionservice_fuzzer.cpp
@@ -23,6 +23,7 @@
#undef private
#include "access_token.h"
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_info_manager.h"
#include "accesstoken_kit.h"
#include "accesstoken_manager_service.h"
@@ -30,6 +31,7 @@
#include "iaccess_token_manager.h"
#include "token_setproc.h"
+
using namespace std;
using namespace OHOS::Security::AccessToken;
static HapInfoParams g_InfoParms = {
@@ -68,8 +70,8 @@ bool GrantPermissionServiceFuzzTest(const uint8_t* data, size_t size)
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
- std::string permissionName = provider.ConsumeRandomLengthString();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
uint32_t flagIndex = provider.ConsumeIntegral() % FLAG_LIST_SIZE;
PermissionFlag flag = FLAG_LIST[flagIndex];
diff --git a/test/fuzztest/normalize_service/accesstoken/inithaptokenservice_fuzzer/corpus/init b/test/fuzztest/normalize_service/accesstoken/inithaptokenservice_fuzzer/corpus/init
deleted file mode 100644
index 65af8ee8d11bf23407ea34d4de49f7cbb6a2b791..0000000000000000000000000000000000000000
--- a/test/fuzztest/normalize_service/accesstoken/inithaptokenservice_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2025 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/normalize_service/accesstoken/inithaptokenservice_fuzzer/corpus/init0 b/test/fuzztest/normalize_service/accesstoken/inithaptokenservice_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..bce21b247b4eabb1b70b0fa5867b6e1d28c18422
Binary files /dev/null and b/test/fuzztest/normalize_service/accesstoken/inithaptokenservice_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/normalize_service/accesstoken/inithaptokenservice_fuzzer/inithaptokenservice_fuzzer.cpp b/test/fuzztest/normalize_service/accesstoken/inithaptokenservice_fuzzer/inithaptokenservice_fuzzer.cpp
index 23c502e95ec7fc241e2a4951863f10756a8f5683..ad25924f5dc999f4a4e66ecb1a6ad5dbf80966d4 100644
--- a/test/fuzztest/normalize_service/accesstoken/inithaptokenservice_fuzzer/inithaptokenservice_fuzzer.cpp
+++ b/test/fuzztest/normalize_service/accesstoken/inithaptokenservice_fuzzer/inithaptokenservice_fuzzer.cpp
@@ -17,6 +17,7 @@
#include
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "hap_info_parcel.h"
@@ -40,7 +41,7 @@ void InitHapInfoParams(const std::string& bundleName, FuzzedDataProvider& provid
param.isSystemApp = provider.ConsumeBool();
param.appDistributionType = provider.ConsumeRandomLengthString();
param.isRestore = provider.ConsumeBool();
- param.tokenID = provider.ConsumeIntegral();
+ param.tokenID = ConsumeTokenId(provider);
param.isAtomicService = provider.ConsumeBool();
}
@@ -99,7 +100,7 @@ bool InitHapTokenServiceFuzzTest(const uint8_t* data, size_t size)
}
FuzzedDataProvider provider(data, size);
- std::string permissionName = provider.ConsumeRandomLengthString();
+ std::string permissionName = ConsumePermissionName(provider);
std::string bundleName = provider.ConsumeRandomLengthString();
HapInfoParcel hapInfoParcel;
diff --git a/test/fuzztest/normalize_service/accesstoken/revokepermissionservice_fuzzer/corpus/init b/test/fuzztest/normalize_service/accesstoken/revokepermissionservice_fuzzer/corpus/init
deleted file mode 100644
index 65af8ee8d11bf23407ea34d4de49f7cbb6a2b791..0000000000000000000000000000000000000000
--- a/test/fuzztest/normalize_service/accesstoken/revokepermissionservice_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2025 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/normalize_service/accesstoken/revokepermissionservice_fuzzer/corpus/init0 b/test/fuzztest/normalize_service/accesstoken/revokepermissionservice_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/normalize_service/accesstoken/revokepermissionservice_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/normalize_service/accesstoken/revokepermissionservice_fuzzer/revokepermissionservice_fuzzer.cpp b/test/fuzztest/normalize_service/accesstoken/revokepermissionservice_fuzzer/revokepermissionservice_fuzzer.cpp
index eefc29c51864da0fc2de86479d38ba2b5015e52f..55e030e1c56097f1a3eafebaebb51c9cbe981104 100644
--- a/test/fuzztest/normalize_service/accesstoken/revokepermissionservice_fuzzer/revokepermissionservice_fuzzer.cpp
+++ b/test/fuzztest/normalize_service/accesstoken/revokepermissionservice_fuzzer/revokepermissionservice_fuzzer.cpp
@@ -22,6 +22,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -50,8 +51,8 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
- std::string permissionName = provider.ConsumeRandomLengthString();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
diff --git a/test/fuzztest/services/accesstoken/allochaptokenstub_fuzzer/allochaptokenstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/allochaptokenstub_fuzzer/allochaptokenstub_fuzzer.cpp
index 10ea736632a751ca6931b9490ec9c2dbbd7dbb37..626d8ac9f817c6667ea89f1da242131aac1f27e6 100644
--- a/test/fuzztest/services/accesstoken/allochaptokenstub_fuzzer/allochaptokenstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/allochaptokenstub_fuzzer/allochaptokenstub_fuzzer.cpp
@@ -18,6 +18,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "hap_info_parcel.h"
@@ -27,6 +28,7 @@ using namespace std;
using namespace OHOS::Security::AccessToken;
const int CONSTANTS_NUMBER_TWO = 2;
static const int32_t ROOT_UID = 0;
+const static int32_t FLAG_SIZE = 16;
namespace OHOS {
void InitHapInfoParams(const std::string& bundleName, FuzzedDataProvider& provider, HapInfoParams& param)
@@ -41,7 +43,7 @@ namespace OHOS {
param.isSystemApp = provider.ConsumeBool();
param.appDistributionType = provider.ConsumeRandomLengthString();
param.isRestore = provider.ConsumeBool();
- param.tokenID = provider.ConsumeIntegral();
+ param.tokenID = ConsumeTokenId(provider);
param.isAtomicService = provider.ConsumeBool();
}
@@ -71,8 +73,7 @@ namespace OHOS {
.permissionName = permissionName,
.grantStatus = static_cast(provider.ConsumeIntegralInRange(
0, static_cast(PermissionState::PERMISSION_GRANTED))),
- .grantFlag = provider.ConsumeIntegralInRange(
- 0, static_cast(PermissionFlag::PERMISSION_ALLOW_THIS_TIME)),
+ .grantFlag = 1 << (provider.ConsumeIntegral() % FLAG_SIZE),
};
PreAuthorizationInfo info = {
@@ -85,7 +86,7 @@ namespace OHOS {
policy.domain = provider.ConsumeRandomLengthString();
policy.permList = { def };
policy.permStateList = { state };
- policy.aclRequestedList = {provider.ConsumeRandomLengthString()};
+ policy.aclRequestedList = {ConsumePermissionName(provider)};
policy.preAuthorizationInfo = { info };
policy.checkIgnore = static_cast(provider.ConsumeIntegralInRange(
0, static_cast(HapPolicyCheckIgnore::ACL_IGNORE_CHECK)));
@@ -100,7 +101,7 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- std::string permissionName = provider.ConsumeRandomLengthString();
+ std::string permissionName = ConsumePermissionName(provider);
std::string bundleName = provider.ConsumeRandomLengthString();
HapInfoParcel hapInfoParcel;
diff --git a/test/fuzztest/services/accesstoken/allochaptokenstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/allochaptokenstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/allochaptokenstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/allochaptokenstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/allochaptokenstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..729b2390a9e7f70f13ce5c0fdd6462d583e0c840
Binary files /dev/null and b/test/fuzztest/services/accesstoken/allochaptokenstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/alloclocaltokenidstub_fuzzer/alloclocaltokenidstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/alloclocaltokenidstub_fuzzer/alloclocaltokenidstub_fuzzer.cpp
index 98c769efe3525df5eaf728aa241f0c0e4a276de9..d593cb53622c5cd63dc1fd4a2607c566a6545eb7 100644
--- a/test/fuzztest/services/accesstoken/alloclocaltokenidstub_fuzzer/alloclocaltokenidstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/alloclocaltokenidstub_fuzzer/alloclocaltokenidstub_fuzzer.cpp
@@ -22,6 +22,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -40,7 +41,7 @@ namespace OHOS {
FuzzedDataProvider provider(data, size);
std::string remoteDeviceID = provider.ConsumeRandomLengthString();
- AccessTokenID tokenId = provider.ConsumeIntegral();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
MessageParcel inData;
inData.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
diff --git a/test/fuzztest/services/accesstoken/alloclocaltokenidstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/alloclocaltokenidstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/alloclocaltokenidstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/alloclocaltokenidstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/alloclocaltokenidstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..3cb0ebde09d81deb7359841e58eb42136b06faa8
Binary files /dev/null and b/test/fuzztest/services/accesstoken/alloclocaltokenidstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/clearusergrantedpermissionstatestub_fuzzer/clearusergrantedpermissionstatestub_fuzzer.cpp b/test/fuzztest/services/accesstoken/clearusergrantedpermissionstatestub_fuzzer/clearusergrantedpermissionstatestub_fuzzer.cpp
index 1fa95d9a63de5da77ccdc4854fd31e19aa570ab7..3d080035cacc15f4cabd85bcd8f9ac1bed1e7b90 100644
--- a/test/fuzztest/services/accesstoken/clearusergrantedpermissionstatestub_fuzzer/clearusergrantedpermissionstatestub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/clearusergrantedpermissionstatestub_fuzzer/clearusergrantedpermissionstatestub_fuzzer.cpp
@@ -22,6 +22,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -39,7 +40,7 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
MessageParcel sendData;
sendData.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
if (!sendData.WriteUint32(tokenId)) {
diff --git a/test/fuzztest/services/accesstoken/clearusergrantedpermissionstatestub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/clearusergrantedpermissionstatestub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/clearusergrantedpermissionstatestub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/clearusergrantedpermissionstatestub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/clearusergrantedpermissionstatestub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..37dbd59e07bcceab4d2c9271d3916847f519eb90
--- /dev/null
+++ b/test/fuzztest/services/accesstoken/clearusergrantedpermissionstatestub_fuzzer/corpus/init0
@@ -0,0 +1,2 @@
+8ZQ-9
+aо
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/deleteremotehaptokeninfostub_fuzzer/deleteremotehaptokeninfostub_fuzzer.cpp b/test/fuzztest/services/accesstoken/deleteremotehaptokeninfostub_fuzzer/deleteremotehaptokeninfostub_fuzzer.cpp
index afa6f19b4342bb09dd5851915f5095c00f0223ea..dbff8141f844b99c726fac424546190aba8a5247 100644
--- a/test/fuzztest/services/accesstoken/deleteremotehaptokeninfostub_fuzzer/deleteremotehaptokeninfostub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/deleteremotehaptokeninfostub_fuzzer/deleteremotehaptokeninfostub_fuzzer.cpp
@@ -15,6 +15,7 @@
#include "deleteremotehaptokeninfostub_fuzzer.h"
+#include "accesstoken_fuzzdata.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "hap_token_info_for_sync_parcel.h"
#include "i_token_sync_manager.h"
@@ -49,7 +50,7 @@ bool DeleteRemoteHapTokenInfoStubFuzzTest(const uint8_t* data, size_t size)
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenID = provider.ConsumeIntegral();
+ AccessTokenID tokenID = ConsumeTokenId(provider);
UpdateRemoteHapTokenInfo();
diff --git a/test/fuzztest/services/accesstoken/deleteremotetokenstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/deleteremotetokenstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/deleteremotetokenstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/deleteremotetokenstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/deleteremotetokenstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..3cb0ebde09d81deb7359841e58eb42136b06faa8
Binary files /dev/null and b/test/fuzztest/services/accesstoken/deleteremotetokenstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/deleteremotetokenstub_fuzzer/deleteremotetokenstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/deleteremotetokenstub_fuzzer/deleteremotetokenstub_fuzzer.cpp
index 37ab57ac361dded7fc34d7c7fde92b513d82d50f..83ce1e229abae7025394725d14e1613a01756d59 100644
--- a/test/fuzztest/services/accesstoken/deleteremotetokenstub_fuzzer/deleteremotetokenstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/deleteremotetokenstub_fuzzer/deleteremotetokenstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_info_manager.h"
#include "accesstoken_kit.h"
#include "accesstoken_manager_service.h"
@@ -43,8 +44,8 @@ namespace OHOS {
FuzzedDataProvider provider(data, size);
std::string deviceID = provider.ConsumeRandomLengthString();
- AccessTokenID tokenId = provider.ConsumeIntegral();
-
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
if (!datas.WriteString(deviceID)) {
diff --git a/test/fuzztest/services/accesstoken/dumptokeninfostub_fuzzer/dumptokeninfostub_fuzzer.cpp b/test/fuzztest/services/accesstoken/dumptokeninfostub_fuzzer/dumptokeninfostub_fuzzer.cpp
index e29b4ac343a2964d92acac454c85e2cf97437d9f..af0674857d8de408d3b8e113449b98ff91e83837 100644
--- a/test/fuzztest/services/accesstoken/dumptokeninfostub_fuzzer/dumptokeninfostub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/dumptokeninfostub_fuzzer/dumptokeninfostub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -35,7 +36,7 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
diff --git a/test/fuzztest/services/accesstoken/getaccesstokenid_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/getaccesstokenid_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/getaccesstokenid_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/getaccesstokenid_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/getaccesstokenid_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..78779e2e2ce8bb524950ccae5de5895ce8d7e711
Binary files /dev/null and b/test/fuzztest/services/accesstoken/getaccesstokenid_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/getdefpermissionstub_fuzzer/getdefpermissionstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/getdefpermissionstub_fuzzer/getdefpermissionstub_fuzzer.cpp
index 80a4152eb1e60f6a47d23af632953aa501099267..35774859f2e02d9e74f785f87643fde7bc633665 100644
--- a/test/fuzztest/services/accesstoken/getdefpermissionstub_fuzzer/getdefpermissionstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/getdefpermissionstub_fuzzer/getdefpermissionstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -37,7 +38,7 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- std::string permissionName = provider.ConsumeRandomLengthString();
+ std::string permissionName = ConsumePermissionName(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
diff --git a/test/fuzztest/services/accesstoken/gethaptokenidstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/gethaptokenidstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/gethaptokenidstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/gethaptokenidstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/gethaptokenidstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..c5517a61662c3fb2fb60cad61f133760b39b5254
Binary files /dev/null and b/test/fuzztest/services/accesstoken/gethaptokenidstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/gethaptokeninfofromremotestub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/gethaptokeninfofromremotestub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/gethaptokeninfofromremotestub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/gethaptokeninfofromremotestub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/gethaptokeninfofromremotestub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..3cb0ebde09d81deb7359841e58eb42136b06faa8
Binary files /dev/null and b/test/fuzztest/services/accesstoken/gethaptokeninfofromremotestub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/gethaptokeninfofromremotestub_fuzzer/gethaptokeninfofromremotestub_fuzzer.cpp b/test/fuzztest/services/accesstoken/gethaptokeninfofromremotestub_fuzzer/gethaptokeninfofromremotestub_fuzzer.cpp
index 75908ff5850d187f152f2e07cecabf40256e8c82..a1feea9ebd3011bb604cf4b9be159004ba3d93d1 100644
--- a/test/fuzztest/services/accesstoken/gethaptokeninfofromremotestub_fuzzer/gethaptokeninfofromremotestub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/gethaptokeninfofromremotestub_fuzzer/gethaptokeninfofromremotestub_fuzzer.cpp
@@ -19,7 +19,7 @@
#include
#include
#undef private
-
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_info_manager.h"
#include "accesstoken_kit.h"
#include "accesstoken_manager_service.h"
@@ -42,7 +42,7 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
diff --git a/test/fuzztest/services/accesstoken/gethaptokeninfostub_fuzzer/gethaptokeninfostub_fuzzer.cpp b/test/fuzztest/services/accesstoken/gethaptokeninfostub_fuzzer/gethaptokeninfostub_fuzzer.cpp
index 9d1480999e09b1b5a7a169d200f5ac2cabfd0bd7..12819cda8f02a7858ea62ac54293acbd58565281 100644
--- a/test/fuzztest/services/accesstoken/gethaptokeninfostub_fuzzer/gethaptokeninfostub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/gethaptokeninfostub_fuzzer/gethaptokeninfostub_fuzzer.cpp
@@ -15,6 +15,7 @@
#include "gethaptokeninfostub_fuzzer.h"
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -34,7 +35,7 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
if (!datas.WriteUint32(tokenId)) {
diff --git a/test/fuzztest/services/accesstoken/getkernelpermissionsstub_fuzzer/getkernelpermissionsstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/getkernelpermissionsstub_fuzzer/getkernelpermissionsstub_fuzzer.cpp
index 0aedbb44bd48c2adb6565ab6ec81837b83d04fb9..149b4902a0f9f4a1a16642d62a06407b8b1ea72e 100644
--- a/test/fuzztest/services/accesstoken/getkernelpermissionsstub_fuzzer/getkernelpermissionsstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/getkernelpermissionsstub_fuzzer/getkernelpermissionsstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -35,7 +36,7 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
diff --git a/test/fuzztest/services/accesstoken/getnativetokenidstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/getnativetokenidstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/getnativetokenidstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/getnativetokenidstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/getnativetokenidstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..78779e2e2ce8bb524950ccae5de5895ce8d7e711
Binary files /dev/null and b/test/fuzztest/services/accesstoken/getnativetokenidstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/getnativetokeninfostub_fuzzer/getnativetokeninfostub_fuzzer.cpp b/test/fuzztest/services/accesstoken/getnativetokeninfostub_fuzzer/getnativetokeninfostub_fuzzer.cpp
index 74064f09af2da323fa4b2adef717e21a0832c46f..4313c7c4608a3002e1bb4b8276a4966d1f8f6316 100644
--- a/test/fuzztest/services/accesstoken/getnativetokeninfostub_fuzzer/getnativetokeninfostub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/getnativetokeninfostub_fuzzer/getnativetokeninfostub_fuzzer.cpp
@@ -22,6 +22,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -39,7 +40,7 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
MessageParcel inData;
inData.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
if (!inData.WriteUint32(tokenId)) {
diff --git a/test/fuzztest/services/accesstoken/getpermissionflagstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/getpermissionflagstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/getpermissionflagstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/getpermissionflagstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/getpermissionflagstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/accesstoken/getpermissionflagstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/getpermissionflagstub_fuzzer/getpermissionflagstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/getpermissionflagstub_fuzzer/getpermissionflagstub_fuzzer.cpp
index 3d9e4b2927fc7fc5726365004f96094d7f4e15b6..8d2c407dc6635053696c5ad65bb8843a5db61b61 100644
--- a/test/fuzztest/services/accesstoken/getpermissionflagstub_fuzzer/getpermissionflagstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/getpermissionflagstub_fuzzer/getpermissionflagstub_fuzzer.cpp
@@ -22,6 +22,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -39,8 +40,8 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
- std::string permissionName = provider.ConsumeRandomLengthString();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
MessageParcel sendData;
sendData.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
if (!sendData.WriteUint32(tokenId) || !sendData.WriteString(permissionName)) {
diff --git a/test/fuzztest/services/accesstoken/getpermissionrequesttogglestatusstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/getpermissionrequesttogglestatusstub_fuzzer/corpus/init
deleted file mode 100644
index 61a7da989b6badef958ee1eb0856df4a2477cda4..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/getpermissionrequesttogglestatusstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
diff --git a/test/fuzztest/services/accesstoken/getpermissionrequesttogglestatusstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/getpermissionrequesttogglestatusstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..4d63c39515f181fc115ae151cd1bf661c6ae68b4
Binary files /dev/null and b/test/fuzztest/services/accesstoken/getpermissionrequesttogglestatusstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/getpermissionrequesttogglestatusstub_fuzzer/getpermissionrequesttogglestatusstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/getpermissionrequesttogglestatusstub_fuzzer/getpermissionrequesttogglestatusstub_fuzzer.cpp
index 64d1b8ba519f0f0735d8d698e4e3284f6a9e6b9e..924d52cbc911ed07c37bb3e94a9b564984bf5483 100644
--- a/test/fuzztest/services/accesstoken/getpermissionrequesttogglestatusstub_fuzzer/getpermissionrequesttogglestatusstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/getpermissionrequesttogglestatusstub_fuzzer/getpermissionrequesttogglestatusstub_fuzzer.cpp
@@ -22,6 +22,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -39,7 +40,7 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- std::string permissionName = provider.ConsumeRandomLengthString();
+ std::string permissionName = ConsumePermissionName(provider);
int32_t userID = provider.ConsumeIntegral();
MessageParcel sendData;
if (!sendData.WriteInterfaceToken(IAccessTokenManager::GetDescriptor()) ||
diff --git a/test/fuzztest/services/accesstoken/getpermissionsstatusstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/getpermissionsstatusstub_fuzzer/corpus/init
deleted file mode 100644
index e7c3fecd8d4d4816e40088113a2316bb9eb2e13f..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/getpermissionsstatusstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/getpermissionsstatusstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/getpermissionsstatusstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/accesstoken/getpermissionsstatusstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/getpermissionsstatusstub_fuzzer/getpermissionsstatusstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/getpermissionsstatusstub_fuzzer/getpermissionsstatusstub_fuzzer.cpp
index 1cb3a60480f69f48dab0f7a9b9e684208976e73c..0ad990580e9e3290e59989961f57e98636ac02a4 100644
--- a/test/fuzztest/services/accesstoken/getpermissionsstatusstub_fuzzer/getpermissionsstatusstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/getpermissionsstatusstub_fuzzer/getpermissionsstatusstub_fuzzer.cpp
@@ -22,6 +22,7 @@
#include
#undef private
#include "access_token.h"
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_kit.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
@@ -47,8 +48,8 @@ size_t g_baseFuzzPos = 0;
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
- std::string permissionName = provider.ConsumeRandomLengthString();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
PermissionListState perm = {
.permissionName = permissionName,
.state = static_cast(provider.ConsumeIntegralInRange(
diff --git a/test/fuzztest/services/accesstoken/getpermissionusedtypestub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/getpermissionusedtypestub_fuzzer/corpus/init
deleted file mode 100644
index e7c3fecd8d4d4816e40088113a2316bb9eb2e13f..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/getpermissionusedtypestub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/getpermissionusedtypestub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/getpermissionusedtypestub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/accesstoken/getpermissionusedtypestub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/getpermissionusedtypestub_fuzzer/getpermissionusedtypestub_fuzzer.cpp b/test/fuzztest/services/accesstoken/getpermissionusedtypestub_fuzzer/getpermissionusedtypestub_fuzzer.cpp
index 4646653b0adf40e7b07223bf7252a4e89c47fe7a..b598bce8faea6ae565652cfdb651829935bf6f77 100644
--- a/test/fuzztest/services/accesstoken/getpermissionusedtypestub_fuzzer/getpermissionusedtypestub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/getpermissionusedtypestub_fuzzer/getpermissionusedtypestub_fuzzer.cpp
@@ -23,6 +23,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "hap_info_parcel.h"
@@ -41,8 +42,8 @@ bool GetPermissionUsedTypeStubFuzzTest(const uint8_t* data, size_t size)
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
- std::string permissionName = provider.ConsumeRandomLengthString();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
diff --git a/test/fuzztest/services/accesstoken/getremotehaptokeninfostub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/getremotehaptokeninfostub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/getremotehaptokeninfostub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/getremotehaptokeninfostub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/getremotehaptokeninfostub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..d9bc53f51dbda02469560b7d4efe48b61feb174a
Binary files /dev/null and b/test/fuzztest/services/accesstoken/getremotehaptokeninfostub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/getremotehaptokeninfostub_fuzzer/getremotehaptokeninfostub_fuzzer.cpp b/test/fuzztest/services/accesstoken/getremotehaptokeninfostub_fuzzer/getremotehaptokeninfostub_fuzzer.cpp
index 1c39a066fa9e91e8eadda95db94ca58edd4495e2..1a09d0c8555be989b4b5b1560cf87898888de342 100644
--- a/test/fuzztest/services/accesstoken/getremotehaptokeninfostub_fuzzer/getremotehaptokeninfostub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/getremotehaptokeninfostub_fuzzer/getremotehaptokeninfostub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "i_token_sync_manager.h"
#include "token_sync_manager_service.h"
@@ -36,7 +37,7 @@ namespace OHOS {
FuzzedDataProvider provider(data, size);
std::string deviceID = provider.ConsumeRandomLengthString();
- AccessTokenID tokenId = provider.ConsumeIntegral();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
MessageParcel datas;
datas.WriteInterfaceToken(ITokenSyncManager::GetDescriptor());
diff --git a/test/fuzztest/services/accesstoken/getremotenativetokenidstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/getremotenativetokenidstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/getremotenativetokenidstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/getremotenativetokenidstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/getremotenativetokenidstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..d9bc53f51dbda02469560b7d4efe48b61feb174a
Binary files /dev/null and b/test/fuzztest/services/accesstoken/getremotenativetokenidstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/getremotenativetokenidstub_fuzzer/getremotenativetokenidstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/getremotenativetokenidstub_fuzzer/getremotenativetokenidstub_fuzzer.cpp
index f6e748eb847ab0f10f4e8df9843b6d41b7378a4a..532bcce4b2f1e1e485b2dc40b1bbde63c779a1c6 100644
--- a/test/fuzztest/services/accesstoken/getremotenativetokenidstub_fuzzer/getremotenativetokenidstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/getremotenativetokenidstub_fuzzer/getremotenativetokenidstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_info_manager.h"
#include "accesstoken_kit.h"
#include "accesstoken_manager_service.h"
@@ -43,7 +44,7 @@ namespace OHOS {
FuzzedDataProvider provider(data, size);
std::string deviceID = provider.ConsumeRandomLengthString();
- AccessTokenID tokenId = provider.ConsumeIntegral();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
diff --git a/test/fuzztest/services/accesstoken/getreqpermissionbynamestub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/getreqpermissionbynamestub_fuzzer/corpus/init
deleted file mode 100644
index e7c3fecd8d4d4816e40088113a2316bb9eb2e13f..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/getreqpermissionbynamestub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/getreqpermissionbynamestub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/getreqpermissionbynamestub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/accesstoken/getreqpermissionbynamestub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/getreqpermissionbynamestub_fuzzer/getreqpermissionbynamestub_fuzzer.cpp b/test/fuzztest/services/accesstoken/getreqpermissionbynamestub_fuzzer/getreqpermissionbynamestub_fuzzer.cpp
index e1a82def80b7c36ae21cbbf863a80f07a21e3c10..999aab8ea58d6383126a4320ca8ee57c9e37ebec 100644
--- a/test/fuzztest/services/accesstoken/getreqpermissionbynamestub_fuzzer/getreqpermissionbynamestub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/getreqpermissionbynamestub_fuzzer/getreqpermissionbynamestub_fuzzer.cpp
@@ -20,6 +20,8 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -35,8 +37,8 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
- std::string permissionName = provider.ConsumeRandomLengthString();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
if (!datas.WriteUint32(tokenId) || !datas.WriteString(permissionName)) {
diff --git a/test/fuzztest/services/accesstoken/getreqpermissionsstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/getreqpermissionsstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/getreqpermissionsstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/getreqpermissionsstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/getreqpermissionsstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/accesstoken/getreqpermissionsstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/getreqpermissionsstub_fuzzer/getreqpermissionsstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/getreqpermissionsstub_fuzzer/getreqpermissionsstub_fuzzer.cpp
index 68722a9542554f4390decb64bafdf0c8cf14c571..9064ae8ad64d659bdbd59bb934b1ae9662fc0d34 100644
--- a/test/fuzztest/services/accesstoken/getreqpermissionsstub_fuzzer/getreqpermissionsstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/getreqpermissionsstub_fuzzer/getreqpermissionsstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -37,7 +38,7 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
diff --git a/test/fuzztest/services/accesstoken/getseccompenhancestub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/getseccompenhancestub_fuzzer/corpus/init
deleted file mode 100644
index e7c3fecd8d4d4816e40088113a2316bb9eb2e13f..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/getseccompenhancestub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/getseccompenhancestub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/getseccompenhancestub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/accesstoken/getseccompenhancestub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/getselfpermissionsstatestub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/getselfpermissionsstatestub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/getselfpermissionsstatestub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/getselfpermissionsstatestub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/getselfpermissionsstatestub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/accesstoken/getselfpermissionsstatestub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/getselfpermissionsstatestub_fuzzer/getselfpermissionsstatestub_fuzzer.cpp b/test/fuzztest/services/accesstoken/getselfpermissionsstatestub_fuzzer/getselfpermissionsstatestub_fuzzer.cpp
index 211bd26b0f3e6377b548fd32fd2e031a4029da22..4d7c195fac8af25b134be8119249efa4c5bbd9a9 100644
--- a/test/fuzztest/services/accesstoken/getselfpermissionsstatestub_fuzzer/getselfpermissionsstatestub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/getselfpermissionsstatestub_fuzzer/getselfpermissionsstatestub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -37,7 +38,7 @@ namespace OHOS {
FuzzedDataProvider provider(data, size);
PermissionListState perm = {
- .permissionName = provider.ConsumeRandomLengthString(),
+ .permissionName = ConsumePermissionName(provider),
.state = static_cast(provider.ConsumeIntegralInRange(
0, static_cast(PermissionOper::BUTT_OPER))),
};
diff --git a/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/corpus/init
deleted file mode 100644
index 65af8ee8d11bf23407ea34d4de49f7cbb6a2b791..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2025 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/getselfpermissionstatusstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/getselfpermissionstatusstub_fuzzer.cpp
index 6de8ea9770310c747146e082be2d5e4300fcc381..a6c3efcce111897b5b466c8806e64f33553c8d3a 100644
--- a/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/getselfpermissionstatusstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/getselfpermissionstatusstub_fuzzer/getselfpermissionstatusstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -36,7 +37,7 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- std::string permissionName = provider.ConsumeRandomLengthString();
+ std::string permissionName = ConsumePermissionName(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
if (!datas.WriteString(permissionName)) {
diff --git a/test/fuzztest/services/accesstoken/gettokenidbyuseridstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/gettokenidbyuseridstub_fuzzer/corpus/init
deleted file mode 100644
index 2aea1356e3c3b3ee6e12ad3f72640897d769d02e..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/gettokenidbyuseridstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2025 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.
-
-FUZZ
diff --git a/test/fuzztest/services/accesstoken/gettokenidbyuseridstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/gettokenidbyuseridstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..f0ea7b716a557f111038a658bbb04ab0c6a9404b
Binary files /dev/null and b/test/fuzztest/services/accesstoken/gettokenidbyuseridstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/gettokentypestub_fuzzer/gettokentypestub_fuzzer.cpp b/test/fuzztest/services/accesstoken/gettokentypestub_fuzzer/gettokentypestub_fuzzer.cpp
index 3c9a47a65136a4b39f8bad6952068bef8f2bb01c..704a5d8b120e1093de8eec1d91e0913b2f6e7b6e 100644
--- a/test/fuzztest/services/accesstoken/gettokentypestub_fuzzer/gettokentypestub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/gettokentypestub_fuzzer/gettokentypestub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -35,7 +36,7 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
MessageParcel in;
in.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
if (!in.WriteUint32(tokenId)) {
diff --git a/test/fuzztest/services/accesstoken/grantpermissionforspecifiedtimestub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/grantpermissionforspecifiedtimestub_fuzzer/corpus/init
deleted file mode 100644
index e7c3fecd8d4d4816e40088113a2316bb9eb2e13f..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/grantpermissionforspecifiedtimestub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/grantpermissionforspecifiedtimestub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/grantpermissionforspecifiedtimestub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/accesstoken/grantpermissionforspecifiedtimestub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/grantpermissionforspecifiedtimestub_fuzzer/grantpermissionforspecifiedtimestub_fuzzer.cpp b/test/fuzztest/services/accesstoken/grantpermissionforspecifiedtimestub_fuzzer/grantpermissionforspecifiedtimestub_fuzzer.cpp
index 74ea69bb4cc9a23e7d73a94ebfaf6bb6f3b945f1..0d61a72d872389322e89b0ca3a1ccb6ca5a12699 100644
--- a/test/fuzztest/services/accesstoken/grantpermissionforspecifiedtimestub_fuzzer/grantpermissionforspecifiedtimestub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/grantpermissionforspecifiedtimestub_fuzzer/grantpermissionforspecifiedtimestub_fuzzer.cpp
@@ -22,6 +22,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "hap_info_parcel.h"
@@ -40,8 +41,8 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
- std::string permissionName = provider.ConsumeRandomLengthString();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
uint32_t onceTime = provider.ConsumeIntegral();
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
diff --git a/test/fuzztest/services/accesstoken/grantpermissionstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/grantpermissionstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/grantpermissionstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/grantpermissionstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/grantpermissionstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/accesstoken/grantpermissionstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/grantpermissionstub_fuzzer/grantpermissionstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/grantpermissionstub_fuzzer/grantpermissionstub_fuzzer.cpp
index 7668fec79bbd909dfc85e3faa059767c184ada31..8c6a4aa3a736b02729dffad2d3c8d8e26f3fb31e 100644
--- a/test/fuzztest/services/accesstoken/grantpermissionstub_fuzzer/grantpermissionstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/grantpermissionstub_fuzzer/grantpermissionstub_fuzzer.cpp
@@ -23,6 +23,7 @@
#undef private
#include "access_token.h"
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_info_manager.h"
#include "accesstoken_kit.h"
#include "accesstoken_manager_service.h"
@@ -48,6 +49,17 @@ static HapPolicyParams g_PolicyPrams = {
const int CONSTANTS_NUMBER_TWO = 2;
const int CONSTANTS_NUMBER_THREE = 3;
static const int32_t ROOT_UID = 0;
+static const vector FLAG_LIST = {
+ PERMISSION_DEFAULT_FLAG,
+ PERMISSION_USER_SET,
+ PERMISSION_USER_FIXED,
+ PERMISSION_SYSTEM_FIXED,
+ PERMISSION_PRE_AUTHORIZED_CANCELABLE,
+ PERMISSION_COMPONENT_SET,
+ PERMISSION_FIXED_FOR_SECURITY_POLICY,
+ PERMISSION_ALLOW_THIS_TIME
+};
+static const uint32_t FLAG_LIST_SIZE = 8;
namespace OHOS {
bool GrantPermissionStubFuzzTest(const uint8_t* data, size_t size)
@@ -57,10 +69,10 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
- std::string permissionName = provider.ConsumeRandomLengthString();
- uint32_t flag = provider.ConsumeIntegralInRange(
- 0, static_cast(PermissionFlag::PERMISSION_ALLOW_THIS_TIME));
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
+ uint32_t flagIndex = provider.ConsumeIntegral() % FLAG_LIST_SIZE;
+ uint32_t flag = FLAG_LIST[flagIndex];
int32_t grantMode = static_cast(provider.ConsumeIntegralInRange(1, 2));
MessageParcel datas;
diff --git a/test/fuzztest/services/accesstoken/inithaptokenstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/inithaptokenstub_fuzzer/corpus/init
deleted file mode 100644
index e7c3fecd8d4d4816e40088113a2316bb9eb2e13f..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/inithaptokenstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/inithaptokenstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/inithaptokenstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..bce21b247b4eabb1b70b0fa5867b6e1d28c18422
Binary files /dev/null and b/test/fuzztest/services/accesstoken/inithaptokenstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/inithaptokenstub_fuzzer/inithaptokenstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/inithaptokenstub_fuzzer/inithaptokenstub_fuzzer.cpp
index 465f60c7d210717c0c985b376968b0f289fba287..091e8c6a99af048e3ee9edaae30099cf1c2bc128 100644
--- a/test/fuzztest/services/accesstoken/inithaptokenstub_fuzzer/inithaptokenstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/inithaptokenstub_fuzzer/inithaptokenstub_fuzzer.cpp
@@ -17,6 +17,7 @@
#include
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "hap_info_parcel.h"
@@ -40,7 +41,7 @@ namespace OHOS {
param.isSystemApp = provider.ConsumeBool();
param.appDistributionType = provider.ConsumeRandomLengthString();
param.isRestore = provider.ConsumeBool();
- param.tokenID = provider.ConsumeIntegral();
+ param.tokenID = ConsumeTokenId(provider);
param.isAtomicService = provider.ConsumeBool();
}
@@ -99,7 +100,7 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- std::string permissionName = provider.ConsumeRandomLengthString();
+ std::string permissionName = ConsumePermissionName(provider);
std::string bundleName = provider.ConsumeRandomLengthString();
HapInfoParcel hapInfoParcel;
diff --git a/test/fuzztest/services/accesstoken/registerpermstatechangecallbackstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/registerpermstatechangecallbackstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/registerpermstatechangecallbackstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/registerpermstatechangecallbackstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/registerpermstatechangecallbackstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/accesstoken/registerpermstatechangecallbackstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/registerpermstatechangecallbackstub_fuzzer/registerpermstatechangecallbackstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/registerpermstatechangecallbackstub_fuzzer/registerpermstatechangecallbackstub_fuzzer.cpp
index aaafac5b89dd37cbc810e0c232fc79c065dd0f0c..74284fef8c8f630fe7c9e469bda22fa5dce545c3 100644
--- a/test/fuzztest/services/accesstoken/registerpermstatechangecallbackstub_fuzzer/registerpermstatechangecallbackstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/registerpermstatechangecallbackstub_fuzzer/registerpermstatechangecallbackstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_client.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
@@ -54,8 +55,8 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
- std::string permissionName = provider.ConsumeRandomLengthString();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
PermStateChangeScope scopeInfo;
scopeInfo.permList = { permissionName };
diff --git a/test/fuzztest/services/accesstoken/registerselfpermstatechangecallbackstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/registerselfpermstatechangecallbackstub_fuzzer/corpus/init
deleted file mode 100644
index 65af8ee8d11bf23407ea34d4de49f7cbb6a2b791..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/registerselfpermstatechangecallbackstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2025 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/registerselfpermstatechangecallbackstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/registerselfpermstatechangecallbackstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/accesstoken/registerselfpermstatechangecallbackstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/registerselfpermstatechangecallbackstub_fuzzer/registerselfpermstatechangecallbackstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/registerselfpermstatechangecallbackstub_fuzzer/registerselfpermstatechangecallbackstub_fuzzer.cpp
index c059674e114a29ab55de356d2a020d5f1f1786b9..02ddbb7e5667230290e3f4de302fe88167dc1393 100644
--- a/test/fuzztest/services/accesstoken/registerselfpermstatechangecallbackstub_fuzzer/registerselfpermstatechangecallbackstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/registerselfpermstatechangecallbackstub_fuzzer/registerselfpermstatechangecallbackstub_fuzzer.cpp
@@ -22,6 +22,7 @@
#undef private
#include "access_token.h"
#define private public
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_id_manager.h"
#include "accesstoken_kit.h"
#include "accesstoken_manager_client.h"
@@ -87,8 +88,8 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
- std::string permissionName = provider.ConsumeRandomLengthString();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
PermStateChangeScope scopeInfo;
scopeInfo.permList = { permissionName };
diff --git a/test/fuzztest/services/accesstoken/requestapppermonsettingstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/requestapppermonsettingstub_fuzzer/corpus/init
deleted file mode 100644
index e7c3fecd8d4d4816e40088113a2316bb9eb2e13f..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/requestapppermonsettingstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/requestapppermonsettingstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/requestapppermonsettingstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/accesstoken/requestapppermonsettingstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/requestapppermonsettingstub_fuzzer/requestapppermonsettingstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/requestapppermonsettingstub_fuzzer/requestapppermonsettingstub_fuzzer.cpp
index 9589180193e8d4d5c2c7d03e00245fead54ce367..4609f556c75d19c38adb5fbfaff58d79babfddb5 100644
--- a/test/fuzztest/services/accesstoken/requestapppermonsettingstub_fuzzer/requestapppermonsettingstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/requestapppermonsettingstub_fuzzer/requestapppermonsettingstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -35,7 +36,7 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
diff --git a/test/fuzztest/services/accesstoken/revokepermissionstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/revokepermissionstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/revokepermissionstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/revokepermissionstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/revokepermissionstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/accesstoken/revokepermissionstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/revokepermissionstub_fuzzer/revokepermissionstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/revokepermissionstub_fuzzer/revokepermissionstub_fuzzer.cpp
index c17a2572a90c98025a0b07a705bd4a07efab1e25..dd64ba4f00f3c9f36af8aa131f4e5a6c0b0f1611 100644
--- a/test/fuzztest/services/accesstoken/revokepermissionstub_fuzzer/revokepermissionstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/revokepermissionstub_fuzzer/revokepermissionstub_fuzzer.cpp
@@ -22,6 +22,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -30,6 +31,17 @@ using namespace std;
using namespace OHOS::Security::AccessToken;
const int CONSTANTS_NUMBER_TWO = 2;
static const int32_t ROOT_UID = 0;
+static const vector FLAG_LIST = {
+ PERMISSION_DEFAULT_FLAG,
+ PERMISSION_USER_SET,
+ PERMISSION_USER_FIXED,
+ PERMISSION_SYSTEM_FIXED,
+ PERMISSION_PRE_AUTHORIZED_CANCELABLE,
+ PERMISSION_COMPONENT_SET,
+ PERMISSION_FIXED_FOR_SECURITY_POLICY,
+ PERMISSION_ALLOW_THIS_TIME
+};
+static const uint32_t FLAG_LIST_SIZE = 8;
namespace OHOS {
bool RevokePermissionStubFuzzTest(const uint8_t* data, size_t size)
@@ -39,16 +51,15 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
- std::string testName = provider.ConsumeRandomLengthString();
- uint32_t flag = static_cast(provider.ConsumeIntegralInRange(
- 0, static_cast(PermissionFlag::PERMISSION_ALLOW_THIS_TIME)));
- int32_t grantMode = static_cast(provider.ConsumeIntegralInRange(1, 2));
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
+ uint32_t flagIndex = provider.ConsumeIntegral() % FLAG_LIST_SIZE;
+ uint32_t flag = FLAG_LIST[flagIndex];
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
- if (!datas.WriteUint32(tokenId) || !datas.WriteString(testName) ||
- !datas.WriteInt32(flag) || !datas.WriteInt32(grantMode)) {
+ if (!datas.WriteUint32(tokenId) || !datas.WriteString(permissionName) ||
+ !datas.WriteInt32(flag)) {
return false;
}
uint32_t code = static_cast(
diff --git a/test/fuzztest/services/accesstoken/setpermdialogcapstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/setpermdialogcapstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/setpermdialogcapstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/setpermdialogcapstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/setpermdialogcapstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..c5517a61662c3fb2fb60cad61f133760b39b5254
Binary files /dev/null and b/test/fuzztest/services/accesstoken/setpermdialogcapstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/setpermissionrequesttogglestatusstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/setpermissionrequesttogglestatusstub_fuzzer/corpus/init
deleted file mode 100644
index 61a7da989b6badef958ee1eb0856df4a2477cda4..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/setpermissionrequesttogglestatusstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
diff --git a/test/fuzztest/services/accesstoken/setpermissionrequesttogglestatusstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/setpermissionrequesttogglestatusstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..00c0ecdc7b03809fe2022acc85f8d0599880c8f3
Binary files /dev/null and b/test/fuzztest/services/accesstoken/setpermissionrequesttogglestatusstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/setpermissionrequesttogglestatusstub_fuzzer/setpermissionrequesttogglestatusstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/setpermissionrequesttogglestatusstub_fuzzer/setpermissionrequesttogglestatusstub_fuzzer.cpp
index c31b8910fd72b8b54a1a1b61415fc147ffb4efbd..dac2239cae33567047ab61452068c44413304eb4 100644
--- a/test/fuzztest/services/accesstoken/setpermissionrequesttogglestatusstub_fuzzer/setpermissionrequesttogglestatusstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/setpermissionrequesttogglestatusstub_fuzzer/setpermissionrequesttogglestatusstub_fuzzer.cpp
@@ -22,6 +22,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -30,6 +31,7 @@ using namespace std;
using namespace OHOS::Security::AccessToken;
const int CONSTANTS_NUMBER_TWO = 2;
static const int32_t ROOT_UID = 0;
+static const int STATUS_MAX = 2;
namespace OHOS {
bool SetPermissionRequestToggleStatusStubFuzzTest(const uint8_t* data, size_t size)
@@ -39,8 +41,8 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- std::string permissionName = provider.ConsumeRandomLengthString();
- uint32_t status = provider.ConsumeIntegral();
+ std::string permissionName = ConsumePermissionName(provider);
+ uint32_t status = provider.ConsumeIntegral() % STATUS_MAX;
int32_t userID = provider.ConsumeIntegral();
MessageParcel sendData;
if (!sendData.WriteInterfaceToken(IAccessTokenManager::GetDescriptor()) ||
diff --git a/test/fuzztest/services/accesstoken/verifyaccesstokenstub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/verifyaccesstokenstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/verifyaccesstokenstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/verifyaccesstokenstub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/verifyaccesstokenstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/accesstoken/verifyaccesstokenstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/verifyaccesstokenstub_fuzzer/verifyaccesstokenstub_fuzzer.cpp b/test/fuzztest/services/accesstoken/verifyaccesstokenstub_fuzzer/verifyaccesstokenstub_fuzzer.cpp
index c8a1063ff6bab991765afb2f3eb927c83af0d97b..50168cc73cbba3d7445f0fa8a0054cceae7ca9e4 100644
--- a/test/fuzztest/services/accesstoken/verifyaccesstokenstub_fuzzer/verifyaccesstokenstub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/verifyaccesstokenstub_fuzzer/verifyaccesstokenstub_fuzzer.cpp
@@ -20,10 +20,12 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
+
using namespace std;
using namespace OHOS::Security::AccessToken;
@@ -35,8 +37,8 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
- std::string permissionName = provider.ConsumeRandomLengthString();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
diff --git a/test/fuzztest/services/accesstoken/verifyaccesstokenwithliststub_fuzzer/corpus/init b/test/fuzztest/services/accesstoken/verifyaccesstokenwithliststub_fuzzer/corpus/init
deleted file mode 100644
index e7c3fecd8d4d4816e40088113a2316bb9eb2e13f..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/accesstoken/verifyaccesstokenwithliststub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/accesstoken/verifyaccesstokenwithliststub_fuzzer/corpus/init0 b/test/fuzztest/services/accesstoken/verifyaccesstokenwithliststub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..f60f31e126bb5af7dc96e29538f2b723ca2e0e96
Binary files /dev/null and b/test/fuzztest/services/accesstoken/verifyaccesstokenwithliststub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/accesstoken/verifyaccesstokenwithliststub_fuzzer/verifyaccesstokenwithliststub_fuzzer.cpp b/test/fuzztest/services/accesstoken/verifyaccesstokenwithliststub_fuzzer/verifyaccesstokenwithliststub_fuzzer.cpp
index 0c7351ac96169c1ccd904bdfcdd3aa01f26de1cc..786a24f4b0291811230d4f4f7d064248f781c39c 100644
--- a/test/fuzztest/services/accesstoken/verifyaccesstokenwithliststub_fuzzer/verifyaccesstokenwithliststub_fuzzer.cpp
+++ b/test/fuzztest/services/accesstoken/verifyaccesstokenwithliststub_fuzzer/verifyaccesstokenwithliststub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_manager_service.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iaccess_token_manager.h"
@@ -36,12 +37,12 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenId = provider.ConsumeIntegral();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
int32_t permSize = provider.ConsumeIntegral() % MAX_PERMISSION_SIZE;
std::vector permissionList;
for (int32_t i = 0; i < permSize; i++) {
- permissionList.emplace_back(provider.ConsumeRandomLengthString());
+ permissionList.emplace_back(ConsumePermissionName(provider));
}
MessageParcel datas;
datas.WriteInterfaceToken(IAccessTokenManager::GetDescriptor());
diff --git a/test/fuzztest/services/privacy/addpermissionusedrecordasyncstub_fuzzer/addpermissionusedrecordasyncstub_fuzzer.cpp b/test/fuzztest/services/privacy/addpermissionusedrecordasyncstub_fuzzer/addpermissionusedrecordasyncstub_fuzzer.cpp
index 794b360c733cf75eaf12c279534393031f94c587..6734e9d4a3dd110a01352584087aee3ab05aa76b 100644
--- a/test/fuzztest/services/privacy/addpermissionusedrecordasyncstub_fuzzer/addpermissionusedrecordasyncstub_fuzzer.cpp
+++ b/test/fuzztest/services/privacy/addpermissionusedrecordasyncstub_fuzzer/addpermissionusedrecordasyncstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iprivacy_manager.h"
#include "privacy_manager_service.h"
@@ -40,8 +41,8 @@ namespace OHOS {
datas.WriteInterfaceToken(IPrivacyManager::GetDescriptor());
AddPermParamInfoParcel infoParcel;
- infoParcel.info.tokenId = provider.ConsumeIntegral();
- infoParcel.info.permissionName = provider.ConsumeRandomLengthString();
+ infoParcel.info.tokenId = ConsumeTokenId(provider);
+ infoParcel.info.permissionName = ConsumePermissionName(provider);
infoParcel.info.successCount = provider.ConsumeIntegral();
infoParcel.info.failCount = provider.ConsumeIntegral();
infoParcel.info.type = static_cast(provider.ConsumeIntegralInRange(
diff --git a/test/fuzztest/services/privacy/addpermissionusedrecordasyncstub_fuzzer/corpus/init b/test/fuzztest/services/privacy/addpermissionusedrecordasyncstub_fuzzer/corpus/init
deleted file mode 100644
index 65af8ee8d11bf23407ea34d4de49f7cbb6a2b791..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/privacy/addpermissionusedrecordasyncstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2025 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/privacy/addpermissionusedrecordasyncstub_fuzzer/corpus/init0 b/test/fuzztest/services/privacy/addpermissionusedrecordasyncstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..a87f2abb506114aefca1cfae678360d784cbf996
Binary files /dev/null and b/test/fuzztest/services/privacy/addpermissionusedrecordasyncstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/privacy/addpermissionusedrecordstub_fuzzer/addpermissionusedrecordstub_fuzzer.cpp b/test/fuzztest/services/privacy/addpermissionusedrecordstub_fuzzer/addpermissionusedrecordstub_fuzzer.cpp
index 42f424e14885b1f42d79a4b1f5f06cb944b2e410..6b9d0a4bed0c16b05f9af48a55f06620e6592a22 100644
--- a/test/fuzztest/services/privacy/addpermissionusedrecordstub_fuzzer/addpermissionusedrecordstub_fuzzer.cpp
+++ b/test/fuzztest/services/privacy/addpermissionusedrecordstub_fuzzer/addpermissionusedrecordstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iprivacy_manager.h"
#include "privacy_manager_service.h"
@@ -40,8 +41,8 @@ namespace OHOS {
datas.WriteInterfaceToken(IPrivacyManager::GetDescriptor());
AddPermParamInfoParcel infoParcel;
- infoParcel.info.tokenId = provider.ConsumeIntegral();
- infoParcel.info.permissionName = provider.ConsumeRandomLengthString();
+ infoParcel.info.tokenId = ConsumeTokenId(provider);
+ infoParcel.info.permissionName = ConsumePermissionName(provider);
infoParcel.info.successCount = provider.ConsumeIntegral();
infoParcel.info.failCount = provider.ConsumeIntegral();
infoParcel.info.type = static_cast(provider.ConsumeIntegralInRange(
diff --git a/test/fuzztest/services/privacy/addpermissionusedrecordstub_fuzzer/corpus/init b/test/fuzztest/services/privacy/addpermissionusedrecordstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/privacy/addpermissionusedrecordstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/privacy/addpermissionusedrecordstub_fuzzer/corpus/init0 b/test/fuzztest/services/privacy/addpermissionusedrecordstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..a87f2abb506114aefca1cfae678360d784cbf996
Binary files /dev/null and b/test/fuzztest/services/privacy/addpermissionusedrecordstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/privacy/getpermissionusedrecordsasyncstub_fuzzer/corpus/init b/test/fuzztest/services/privacy/getpermissionusedrecordsasyncstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/privacy/getpermissionusedrecordsasyncstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/privacy/getpermissionusedrecordsasyncstub_fuzzer/corpus/init0 b/test/fuzztest/services/privacy/getpermissionusedrecordsasyncstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..d6928cddb4282f690353fdb6f136e3e869f6163c
Binary files /dev/null and b/test/fuzztest/services/privacy/getpermissionusedrecordsasyncstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/privacy/getpermissionusedrecordsasyncstub_fuzzer/getpermissionusedrecordsasyncstub_fuzzer.cpp b/test/fuzztest/services/privacy/getpermissionusedrecordsasyncstub_fuzzer/getpermissionusedrecordsasyncstub_fuzzer.cpp
index 0ab6b7e1142724f5d9df6887dad8f39ac1f89f70..3a366d69aad01d13d8e44e33c02a234ee1783179 100644
--- a/test/fuzztest/services/privacy/getpermissionusedrecordsasyncstub_fuzzer/getpermissionusedrecordsasyncstub_fuzzer.cpp
+++ b/test/fuzztest/services/privacy/getpermissionusedrecordsasyncstub_fuzzer/getpermissionusedrecordsasyncstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "errors.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iprivacy_manager.h"
@@ -48,11 +49,11 @@ namespace OHOS {
FuzzedDataProvider provider(data, size);
PermissionUsedRequest request = {
- .tokenId = provider.ConsumeIntegral(),
+ .tokenId = ConsumeTokenId(provider),
.isRemote = provider.ConsumeBool(),
.deviceId = provider.ConsumeRandomLengthString(),
.bundleName = provider.ConsumeRandomLengthString(),
- .permissionList = {provider.ConsumeRandomLengthString()},
+ .permissionList = {ConsumePermissionName(provider)},
.beginTimeMillis = provider.ConsumeIntegral(),
.endTimeMillis = provider.ConsumeIntegral(),
.flag = static_cast(provider.ConsumeIntegralInRange(
diff --git a/test/fuzztest/services/privacy/getpermissionusedrecordsstub_fuzzer/corpus/init b/test/fuzztest/services/privacy/getpermissionusedrecordsstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/privacy/getpermissionusedrecordsstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/privacy/getpermissionusedrecordsstub_fuzzer/corpus/init0 b/test/fuzztest/services/privacy/getpermissionusedrecordsstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..d6928cddb4282f690353fdb6f136e3e869f6163c
Binary files /dev/null and b/test/fuzztest/services/privacy/getpermissionusedrecordsstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/privacy/getpermissionusedrecordsstub_fuzzer/getpermissionusedrecordsstub_fuzzer.cpp b/test/fuzztest/services/privacy/getpermissionusedrecordsstub_fuzzer/getpermissionusedrecordsstub_fuzzer.cpp
index cd1ac4d965cd77c5d6f72e695e6ca9e91e897b43..a7fc4cd5338d75c43434e242147ed74e677532e2 100644
--- a/test/fuzztest/services/privacy/getpermissionusedrecordsstub_fuzzer/getpermissionusedrecordsstub_fuzzer.cpp
+++ b/test/fuzztest/services/privacy/getpermissionusedrecordsstub_fuzzer/getpermissionusedrecordsstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iprivacy_manager.h"
#include "permission_used_request.h"
@@ -38,11 +39,11 @@ namespace OHOS {
FuzzedDataProvider provider(data, size);
PermissionUsedRequest request = {
- .tokenId = provider.ConsumeIntegral(),
+ .tokenId = ConsumeTokenId(provider),
.isRemote = provider.ConsumeBool(),
.deviceId = provider.ConsumeRandomLengthString(),
.bundleName = provider.ConsumeRandomLengthString(),
- .permissionList = {provider.ConsumeRandomLengthString()},
+ .permissionList = {ConsumePermissionName(provider)},
.beginTimeMillis = provider.ConsumeIntegral(),
.endTimeMillis = provider.ConsumeIntegral(),
.flag = static_cast(provider.ConsumeIntegralInRange(
diff --git a/test/fuzztest/services/privacy/getpermissionusedtypeinfosstub_fuzzer/corpus/init b/test/fuzztest/services/privacy/getpermissionusedtypeinfosstub_fuzzer/corpus/init
deleted file mode 100644
index e7c3fecd8d4d4816e40088113a2316bb9eb2e13f..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/privacy/getpermissionusedtypeinfosstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/privacy/getpermissionusedtypeinfosstub_fuzzer/corpus/init0 b/test/fuzztest/services/privacy/getpermissionusedtypeinfosstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/privacy/getpermissionusedtypeinfosstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/privacy/getpermissionusedtypeinfosstub_fuzzer/getpermissionusedtypeinfosstub_fuzzer.cpp b/test/fuzztest/services/privacy/getpermissionusedtypeinfosstub_fuzzer/getpermissionusedtypeinfosstub_fuzzer.cpp
index 6e80274e1bef35f4d52129b107497f448c5d21f3..0cc965f9f2257af584831f619225707f78d9b3cf 100644
--- a/test/fuzztest/services/privacy/getpermissionusedtypeinfosstub_fuzzer/getpermissionusedtypeinfosstub_fuzzer.cpp
+++ b/test/fuzztest/services/privacy/getpermissionusedtypeinfosstub_fuzzer/getpermissionusedtypeinfosstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iprivacy_manager.h"
#include "privacy_manager_service.h"
@@ -35,13 +36,15 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IPrivacyManager::GetDescriptor());
- if (!datas.WriteUint32(provider.ConsumeIntegral())) {
+ if (!datas.WriteUint32(tokenId)) {
return false;
}
- if (!datas.WriteString(provider.ConsumeRandomLengthString())) {
+ if (!datas.WriteString(permissionName)) {
return false;
}
diff --git a/test/fuzztest/services/privacy/isallowedusingpermissionstub_fuzzer/corpus/init b/test/fuzztest/services/privacy/isallowedusingpermissionstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/privacy/isallowedusingpermissionstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/privacy/isallowedusingpermissionstub_fuzzer/corpus/init0 b/test/fuzztest/services/privacy/isallowedusingpermissionstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/privacy/isallowedusingpermissionstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/privacy/isallowedusingpermissionstub_fuzzer/isallowedusingpermissionstub_fuzzer.cpp b/test/fuzztest/services/privacy/isallowedusingpermissionstub_fuzzer/isallowedusingpermissionstub_fuzzer.cpp
index 39a56987903b1272a380076eeaed0fcec578e005..1c8da86e8f694d390d9e6ca70e575a0799c9d0aa 100644
--- a/test/fuzztest/services/privacy/isallowedusingpermissionstub_fuzzer/isallowedusingpermissionstub_fuzzer.cpp
+++ b/test/fuzztest/services/privacy/isallowedusingpermissionstub_fuzzer/isallowedusingpermissionstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iprivacy_manager.h"
#include "privacy_manager_service.h"
@@ -35,13 +36,15 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IPrivacyManager::GetDescriptor());
- if (!datas.WriteUint32(provider.ConsumeIntegral())) {
+ if (!datas.WriteUint32(tokenId)) {
return false;
}
- if (!datas.WriteString(provider.ConsumeRandomLengthString())) {
+ if (!datas.WriteString(permissionName)) {
return false;
}
if (!datas.WriteInt32(provider.ConsumeIntegral())) {
diff --git a/test/fuzztest/services/privacy/registerpermactivestatuscallbackstub_fuzzer/registerpermactivestatuscallbackstub_fuzzer.cpp b/test/fuzztest/services/privacy/registerpermactivestatuscallbackstub_fuzzer/registerpermactivestatuscallbackstub_fuzzer.cpp
index 09ee03fb6be914cbfad9be3232121acba815e530..2d15b047fe13eaaccf86068dfa9c91d7f1ed97fe 100644
--- a/test/fuzztest/services/privacy/registerpermactivestatuscallbackstub_fuzzer/registerpermactivestatuscallbackstub_fuzzer.cpp
+++ b/test/fuzztest/services/privacy/registerpermactivestatuscallbackstub_fuzzer/registerpermactivestatuscallbackstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iprivacy_manager.h"
#include "perm_active_status_change_callback.h"
@@ -56,7 +57,7 @@ namespace OHOS {
FuzzedDataProvider provider(data, size);
- std::vector permList = {provider.ConsumeRandomLengthString()};
+ std::vector permList = {ConsumePermissionName(provider)};
auto callback = std::make_shared(permList);
callback->type_ = PERM_INACTIVE;
sptr callbackWrap = nullptr;
diff --git a/test/fuzztest/services/privacy/removepermissionusedrecordsstub_fuzzer/corpus/init b/test/fuzztest/services/privacy/removepermissionusedrecordsstub_fuzzer/corpus/init
deleted file mode 100644
index e4ceac1bcd4e3b3427eb63cea0c28304064333cc..0000000000000000000000000000000000000000
--- a/test/fuzztest/services/privacy/removepermissionusedrecordsstub_fuzzer/corpus/init
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2023 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.
-
-FUZZ
\ No newline at end of file
diff --git a/test/fuzztest/services/privacy/removepermissionusedrecordsstub_fuzzer/corpus/init0 b/test/fuzztest/services/privacy/removepermissionusedrecordsstub_fuzzer/corpus/init0
new file mode 100644
index 0000000000000000000000000000000000000000..7c1b44fdbf9c63cea76689b90ebd0e964c18ef27
Binary files /dev/null and b/test/fuzztest/services/privacy/removepermissionusedrecordsstub_fuzzer/corpus/init0 differ
diff --git a/test/fuzztest/services/privacy/removepermissionusedrecordsstub_fuzzer/removepermissionusedrecordsstub_fuzzer.cpp b/test/fuzztest/services/privacy/removepermissionusedrecordsstub_fuzzer/removepermissionusedrecordsstub_fuzzer.cpp
index 2eb66bfbba5cbe5f5d368aedd2799ff6408bd0db..3fbc72500bf312ae9fc00241d2f047c3ca75e40a 100644
--- a/test/fuzztest/services/privacy/removepermissionusedrecordsstub_fuzzer/removepermissionusedrecordsstub_fuzzer.cpp
+++ b/test/fuzztest/services/privacy/removepermissionusedrecordsstub_fuzzer/removepermissionusedrecordsstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iprivacy_manager.h"
#include "privacy_manager_service.h"
@@ -35,13 +36,15 @@ namespace OHOS {
}
FuzzedDataProvider provider(data, size);
+ AccessTokenID tokenId = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
MessageParcel datas;
datas.WriteInterfaceToken(IPrivacyManager::GetDescriptor());
- if (!datas.WriteUint32(provider.ConsumeIntegral())) {
+ if (!datas.WriteUint32(tokenId)) {
return false;
}
- if (!datas.WriteString(provider.ConsumeRandomLengthString())) {
+ if (!datas.WriteString(permissionName)) {
return false;
}
diff --git a/test/fuzztest/services/privacy/sethapwithfgreminderstub_fuzzer/sethapwithfgreminderstub_fuzzer.cpp b/test/fuzztest/services/privacy/sethapwithfgreminderstub_fuzzer/sethapwithfgreminderstub_fuzzer.cpp
index e984d91926e049c85b7e7dec2f2cec37eb5ca8e4..da3724fafc4ed6a24668134ff72d1483406d777e 100644
--- a/test/fuzztest/services/privacy/sethapwithfgreminderstub_fuzzer/sethapwithfgreminderstub_fuzzer.cpp
+++ b/test/fuzztest/services/privacy/sethapwithfgreminderstub_fuzzer/sethapwithfgreminderstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "accesstoken_kit.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iprivacy_manager.h"
@@ -70,7 +71,7 @@ namespace OHOS {
GetNativeToken();
if (size > sizeof(uint32_t) + sizeof(bool)) {
- AccessTokenID tokenId = provider.ConsumeIntegral();
+ AccessTokenID tokenId = ConsumeTokenId(provider);
bool isAllowed = provider.ConsumeBool();
MessageParcel datas;
diff --git a/test/fuzztest/services/privacy/setmutepolicystub_fuzzer/setmutepolicystub_fuzzer.cpp b/test/fuzztest/services/privacy/setmutepolicystub_fuzzer/setmutepolicystub_fuzzer.cpp
index b49e02e09241cc34d47d36a0a8cb1ee453eb45b5..77f3f71a8306f24184fb07f33260472b3c0018a8 100644
--- a/test/fuzztest/services/privacy/setmutepolicystub_fuzzer/setmutepolicystub_fuzzer.cpp
+++ b/test/fuzztest/services/privacy/setmutepolicystub_fuzzer/setmutepolicystub_fuzzer.cpp
@@ -31,6 +31,8 @@ using namespace std;
using namespace OHOS::Security::AccessToken;
const int CONSTANTS_NUMBER_TWO = 2;
static const int32_t ROOT_UID = 0;
+static const uint32_t ACTIVE_CHANGE_CHANGE_TYPE_MAX = 4;
+static const uint32_t CALLER_TYPE_MAX = 2;
namespace OHOS {
const uint8_t* g_baseFuzzData = nullptr;
@@ -73,8 +75,8 @@ size_t g_baseFuzzPos = 0;
GetNativeToken();
if (size > sizeof(uint32_t) + sizeof(bool) + sizeof(uint32_t)) {
- uint32_t policyType = provider.ConsumeIntegral();
- uint32_t callerType = provider.ConsumeIntegral();
+ uint32_t policyType = provider.ConsumeIntegralInRange(0, ACTIVE_CHANGE_CHANGE_TYPE_MAX);
+ uint32_t callerType = provider.ConsumeIntegralInRange(0, CALLER_TYPE_MAX);
bool isMute = provider.ConsumeBool();
uint32_t tokenID = provider.ConsumeIntegral();
diff --git a/test/fuzztest/services/privacy/startusingpermissioncallbackstub_fuzzer/startusingpermissioncallbackstub_fuzzer.cpp b/test/fuzztest/services/privacy/startusingpermissioncallbackstub_fuzzer/startusingpermissioncallbackstub_fuzzer.cpp
index e123996b9fa1b0f9fa5abd3a6023f347415af6f9..e390a6e2fb735bdba35f795d12135bb67f608fbd 100644
--- a/test/fuzztest/services/privacy/startusingpermissioncallbackstub_fuzzer/startusingpermissioncallbackstub_fuzzer.cpp
+++ b/test/fuzztest/services/privacy/startusingpermissioncallbackstub_fuzzer/startusingpermissioncallbackstub_fuzzer.cpp
@@ -15,6 +15,7 @@
#include "startusingpermissioncallbackstub_fuzzer.h"
+#include "accesstoken_fuzzdata.h"
#include "constant.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iprivacy_manager.h"
@@ -113,7 +114,7 @@ bool StartUsingPermissionCallbackStubFuzzTest(const uint8_t* data, size_t size)
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenID = provider.ConsumeIntegral();
+ AccessTokenID tokenID = ConsumeTokenId(provider);
int32_t pid = provider.ConsumeIntegral();
std::string permissionName;
int32_t opCode = provider.ConsumeIntegral() % g_permSize;
diff --git a/test/fuzztest/services/privacy/startusingpermissionstub_fuzzer/startusingpermissionstub_fuzzer.cpp b/test/fuzztest/services/privacy/startusingpermissionstub_fuzzer/startusingpermissionstub_fuzzer.cpp
index 658295ce4efab9278d0e2e3876af638503550496..e52e7b19149074f10e24ba7b840c0dcca9134904 100644
--- a/test/fuzztest/services/privacy/startusingpermissionstub_fuzzer/startusingpermissionstub_fuzzer.cpp
+++ b/test/fuzztest/services/privacy/startusingpermissionstub_fuzzer/startusingpermissionstub_fuzzer.cpp
@@ -15,6 +15,7 @@
#include "startusingpermissionstub_fuzzer.h"
+#include "accesstoken_fuzzdata.h"
#include "constant.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iprivacy_manager.h"
@@ -83,7 +84,7 @@ bool StartUsingPermissionStubFuzzTest(const uint8_t* data, size_t size)
}
FuzzedDataProvider provider(data, size);
- AccessTokenID tokenID = provider.ConsumeIntegral();
+ AccessTokenID tokenID = ConsumeTokenId(provider);
int32_t pid = provider.ConsumeIntegral();
std::string permissionName;
int32_t opCode = provider.ConsumeIntegral() % g_permSize;
diff --git a/test/fuzztest/services/privacy/stopusingpermissionstub_fuzzer/stopusingpermissionstub_fuzzer.cpp b/test/fuzztest/services/privacy/stopusingpermissionstub_fuzzer/stopusingpermissionstub_fuzzer.cpp
index 7967d5252964fee9a5965c981cd2b3065a73fbcd..3996e052de75fea5a2bb1ee101f600ecd5bd3bd8 100644
--- a/test/fuzztest/services/privacy/stopusingpermissionstub_fuzzer/stopusingpermissionstub_fuzzer.cpp
+++ b/test/fuzztest/services/privacy/stopusingpermissionstub_fuzzer/stopusingpermissionstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iprivacy_manager.h"
#include "privacy_manager_service.h"
@@ -37,11 +38,13 @@ namespace OHOS {
FuzzedDataProvider provider(data, size);
MessageParcel datas;
+ AccessTokenID tokenID = ConsumeTokenId(provider);
+ std::string permissionName = ConsumePermissionName(provider);
datas.WriteInterfaceToken(IPrivacyManager::GetDescriptor());
- if (!datas.WriteUint32(provider.ConsumeIntegral())) {
+ if (!datas.WriteUint32(tokenID)) {
return false;
}
- if (!datas.WriteString(provider.ConsumeRandomLengthString())) {
+ if (!datas.WriteString(permissionName)) {
return false;
}
if (!datas.WriteInt32(provider.ConsumeIntegral())) {
diff --git a/test/fuzztest/services/privacy/unregisterpermactivestatuscallbackstub_fuzzer/unregisterpermactivestatuscallbackstub_fuzzer.cpp b/test/fuzztest/services/privacy/unregisterpermactivestatuscallbackstub_fuzzer/unregisterpermactivestatuscallbackstub_fuzzer.cpp
index a86e9062d8785290bcd480e47232e72b06ab0382..098c2fa41d045e16117c9565b65c4832fcde5ff4 100644
--- a/test/fuzztest/services/privacy/unregisterpermactivestatuscallbackstub_fuzzer/unregisterpermactivestatuscallbackstub_fuzzer.cpp
+++ b/test/fuzztest/services/privacy/unregisterpermactivestatuscallbackstub_fuzzer/unregisterpermactivestatuscallbackstub_fuzzer.cpp
@@ -20,6 +20,7 @@
#include
#undef private
+#include "accesstoken_fuzzdata.h"
#include "fuzzer/FuzzedDataProvider.h"
#include "iprivacy_manager.h"
#include "perm_active_status_change_callback.h"
@@ -59,7 +60,7 @@ namespace OHOS {
MessageParcel datas;
datas.WriteInterfaceToken(IPrivacyManager::GetDescriptor());
- std::vector permList = {provider.ConsumeRandomLengthString()};
+ std::vector permList = {ConsumePermissionName(provider)};
auto callback = std::make_shared(permList);
callback->type_ = PERM_INACTIVE;