mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 18:20:04 +00:00
Signed-off-by: xuqinghuo <xuqinghuo@h-partners.com>
issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I8NR8H
This commit is contained in:
parent
38bc010c2a
commit
55c9c63900
@ -19,6 +19,7 @@ group("fuzztest") {
|
||||
"arraybufferrefnew_fuzzer:fuzztest",
|
||||
"arraybufferrefnewwithtwoparameters_fuzzer:fuzztest",
|
||||
"arraylist_fuzzer:fuzztest",
|
||||
"arrayref_fuzzer:fuzztest",
|
||||
"bigint64arrayrefnew_fuzzer:fuzztest",
|
||||
"bigintrefgetwordsarraysize_fuzzer:fuzztest",
|
||||
"bigintrefnew_fuzzer:fuzztest",
|
||||
@ -199,14 +200,17 @@ group("fuzztest") {
|
||||
"createbigwords_fuzzer:fuzztest",
|
||||
"dataviewrefnew_fuzzer:fuzztest",
|
||||
"daterefnew_fuzzer:fuzztest",
|
||||
"deleteworker_fuzzer:fuzztest",
|
||||
"dumpheapsnapshot1_fuzzer:fuzztest",
|
||||
"dumpheapsnapshot2_fuzzer:fuzztest",
|
||||
"dumpheapsnapshot3_fuzzer:fuzztest",
|
||||
"exceptionaggregateerror_fuzzer:fuzztest",
|
||||
"exceptionclass_fuzzer:fuzztest",
|
||||
"exceptionevalerror_fuzzer:fuzztest",
|
||||
"exceptionoomerror_fuzzer:fuzztest",
|
||||
"exceptiontypeerror_fuzzer:fuzztest",
|
||||
"execute_fuzzer:fuzztest",
|
||||
"executionscope_fuzzer:fuzztest",
|
||||
"float32arrayrefnew_fuzzer:fuzztest",
|
||||
"float64arrayrefnew_fuzzer:fuzztest",
|
||||
"functionrefcall_fuzzer:fuzztest",
|
||||
@ -214,12 +218,16 @@ group("fuzztest") {
|
||||
"functionrefnew_fuzzer:fuzztest",
|
||||
"functionrefnewclassfunction_fuzzer:fuzztest",
|
||||
"getallocationprofile_fuzzer:fuzztest",
|
||||
"getassetpath_fuzzer:fuzztest",
|
||||
"getbundlename_fuzzer:fuzztest",
|
||||
"getmodulename_fuzzer:fuzztest",
|
||||
"getnativepointerfield_fuzzer:fuzztest",
|
||||
"getwordsarray_fuzzer:fuzztest",
|
||||
"int16arrayrefnew_fuzzer:fuzztest",
|
||||
"int32arrayrefnew_fuzzer:fuzztest",
|
||||
"int8arrayrefnew_fuzzer:fuzztest",
|
||||
"integerrefnewvalue_fuzzer:fuzztest",
|
||||
"isquickfixcausedexception_fuzzer:fuzztest",
|
||||
"jsnapideleteserializationdata_fuzzer:fuzztest",
|
||||
"jsnapideserializevalue_fuzzer:fuzztest",
|
||||
"jsnapiexception_fuzzer:fuzztest",
|
||||
@ -238,6 +246,7 @@ group("fuzztest") {
|
||||
"jsnapistartdebugger_fuzzer:fuzztest",
|
||||
"jsnapiuncaughtclearexception_fuzzer:fuzztest",
|
||||
"jsnapiuncaughtexception_fuzzer:fuzztest",
|
||||
"jsnapiunloadpatch_fuzzer:fuzztest",
|
||||
"jsnapivalue_fuzzer:fuzztest",
|
||||
"jsonparse_fuzzer:fuzztest",
|
||||
"jsonstringify_fuzzer:fuzztest",
|
||||
@ -263,11 +272,14 @@ group("fuzztest") {
|
||||
"jsvaluerefispromisevalue_fuzzer:fuzztest",
|
||||
"jsvaluerefissharedarraybuffer_fuzzer:fuzztest",
|
||||
"jsvaluerefnullvalue_fuzzer:fuzztest",
|
||||
"jsvaluerefobject_fuzzer:fuzztest",
|
||||
"jsvaluereftobigint_fuzzer:fuzztest",
|
||||
"jsvaluereftobooleanvalue_fuzzer:fuzztest",
|
||||
"jsvaluereftonumbervalue_fuzzer:fuzztest",
|
||||
"jsvaluereftoobjectvalue_fuzzer:fuzztest",
|
||||
"jsvaluerefuint32value_fuzzer:fuzztest",
|
||||
"loadpatch_fuzzer:fuzztest",
|
||||
"loadpatchlong_fuzzer:fuzztest",
|
||||
"mapiteratorefget_fuzzer:fuzztest",
|
||||
"maprefgetsetkeyvaluesize_fuzzer:fuzztest",
|
||||
"nativepointernew1_fuzzer:fuzztest",
|
||||
@ -284,6 +296,7 @@ group("fuzztest") {
|
||||
"objectdelete_fuzzer:fuzztest",
|
||||
"objectget_fuzzer:fuzztest",
|
||||
"objecthas_fuzzer:fuzztest",
|
||||
"objectref_fuzzer:fuzztest",
|
||||
"objectrefall_fuzzer:fuzztest",
|
||||
"objectrefdelete_fuzzer:fuzztest",
|
||||
"objectrefgetglobalobject_fuzzer:fuzztest",
|
||||
@ -291,12 +304,17 @@ group("fuzztest") {
|
||||
"objectrefsetprototype_fuzzer:fuzztest",
|
||||
"objectset_fuzzer:fuzztest",
|
||||
"primitiverefgetvalue_fuzzer:fuzztest",
|
||||
"promisecapabilityref_fuzzer:fuzztest",
|
||||
"promiseref_fuzzer:fuzztest",
|
||||
"promiserejectinfo_fuzzer:fuzztest",
|
||||
"propertyattribute_fuzzer:fuzztest",
|
||||
"publicapilocal_fuzzer:fuzztest",
|
||||
"publicapilocalregexpref_fuzzer:fuzztest",
|
||||
"registerquickfixqueryfunc_fuzzer:fuzztest",
|
||||
"setbundlename_fuzzer:fuzztest",
|
||||
"setcpusamplinginterval_fuzzer:fuzztest",
|
||||
"setiteratorrefget_fuzzer:fuzztest",
|
||||
"setmodulename_fuzzer:fuzztest",
|
||||
"setnativepointerfield_fuzzer:fuzztest",
|
||||
"setnativepointerfieldcount_fuzzer:fuzztest",
|
||||
"snapshotserializebuiltins_fuzzer:fuzztest",
|
||||
@ -308,8 +326,17 @@ group("fuzztest") {
|
||||
"stopsampling_fuzzer:fuzztest",
|
||||
"stringrefcast_fuzzer:fuzztest",
|
||||
"stringrefgetnapiwrapperstring_fuzzer:fuzztest",
|
||||
"stringreflength_fuzzer:fuzztest",
|
||||
"stringrefnewfromutf16_fuzzer:fuzztest",
|
||||
"stringrefnewfromutf8_fuzzer:fuzztest",
|
||||
"stringrefutf8length_fuzzer:fuzztest",
|
||||
"stringrefwritelatin1_fuzzer:fuzztest",
|
||||
"stringrefwriteutf16_fuzzer:fuzztest",
|
||||
"symbolnew_fuzzer:fuzztest",
|
||||
"templateclassglobal_fuzzer:fuzztest",
|
||||
"tonativepointer_fuzzer:fuzztest",
|
||||
"trycatch_fuzzer:fuzztest",
|
||||
"typedarrayref_fuzzer:fuzztest",
|
||||
"uint16arrayrefnew_fuzzer:fuzztest",
|
||||
"uint32arrayrefnew_fuzzer:fuzztest",
|
||||
"uint8arrayrefnew_fuzzer:fuzztest",
|
||||
|
44
test/fuzztest/arrayref_fuzzer/BUILD.gn
Normal file
44
test/fuzztest/arrayref_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,44 @@
|
||||
# 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.
|
||||
|
||||
#####################################hydra-fuzz###############################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
####################################fuzztest##################################
|
||||
ohos_fuzztest("ArrayRefFuzzerTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/arrayref_fuzzer"
|
||||
|
||||
sources = [ "arrayref_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":ArrayRefFuzzerTest" ]
|
||||
}
|
93
test/fuzztest/arrayref_fuzzer/arrayref_fuzzer.cpp
Normal file
93
test/fuzztest/arrayref_fuzzer/arrayref_fuzzer.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "arrayref_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
void ArrayRefNewFuzzerTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
ArrayRef::New(vm, (uint32_t)size);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void ArrayRefGetValueAtFuzzerTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
Local<ObjectRef> globalObject = JSNApi::GetGlobalObject(vm);
|
||||
Local<ArrayRef> property = ArrayRef::New(vm, (uint32_t)size);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
[[maybe_unused]]Local<JSValueRef> value = property->GetValueAt(vm, globalObject, (uint32_t)size);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void ArrayRefLengthFuzzerTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<ArrayRef> property = ArrayRef::New(vm, (uint32_t)size);
|
||||
property->Length(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void ArrayRefSetValueAtFuzzerTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<ObjectRef> globalObject = JSNApi::GetGlobalObject(vm);
|
||||
Local<ArrayRef> property = ArrayRef::New(vm, (uint32_t)size);
|
||||
Local<JSValueRef> value = ObjectRef::New(vm);
|
||||
[[maybe_unused]]bool result = property->SetValueAt(vm, globalObject, (uint32_t)size, value);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::ArrayRefNewFuzzerTest(data, size);
|
||||
OHOS::ArrayRefGetValueAtFuzzerTest(data, size);
|
||||
OHOS::ArrayRefLengthFuzzerTest(data, size);
|
||||
OHOS::ArrayRefSetValueAtFuzzerTest(data, size);
|
||||
return 0;
|
||||
}
|
21
test/fuzztest/arrayref_fuzzer/arrayref_fuzzer.h
Normal file
21
test/fuzztest/arrayref_fuzzer/arrayref_fuzzer.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef ARRAYREF_FUZZER_H
|
||||
#define ARRAYREF_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "arrayref_fuzzer.h"
|
||||
|
||||
#endif
|
14
test/fuzztest/arrayref_fuzzer/corpus/init
Normal file
14
test/fuzztest/arrayref_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
25
test/fuzztest/arrayref_fuzzer/project.xml
Normal file
25
test/fuzztest/arrayref_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
46
test/fuzztest/deleteworker_fuzzer/BUILD.gn
Normal file
46
test/fuzztest/deleteworker_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,46 @@
|
||||
# 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.
|
||||
|
||||
##################################hydra-fuzz###################################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
##################################fuzztest#####################################
|
||||
ohos_fuzztest("DeleteWorkerFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/deleteworker_fuzzer"
|
||||
|
||||
resource_config_file = "$js_root/test/resource/js_runtime/ohos_test.xml"
|
||||
|
||||
sources = [ "deleteworker_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime_test",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":DeleteWorkerFuzzTest" ]
|
||||
}
|
14
test/fuzztest/deleteworker_fuzzer/corpus/init
Normal file
14
test/fuzztest/deleteworker_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
46
test/fuzztest/deleteworker_fuzzer/deleteworker_fuzzer.cpp
Normal file
46
test/fuzztest/deleteworker_fuzzer/deleteworker_fuzzer.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "deleteworker_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/base/utf_helper.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
using namespace panda::ecmascript::base::utf_helper;
|
||||
|
||||
namespace OHOS {
|
||||
void DeleteWorkerFuzzTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
JSNApi::DeleteWorker(vm, nullptr);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::DeleteWorkerFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
21
test/fuzztest/deleteworker_fuzzer/deleteworker_fuzzer.h
Normal file
21
test/fuzztest/deleteworker_fuzzer/deleteworker_fuzzer.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef DELETEWORKER_FUZZER_H
|
||||
#define DELETEWORKER_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "deleteworker_fuzzer.h"
|
||||
|
||||
#endif
|
25
test/fuzztest/deleteworker_fuzzer/project.xml
Normal file
25
test/fuzztest/deleteworker_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
46
test/fuzztest/exceptionclass_fuzzer/BUILD.gn
Normal file
46
test/fuzztest/exceptionclass_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,46 @@
|
||||
# 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.
|
||||
|
||||
##################################hydra-fuzz###################################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
##################################fuzztest#####################################
|
||||
ohos_fuzztest("ExpectionClassFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/exceptionclass_fuzzer"
|
||||
|
||||
resource_config_file = "$js_root/test/resource/js_runtime/ohos_test.xml"
|
||||
|
||||
sources = [ "exceptionclass_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime_test",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":ExpectionClassFuzzTest" ]
|
||||
}
|
14
test/fuzztest/exceptionclass_fuzzer/corpus/init
Normal file
14
test/fuzztest/exceptionclass_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "exceptionclass_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/base/utf_helper.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
using namespace panda::ecmascript::base::utf_helper;
|
||||
|
||||
namespace OHOS {
|
||||
void ExpectionErrorFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<StringRef> message = StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
[[maybe_unused]]Local<JSValueRef> error = Exception::Error(vm, message);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void ExpectionRangeErrorFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<StringRef> message = StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
[[maybe_unused]]Local<JSValueRef> error = Exception::RangeError(vm, message);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void ReferenceErrorFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<StringRef> message = StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
[[maybe_unused]]Local<JSValueRef> error = Exception::ReferenceError(vm, message);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void SYNTexErrorFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<StringRef> message = StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
[[maybe_unused]]Local<JSValueRef> error = Exception::SyntaxError(vm, message);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::ExpectionErrorFuzzTest(data, size);
|
||||
OHOS::ExpectionRangeErrorFuzzTest(data, size);
|
||||
OHOS::ReferenceErrorFuzzTest(data, size);
|
||||
OHOS::SYNTexErrorFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
21
test/fuzztest/exceptionclass_fuzzer/exceptionclass_fuzzer.h
Normal file
21
test/fuzztest/exceptionclass_fuzzer/exceptionclass_fuzzer.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef EXCEPTIONCLASS_FUZZER_H
|
||||
#define EXCEPTIONCLASS_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "exceptionclass_fuzzer.h"
|
||||
|
||||
#endif
|
25
test/fuzztest/exceptionclass_fuzzer/project.xml
Normal file
25
test/fuzztest/exceptionclass_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
44
test/fuzztest/executionscope_fuzzer/BUILD.gn
Normal file
44
test/fuzztest/executionscope_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,44 @@
|
||||
# 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.
|
||||
|
||||
############################hydra-fuzz##############################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
############################fuzztest################################
|
||||
ohos_fuzztest("ExecutionScopeFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/executionscope_fuzzer"
|
||||
|
||||
sources = [ "executionscope_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":ExecutionScopeFuzzTest" ]
|
||||
}
|
14
test/fuzztest/executionscope_fuzzer/corpus/init
Normal file
14
test/fuzztest/executionscope_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "executionscope_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/base/utf_helper.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
namespace OHOS {
|
||||
void ExecutionScopeFuzzTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetGcType(RuntimeOption::GC_TYPE::GEN_GC);
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
auto vm = JSNApi::CreateJSVM(option);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
JSExecutionScope jsexecutionScope(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::ExecutionScopeFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
21
test/fuzztest/executionscope_fuzzer/executionscope_fuzzer.h
Normal file
21
test/fuzztest/executionscope_fuzzer/executionscope_fuzzer.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef EXECUTIONSCOPE_FUZZER_H
|
||||
#define EXECUTIONSCOPE_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "executionscope_fuzzer"
|
||||
|
||||
#endif
|
25
test/fuzztest/executionscope_fuzzer/project.xml
Normal file
25
test/fuzztest/executionscope_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
44
test/fuzztest/getassetpath_fuzzer/BUILD.gn
Normal file
44
test/fuzztest/getassetpath_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,44 @@
|
||||
# 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.
|
||||
|
||||
#####################################hydra-fuzz###############################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
####################################fuzztest##################################
|
||||
ohos_fuzztest("GetAssetPathFuzzerTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/getassetpath_fuzzer"
|
||||
|
||||
sources = [ "getassetpath_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":GetAssetPathFuzzerTest" ]
|
||||
}
|
14
test/fuzztest/getassetpath_fuzzer/corpus/init
Normal file
14
test/fuzztest/getassetpath_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
46
test/fuzztest/getassetpath_fuzzer/getassetpath_fuzzer.cpp
Normal file
46
test/fuzztest/getassetpath_fuzzer/getassetpath_fuzzer.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "getassetpath_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
void GetAssetPathFuzzerTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
JSNApi::SetAssetPath(vm, (char*)data);
|
||||
[[maybe_unused]]std::string res = JSNApi::GetAssetPath(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::GetAssetPathFuzzerTest(data, size);
|
||||
return 0;
|
||||
}
|
21
test/fuzztest/getassetpath_fuzzer/getassetpath_fuzzer.h
Normal file
21
test/fuzztest/getassetpath_fuzzer/getassetpath_fuzzer.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef GETASSETPATH_FUZZER_H
|
||||
#define GETASSETPATH_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "getassetpath_fuzzer.h"
|
||||
|
||||
#endif
|
25
test/fuzztest/getassetpath_fuzzer/project.xml
Normal file
25
test/fuzztest/getassetpath_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
44
test/fuzztest/getbundlename_fuzzer/BUILD.gn
Normal file
44
test/fuzztest/getbundlename_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,44 @@
|
||||
# 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.
|
||||
|
||||
#####################################hydra-fuzz###############################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
####################################fuzztest##################################
|
||||
ohos_fuzztest("GetBundleNameFuzzerTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/getbundlename_fuzzer"
|
||||
|
||||
sources = [ "getbundlename_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":GetBundleNameFuzzerTest" ]
|
||||
}
|
14
test/fuzztest/getbundlename_fuzzer/corpus/init
Normal file
14
test/fuzztest/getbundlename_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
46
test/fuzztest/getbundlename_fuzzer/getbundlename_fuzzer.cpp
Normal file
46
test/fuzztest/getbundlename_fuzzer/getbundlename_fuzzer.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "getbundlename_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
void GetBundleNameFuzzerTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
JSNApi::SetBundleName(vm, (char*)data);
|
||||
[[maybe_unused]]std::string res = JSNApi::GetBundleName(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::GetBundleNameFuzzerTest(data, size);
|
||||
return 0;
|
||||
}
|
21
test/fuzztest/getbundlename_fuzzer/getbundlename_fuzzer.h
Normal file
21
test/fuzztest/getbundlename_fuzzer/getbundlename_fuzzer.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef GETBUNDLENAME_FUZZER_H
|
||||
#define GETBUNDLENAME_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "getbundlename_fuzzer.h"
|
||||
|
||||
#endif
|
25
test/fuzztest/getbundlename_fuzzer/project.xml
Normal file
25
test/fuzztest/getbundlename_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
44
test/fuzztest/getmodulename_fuzzer/BUILD.gn
Normal file
44
test/fuzztest/getmodulename_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,44 @@
|
||||
# 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.
|
||||
|
||||
#####################################hydra-fuzz###############################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
####################################fuzztest##################################
|
||||
ohos_fuzztest("GetModuleNameFuzzerTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/getmodulename_fuzzer"
|
||||
|
||||
sources = [ "getmodulename_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":GetModuleNameFuzzerTest" ]
|
||||
}
|
14
test/fuzztest/getmodulename_fuzzer/corpus/init
Normal file
14
test/fuzztest/getmodulename_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
46
test/fuzztest/getmodulename_fuzzer/getmodulename_fuzzer.cpp
Normal file
46
test/fuzztest/getmodulename_fuzzer/getmodulename_fuzzer.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "getmodulename_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
void GetModuleNameFuzzerTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
JSNApi::SetModuleName(vm, (char*)data);
|
||||
[[maybe_unused]]std::string res = JSNApi::GetModuleName(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::GetModuleNameFuzzerTest(data, size);
|
||||
return 0;
|
||||
}
|
21
test/fuzztest/getmodulename_fuzzer/getmodulename_fuzzer.h
Normal file
21
test/fuzztest/getmodulename_fuzzer/getmodulename_fuzzer.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef GETMODULENAME_FUZZER_H
|
||||
#define GETMODULENAME_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "getmodulename_fuzzer.h"
|
||||
|
||||
#endif
|
25
test/fuzztest/getmodulename_fuzzer/project.xml
Normal file
25
test/fuzztest/getmodulename_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
44
test/fuzztest/isquickfixcausedexception_fuzzer/BUILD.gn
Normal file
44
test/fuzztest/isquickfixcausedexception_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,44 @@
|
||||
# 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.
|
||||
|
||||
#####################################hydra-fuzz###############################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
####################################fuzztest##################################
|
||||
ohos_fuzztest("IsQuickFixCausedExceptionFuzzerTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/isquickfixcausedexception_fuzzer"
|
||||
|
||||
sources = [ "isquickfixcausedexception_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":IsQuickFixCausedExceptionFuzzerTest" ]
|
||||
}
|
14
test/fuzztest/isquickfixcausedexception_fuzzer/corpus/init
Normal file
14
test/fuzztest/isquickfixcausedexception_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "isquickfixcausedexception_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
void IsQuickFixCausedExceptionFuzzerTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
std::string patchFileName = "index.abc";
|
||||
Local<ObjectRef> exception = JSNApi::GetAndClearUncaughtException(vm);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
JSNApi::IsQuickFixCausedException(vm, exception, patchFileName);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::IsQuickFixCausedExceptionFuzzerTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef ISQUICKFIXCAUSEDEXCEPTION_FUZZER_H
|
||||
#define ISQUICKFIXCAUSEDEXCEPTION_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "isquickfixcausedexception_fuzzer.h"
|
||||
|
||||
#endif
|
25
test/fuzztest/isquickfixcausedexception_fuzzer/project.xml
Normal file
25
test/fuzztest/isquickfixcausedexception_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
44
test/fuzztest/jsnapiunloadpatch_fuzzer/BUILD.gn
Normal file
44
test/fuzztest/jsnapiunloadpatch_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,44 @@
|
||||
# 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.
|
||||
|
||||
#####################################hydra-fuzz###############################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
####################################fuzztest##################################
|
||||
ohos_fuzztest("JSNApiUnloadPatchTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/jsnapiunloadpatch_fuzzer"
|
||||
|
||||
sources = [ "jsnapiunloadpatch_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":JSNApiUnloadPatchTest" ]
|
||||
}
|
14
test/fuzztest/jsnapiunloadpatch_fuzzer/corpus/init
Normal file
14
test/fuzztest/jsnapiunloadpatch_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "jsnapiunloadpatch_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
void JSNApiUnloadPatchTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
std::string patchFileName = "index.abc";
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
JSNApi::UnloadPatch(vm, patchFileName);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::JSNApiUnloadPatchTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef JSNAPIUNLOADPATCH_FUZZER_H
|
||||
#define JSNAPIUNLOADPATCH_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "jsnapiunloadpatch_fuzzer.h"
|
||||
|
||||
#endif
|
25
test/fuzztest/jsnapiunloadpatch_fuzzer/project.xml
Normal file
25
test/fuzztest/jsnapiunloadpatch_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
46
test/fuzztest/jsvaluerefobject_fuzzer/BUILD.gn
Normal file
46
test/fuzztest/jsvaluerefobject_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,46 @@
|
||||
# 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.
|
||||
|
||||
##################################hydra-fuzz###################################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
##################################fuzztest#####################################
|
||||
ohos_fuzztest("JSValueRefObjectFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/jsvaluerefobject_fuzzer"
|
||||
|
||||
resource_config_file = "$js_root/test/resource/js_runtime/ohos_test.xml"
|
||||
|
||||
sources = [ "jsvaluerefobject_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime_test",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":JSValueRefObjectFuzzTest" ]
|
||||
}
|
14
test/fuzztest/jsvaluerefobject_fuzzer/corpus/init
Normal file
14
test/fuzztest/jsvaluerefobject_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
@ -0,0 +1,142 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "jsvaluerefobject_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
#include "ecmascript/napi/jsnapi_helper.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
void JSValueRefIsSymbolFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<StringRef> description = StringRef::NewFromUtf8(vm, (char*)data, size);
|
||||
Local<SymbolRef> symbol = SymbolRef::New(vm, description);
|
||||
symbol->IsSymbol();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void JSValueRefIsBigIntFuzzTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
constexpr int input = 2147483646;
|
||||
Local<IntegerRef> intValue = IntegerRef::New(vm, input);
|
||||
[[maybe_unused]]bool res = intValue->IsBigInt();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void JSValueRefIsObjectFuzzTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<JSValueRef> res = IntegerRef::New(vm, (int)size);
|
||||
[[maybe_unused]]bool result = res->IsObject();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void IsArgumentsObjectFuzzTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
ObjectFactory *factory = vm->GetFactory();
|
||||
JSHandle<JSArguments> obj = factory->NewJSArguments();
|
||||
JSHandle<JSTaggedValue> argumentTag = JSHandle<JSTaggedValue>::Cast(obj);
|
||||
JSNApiHelper::ToLocal<ObjectRef>(argumentTag)->IsArgumentsObject();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void IsJSPrimitiveBooleanFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
int length = 8;
|
||||
Local<StringRef> obj = StringRef::NewFromUtf16(vm, (char16_t*)data, length);
|
||||
obj->IsJSPrimitiveBoolean();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void IsGeneratorFunctionFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
int length = 8;
|
||||
Local<StringRef> obj = StringRef::NewFromUtf16(vm, (char16_t*)data, length);
|
||||
obj->IsGeneratorFunction();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void IsMapIteratorFuzzTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
JSRuntimeOptions option;
|
||||
EcmaVM *vm = JSNApi::CreateEcmaVM(option);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<JSValueRef> object = IntegerRef::New(vm, (int)size);
|
||||
object->IsMapIterator();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::JSValueRefIsSymbolFuzzTest(data, size);
|
||||
OHOS::JSValueRefIsBigIntFuzzTest(data, size);
|
||||
OHOS::JSValueRefIsObjectFuzzTest(data, size);
|
||||
OHOS::IsArgumentsObjectFuzzTest(data, size);
|
||||
OHOS::IsJSPrimitiveBooleanFuzzTest(data, size);
|
||||
OHOS::IsGeneratorFunctionFuzzTest(data, size);
|
||||
OHOS::IsMapIteratorFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef JSVALUEREFOBJECT_FUZZER_H
|
||||
#define JSVALUEREFOBJECT_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "jsvaluerefobject_fuzzer.h"
|
||||
|
||||
#endif
|
25
test/fuzztest/jsvaluerefobject_fuzzer/project.xml
Normal file
25
test/fuzztest/jsvaluerefobject_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
46
test/fuzztest/loadpatch_fuzzer/BUILD.gn
Normal file
46
test/fuzztest/loadpatch_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,46 @@
|
||||
# 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.
|
||||
|
||||
##################################hydra-fuzz###################################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
##################################fuzztest#####################################
|
||||
ohos_fuzztest("LoadPatchFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/loadpatch_fuzzer"
|
||||
|
||||
resource_config_file = "$js_root/test/resource/js_runtime/ohos_test.xml"
|
||||
|
||||
sources = [ "loadpatch_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime_test",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":LoadPatchFuzzTest" ]
|
||||
}
|
14
test/fuzztest/loadpatch_fuzzer/corpus/init
Normal file
14
test/fuzztest/loadpatch_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
47
test/fuzztest/loadpatch_fuzzer/loadpatch_fuzzer.cpp
Normal file
47
test/fuzztest/loadpatch_fuzzer/loadpatch_fuzzer.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "loadpatch_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
void LoadPatchFuzzTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
std::string baseFileName = "index.abc";
|
||||
std::string patchFileName = "index.abc";
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
JSNApi::LoadPatch(vm, patchFileName, baseFileName);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::LoadPatchFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
21
test/fuzztest/loadpatch_fuzzer/loadpatch_fuzzer.h
Normal file
21
test/fuzztest/loadpatch_fuzzer/loadpatch_fuzzer.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef LOADPATCH_FUZZER_H
|
||||
#define LOADPATCH_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "loadpatch_fuzzer.h"
|
||||
|
||||
#endif
|
25
test/fuzztest/loadpatch_fuzzer/project.xml
Normal file
25
test/fuzztest/loadpatch_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
46
test/fuzztest/loadpatchlong_fuzzer/BUILD.gn
Normal file
46
test/fuzztest/loadpatchlong_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,46 @@
|
||||
# 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.
|
||||
|
||||
##################################hydra-fuzz###################################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
##################################fuzztest#####################################
|
||||
ohos_fuzztest("LoadPatchLongFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/loadpatchlong_fuzzer"
|
||||
|
||||
resource_config_file = "$js_root/test/resource/js_runtime/ohos_test.xml"
|
||||
|
||||
sources = [ "loadpatchlong_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime_test",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":LoadPatchLongFuzzTest" ]
|
||||
}
|
14
test/fuzztest/loadpatchlong_fuzzer/corpus/init
Normal file
14
test/fuzztest/loadpatchlong_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
47
test/fuzztest/loadpatchlong_fuzzer/loadpatchlong_fuzzer.cpp
Normal file
47
test/fuzztest/loadpatchlong_fuzzer/loadpatchlong_fuzzer.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "loadpatchlong_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
void LoadPatchLongFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
std::string baseFileName = "index.abc";
|
||||
std::string patchFileName = "index.abc";
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
JSNApi::LoadPatch(vm, patchFileName, (void *)data, size, baseFileName, (void *)data, size);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::LoadPatchLongFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
21
test/fuzztest/loadpatchlong_fuzzer/loadpatchlong_fuzzer.h
Normal file
21
test/fuzztest/loadpatchlong_fuzzer/loadpatchlong_fuzzer.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef LOADPATCHLONG_FUZZER_H
|
||||
#define LOADPATCHLONG_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "loadpatchlong_fuzzer.h"
|
||||
|
||||
#endif
|
25
test/fuzztest/loadpatchlong_fuzzer/project.xml
Normal file
25
test/fuzztest/loadpatchlong_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
46
test/fuzztest/objectref_fuzzer/BUILD.gn
Normal file
46
test/fuzztest/objectref_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,46 @@
|
||||
# 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.
|
||||
|
||||
##################################hydra-fuzz###################################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
##################################fuzztest#####################################
|
||||
ohos_fuzztest("ObjectRefFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/objectref_fuzzer"
|
||||
|
||||
resource_config_file = "$js_root/test/resource/js_runtime/ohos_test.xml"
|
||||
|
||||
sources = [ "objectref_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime_test",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":ObjectRefFuzzTest" ]
|
||||
}
|
14
test/fuzztest/objectref_fuzzer/corpus/init
Normal file
14
test/fuzztest/objectref_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
74
test/fuzztest/objectref_fuzzer/objectref_fuzzer.cpp
Normal file
74
test/fuzztest/objectref_fuzzer/objectref_fuzzer.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "objectref_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
using FunctionForRef = Local<JSValueRef>(*)(JsiRuntimeCallInfo*);
|
||||
namespace OHOS {
|
||||
Local<JSValueRef> FuncRefNewCallbackForTest(JsiRuntimeCallInfo* info)
|
||||
{
|
||||
LOG_ECMA(ERROR) << "runing FuncRefNewCallbackForTest";
|
||||
EscapeLocalScope scope(info->GetVM());
|
||||
return scope.Escape(ArrayRef::New(info->GetVM(), info->GetArgsNumber()));
|
||||
}
|
||||
void SetAccessorPropertyFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<JSValueRef> key = StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
FunctionForRef nativeFunc = FuncRefNewCallbackForTest;
|
||||
Local<FunctionRef> getter = FunctionRef::New(vm, nativeFunc);
|
||||
Local<FunctionRef> setter = FunctionRef::New(vm, nativeFunc);
|
||||
Local<ObjectRef> object = ObjectRef::New(vm);
|
||||
object->SetAccessorProperty(vm, key, getter, setter);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void DefinePropertyFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<ObjectRef> object = ObjectRef::New(vm);
|
||||
Local<JSValueRef> key = StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
Local<JSValueRef> value = ObjectRef::New(vm);
|
||||
PropertyAttribute attribute(value, true, true, true);
|
||||
object->DefineProperty(vm, key, attribute);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::SetAccessorPropertyFuzzTest(data, size);
|
||||
OHOS::DefinePropertyFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
21
test/fuzztest/objectref_fuzzer/objectref_fuzzer.h
Normal file
21
test/fuzztest/objectref_fuzzer/objectref_fuzzer.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef OBJECTREF_FUZZER_H
|
||||
#define OBJECTREF_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "objectref_fuzzer.h"
|
||||
|
||||
#endif
|
25
test/fuzztest/objectref_fuzzer/project.xml
Normal file
25
test/fuzztest/objectref_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
46
test/fuzztest/promisecapabilityref_fuzzer/BUILD.gn
Normal file
46
test/fuzztest/promisecapabilityref_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,46 @@
|
||||
# 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.
|
||||
|
||||
##################################hydra-fuzz###################################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
##################################fuzztest#####################################
|
||||
ohos_fuzztest("PromiseCapabilityRefFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/promisecapabilityref_fuzzer"
|
||||
|
||||
resource_config_file = "$js_root/test/resource/js_runtime/ohos_test.xml"
|
||||
|
||||
sources = [ "promisecapabilityref_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime_test",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":PromiseCapabilityRefFuzzTest" ]
|
||||
}
|
14
test/fuzztest/promisecapabilityref_fuzzer/corpus/init
Normal file
14
test/fuzztest/promisecapabilityref_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
25
test/fuzztest/promisecapabilityref_fuzzer/project.xml
Normal file
25
test/fuzztest/promisecapabilityref_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "promisecapabilityref_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
void PromiseCapabilityRefNewFuzzTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
[[maybe_unused]]Local<PromiseCapabilityRef> capability = PromiseCapabilityRef::New(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void PromiseCapabilityRefResolveFuzzTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<PromiseCapabilityRef> capability = PromiseCapabilityRef::New(vm);
|
||||
Local<StringRef> value = NumberRef::New(vm, (double)size);
|
||||
capability->Resolve(vm, value);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void PromiseCapabilityRefRejectFuzzTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<PromiseCapabilityRef> capability = PromiseCapabilityRef::New(vm);
|
||||
Local<StringRef> value = NumberRef::New(vm, (double)size);
|
||||
capability->Resolve(vm, value);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::PromiseCapabilityRefNewFuzzTest(data, size);
|
||||
OHOS::PromiseCapabilityRefResolveFuzzTest(data, size);
|
||||
OHOS::PromiseCapabilityRefRejectFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef PROMISECAPABILITYREF_FUZZER_H
|
||||
#define PROMISECAPABILITYREF_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "promisecapabilityref_fuzzer.h"
|
||||
|
||||
#endif
|
46
test/fuzztest/promiserejectinfo_fuzzer/BUILD.gn
Normal file
46
test/fuzztest/promiserejectinfo_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,46 @@
|
||||
# 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.
|
||||
|
||||
##################################hydra-fuzz###################################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
##################################fuzztest#####################################
|
||||
ohos_fuzztest("PromiseRejectInfoFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/promiserejectinfo_fuzzer"
|
||||
|
||||
resource_config_file = "$js_root/test/resource/js_runtime/ohos_test.xml"
|
||||
|
||||
sources = [ "promiserejectinfo_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime_test",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":PromiseRejectInfoFuzzTest" ]
|
||||
}
|
14
test/fuzztest/promiserejectinfo_fuzzer/corpus/init
Normal file
14
test/fuzztest/promiserejectinfo_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
25
test/fuzztest/promiserejectinfo_fuzzer/project.xml
Normal file
25
test/fuzztest/promiserejectinfo_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "promiserejectinfo_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/base/utf_helper.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
using namespace panda::ecmascript::base::utf_helper;
|
||||
|
||||
namespace OHOS {
|
||||
void PromiseRejectInfoNewFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<StringRef> promiseStirng = StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
Local<JSValueRef> promise(promiseStirng);
|
||||
Local<StringRef> reasonString = StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
Local<JSValueRef> reason(reasonString);
|
||||
void *data2 = static_cast<void*>(new std::string("test"));
|
||||
[[maybe_unused]]PromiseRejectInfo promiseReject(promise, reason,
|
||||
PromiseRejectInfo::PROMISE_REJECTION_EVENT::REJECT, data2);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void GetPromiseFuzzTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<PromiseCapabilityRef> capability = PromiseCapabilityRef::New(vm);
|
||||
[[maybe_unused]]Local<PromiseRef> promise = capability->GetPromise(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void GetDataFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<StringRef> promiseStirng = StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
Local<JSValueRef> promise(promiseStirng);
|
||||
Local<StringRef> reasonString = StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
Local<JSValueRef> reason(reasonString);
|
||||
PromiseRejectInfo promiseReject(promise, reason,
|
||||
PromiseRejectInfo::PROMISE_REJECTION_EVENT::REJECT, (void*)data);
|
||||
promiseReject.GetData();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void PromiseRejectInfoGetPromiseFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<StringRef> promiseStirng = StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
Local<JSValueRef> promise(promiseStirng);
|
||||
Local<StringRef> reasonString = StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
Local<JSValueRef> reason(reasonString);
|
||||
void *newdata = static_cast<void*>(new std::string("test"));
|
||||
PromiseRejectInfo promiseReject(promise, reason, PromiseRejectInfo::PROMISE_REJECTION_EVENT::REJECT, newdata);
|
||||
promiseReject.GetPromise();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void PromiseRejectInfoGetReasonFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<StringRef> promiseStirng = StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
Local<JSValueRef> promise(promiseStirng);
|
||||
Local<StringRef> reasonString = StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
Local<JSValueRef> reason(reasonString);
|
||||
void *data2 = static_cast<void*>(new std::string("test"));
|
||||
PromiseRejectInfo promiseReject(promise, reason, PromiseRejectInfo::PROMISE_REJECTION_EVENT::REJECT, data2);
|
||||
[[maybe_unused]]Local<JSValueRef> reason_res = promiseReject.GetReason();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void PromiseRejectInfoGetOperationFuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<StringRef> promiseStirng = StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
Local<JSValueRef> promise(promiseStirng);
|
||||
Local<StringRef> reasonString = StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
Local<JSValueRef> reason(reasonString);
|
||||
void *data2 = static_cast<void*>(new std::string("test"));
|
||||
PromiseRejectInfo promiseReject(promise, reason, PromiseRejectInfo::PROMISE_REJECTION_EVENT::REJECT, data2);
|
||||
promiseReject.GetOperation();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::PromiseRejectInfoNewFuzzTest(data, size);
|
||||
OHOS::GetPromiseFuzzTest(data, size);
|
||||
OHOS::GetDataFuzzTest(data, size);
|
||||
OHOS::PromiseRejectInfoGetPromiseFuzzTest(data, size);
|
||||
OHOS::PromiseRejectInfoGetReasonFuzzTest(data, size);
|
||||
OHOS::PromiseRejectInfoGetOperationFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef PROMISEREJECTINFO_FUZZER_H
|
||||
#define PROMISEREJECTINFO_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "promiserejectinfo_fuzzer.h"
|
||||
|
||||
#endif
|
44
test/fuzztest/registerquickfixqueryfunc_fuzzer/BUILD.gn
Normal file
44
test/fuzztest/registerquickfixqueryfunc_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,44 @@
|
||||
# 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.
|
||||
|
||||
#####################################hydra-fuzz###############################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
####################################fuzztest##################################
|
||||
ohos_fuzztest("RegisterQuickFixQueryFuncFuzzerTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/registerquickfixqueryfunc_fuzzer"
|
||||
|
||||
sources = [ "registerquickfixqueryfunc_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":RegisterQuickFixQueryFuncFuzzerTest" ]
|
||||
}
|
14
test/fuzztest/registerquickfixqueryfunc_fuzzer/corpus/init
Normal file
14
test/fuzztest/registerquickfixqueryfunc_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
25
test/fuzztest/registerquickfixqueryfunc_fuzzer/project.xml
Normal file
25
test/fuzztest/registerquickfixqueryfunc_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "registerquickfixqueryfunc_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
bool QuickFixQueryFunc(std::string baseFileName, std::string &patchFileName, void **patchBuffer,
|
||||
size_t &patchBufferSize)
|
||||
{
|
||||
if (baseFileName != "multi_file/base/merge.abc") {
|
||||
return false;
|
||||
}
|
||||
patchFileName = "__index.pa";
|
||||
const char *data = R"(
|
||||
.function void foo() {}
|
||||
)";
|
||||
char *bufferData = new char[strlen(data) + 1];
|
||||
size_t dataSize = strlen(data) + 1;
|
||||
strcpy_s(bufferData, dataSize, data);
|
||||
*patchBuffer = reinterpret_cast<void *>(bufferData);
|
||||
patchBufferSize = strlen(data);
|
||||
return true;
|
||||
}
|
||||
void RegisterQuickFixQueryFuncFuzzerTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
JSNApi::RegisterQuickFixQueryFunc(vm, QuickFixQueryFunc);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::RegisterQuickFixQueryFuncFuzzerTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef REGISTERQUICKFIXQUERYFUNC_FUZZER_H
|
||||
#define REGISTERQUICKFIXQUERYFUNC_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "registerquickfixqueryfunc_fuzzer.h"
|
||||
|
||||
#endif
|
44
test/fuzztest/setbundlename_fuzzer/BUILD.gn
Normal file
44
test/fuzztest/setbundlename_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,44 @@
|
||||
# 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.
|
||||
|
||||
#####################################hydra-fuzz###############################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
####################################fuzztest##################################
|
||||
ohos_fuzztest("SetBundleNameFuzzerTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/setbundlename_fuzzer"
|
||||
|
||||
sources = [ "setbundlename_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":SetBundleNameFuzzerTest" ]
|
||||
}
|
14
test/fuzztest/setbundlename_fuzzer/corpus/init
Normal file
14
test/fuzztest/setbundlename_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
25
test/fuzztest/setbundlename_fuzzer/project.xml
Normal file
25
test/fuzztest/setbundlename_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
45
test/fuzztest/setbundlename_fuzzer/setbundlename_fuzzer.cpp
Normal file
45
test/fuzztest/setbundlename_fuzzer/setbundlename_fuzzer.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "setbundlename_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
void SetBundleNameFuzzerTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
JSNApi::SetBundleName(vm, (char*)data);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::SetBundleNameFuzzerTest(data, size);
|
||||
return 0;
|
||||
}
|
21
test/fuzztest/setbundlename_fuzzer/setbundlename_fuzzer.h
Normal file
21
test/fuzztest/setbundlename_fuzzer/setbundlename_fuzzer.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef SETBUNDLENAME_FUZZER_H
|
||||
#define SETBUNDLENAME_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "setbundlename_fuzzer.h"
|
||||
|
||||
#endif
|
44
test/fuzztest/setmodulename_fuzzer/BUILD.gn
Normal file
44
test/fuzztest/setmodulename_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,44 @@
|
||||
# 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.
|
||||
|
||||
#####################################hydra-fuzz###############################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
####################################fuzztest##################################
|
||||
ohos_fuzztest("SetModuleNameFuzzerTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/setmodulename_fuzzer"
|
||||
|
||||
sources = [ "setmodulename_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":SetModuleNameFuzzerTest" ]
|
||||
}
|
14
test/fuzztest/setmodulename_fuzzer/corpus/init
Normal file
14
test/fuzztest/setmodulename_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
25
test/fuzztest/setmodulename_fuzzer/project.xml
Normal file
25
test/fuzztest/setmodulename_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
45
test/fuzztest/setmodulename_fuzzer/setmodulename_fuzzer.cpp
Normal file
45
test/fuzztest/setmodulename_fuzzer/setmodulename_fuzzer.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "setmodulename_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
void SetModuleNameFuzzerTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
JSNApi::SetModuleName(vm, (char*)data);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::SetModuleNameFuzzerTest(data, size);
|
||||
return 0;
|
||||
}
|
21
test/fuzztest/setmodulename_fuzzer/setmodulename_fuzzer.h
Normal file
21
test/fuzztest/setmodulename_fuzzer/setmodulename_fuzzer.h
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef SETMODULENAME_FUZZER_H
|
||||
#define SETMODULENAME_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "setmodulename_fuzzer.h"
|
||||
|
||||
#endif
|
46
test/fuzztest/stringreflength_fuzzer/BUILD.gn
Normal file
46
test/fuzztest/stringreflength_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,46 @@
|
||||
# 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.
|
||||
|
||||
##################################hydra-fuzz###################################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
##################################fuzztest#####################################
|
||||
ohos_fuzztest("StringRefLengthFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/stringreflength_fuzzer"
|
||||
|
||||
resource_config_file = "$js_root/test/resource/js_runtime/ohos_test.xml"
|
||||
|
||||
sources = [ "stringreflength_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime_test",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":StringRefLengthFuzzTest" ]
|
||||
}
|
14
test/fuzztest/stringreflength_fuzzer/corpus/init
Normal file
14
test/fuzztest/stringreflength_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
25
test/fuzztest/stringreflength_fuzzer/project.xml
Normal file
25
test/fuzztest/stringreflength_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "stringreflength_fuzzer.h"
|
||||
#include "ecmascript/base/utf_helper.h"
|
||||
#include "ecmascript/ecma_string-inl.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
using namespace panda::ecmascript::base::utf_helper;
|
||||
|
||||
namespace OHOS {
|
||||
void StringRefLengthFuzzTest([[maybe_unused]]const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Local<StringRef> res = StringRef::StringRef::NewFromUtf8(vm, (char*)data, (int)size);
|
||||
res->Length();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::StringRefLengthFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef STRINGREFLENGTH_FUZZER_H
|
||||
#define STRINGREFLENGTH_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "stringreflength_fuzzer"
|
||||
|
||||
#endif
|
46
test/fuzztest/stringrefnewfromutf16_fuzzer/BUILD.gn
Normal file
46
test/fuzztest/stringrefnewfromutf16_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,46 @@
|
||||
# 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.
|
||||
|
||||
##################################hydra-fuzz###################################
|
||||
import("//arkcompiler/ets_runtime/js_runtime_config.gni")
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
|
||||
##################################fuzztest#####################################
|
||||
ohos_fuzztest("StringRefNewFromUtf16FuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/stringrefnewfromutf16_fuzzer"
|
||||
|
||||
resource_config_file = "$js_root/test/resource/js_runtime/ohos_test.xml"
|
||||
|
||||
sources = [ "stringrefnewfromutf16_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "$js_root:ecma_test_config" ]
|
||||
|
||||
deps = [
|
||||
"$js_root:libark_jsruntime_test",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
}
|
||||
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [ ":StringRefNewFromUtf16FuzzTest" ]
|
||||
}
|
14
test/fuzztest/stringrefnewfromutf16_fuzzer/corpus/init
Normal file
14
test/fuzztest/stringrefnewfromutf16_fuzzer/corpus/init
Normal file
@ -0,0 +1,14 @@
|
||||
# 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
|
25
test/fuzztest/stringrefnewfromutf16_fuzzer/project.xml
Normal file
25
test/fuzztest/stringrefnewfromutf16_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "stringrefnewfromutf16_fuzzer.h"
|
||||
#include "ecmascript/base/utf_helper.h"
|
||||
#include "ecmascript/ecma_string-inl.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
using namespace panda::ecmascript::base::utf_helper;
|
||||
|
||||
namespace OHOS {
|
||||
void StringRefNewFromUtf16FuzzTest(const uint8_t* data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
if (data == nullptr || size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
StringRef::NewFromUtf16(vm, (char16_t*)data);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::StringRefNewFromUtf16FuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user