mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2025-02-17 02:10:00 +00:00
commit
8decbd1fd3
@ -19,7 +19,6 @@ group("fuzztest") {
|
||||
"arraybufferrefnew_fuzzer:fuzztest",
|
||||
"arraybufferrefnewwithtwoparameters_fuzzer:fuzztest",
|
||||
"arraylist_fuzzer:fuzztest",
|
||||
"arrayref_fuzzer:fuzztest",
|
||||
"bigint64arrayrefnew_fuzzer:fuzztest",
|
||||
"bigintrefgetwordsarraysize_fuzzer:fuzztest",
|
||||
"bigintrefnew_fuzzer:fuzztest",
|
||||
@ -200,10 +199,8 @@ group("fuzztest") {
|
||||
"copyableglobalisempty_fuzzer:fuzztest",
|
||||
"copyableglobalsetandclearweak_fuzzer:fuzztest",
|
||||
"createbigwords_fuzzer:fuzztest",
|
||||
"dataviewref_fuzzer:fuzztest",
|
||||
"dataviewrefnew_fuzzer:fuzztest",
|
||||
"daterefnew_fuzzer:fuzztest",
|
||||
"deleteworker_fuzzer:fuzztest",
|
||||
"dumpheapsnapshot1_fuzzer:fuzztest",
|
||||
"dumpheapsnapshot2_fuzzer:fuzztest",
|
||||
"dumpheapsnapshot3_fuzzer:fuzztest",
|
||||
@ -213,7 +210,6 @@ group("fuzztest") {
|
||||
"exceptionevalerror_fuzzer:fuzztest",
|
||||
"exceptionoomerror_fuzzer:fuzztest",
|
||||
"exceptiontypeerror_fuzzer:fuzztest",
|
||||
"executionscope_fuzzer:fuzztest",
|
||||
"float32arrayrefnew_fuzzer:fuzztest",
|
||||
"float64arrayrefnew_fuzzer:fuzztest",
|
||||
"functionrefcall_fuzzer:fuzztest",
|
||||
@ -226,19 +222,16 @@ group("fuzztest") {
|
||||
"functionrefnewclassfunction_fuzzer:fuzztest",
|
||||
"generatorfunctionref_fuzzer:fuzztest",
|
||||
"getallocationprofile_fuzzer:fuzztest",
|
||||
"getassetpath_fuzzer:fuzztest",
|
||||
"getbundlename_fuzzer:fuzztest",
|
||||
"getformatfunction_fuzzer:fuzztest",
|
||||
"getjspandafile_fuzzer:fuzztest",
|
||||
"getmodulename_fuzzer:fuzztest",
|
||||
"getnativepointerfield_fuzzer:fuzztest",
|
||||
"getwordsarray_fuzzer:fuzztest",
|
||||
"globalclass_fuzzer:fuzztest",
|
||||
"int16arrayrefnew_fuzzer:fuzztest",
|
||||
"int32arrayrefnew_fuzzer:fuzztest",
|
||||
"int8arrayrefnew_fuzzer:fuzztest",
|
||||
"integerrefnewvalue_fuzzer:fuzztest",
|
||||
"isquickfixcausedexception_fuzzer:fuzztest",
|
||||
"jsnapiaddworker_fuzzer:fuzztest",
|
||||
"jsnapicontext_fuzzer:fuzztest",
|
||||
"jsnapideleteserializationdata_fuzzer:fuzztest",
|
||||
@ -265,7 +258,6 @@ group("fuzztest") {
|
||||
"jsnapitriggergc_fuzzer:fuzztest",
|
||||
"jsnapiuncaughtclearexception_fuzzer:fuzztest",
|
||||
"jsnapiuncaughtexception_fuzzer:fuzztest",
|
||||
"jsnapiunloadpatch_fuzzer:fuzztest",
|
||||
"jsnapivalue_fuzzer:fuzztest",
|
||||
"jsonparse_fuzzer:fuzztest",
|
||||
"jsonstringify_fuzzer:fuzztest",
|
||||
@ -306,7 +298,6 @@ group("fuzztest") {
|
||||
"jsvaluerefuint32value_fuzzer:fuzztest",
|
||||
"jsvaluerefwithinint32_fuzzer:fuzztest",
|
||||
"loadapbinaryfile_fuzzer:fuzztest",
|
||||
"loadpatch_fuzzer:fuzztest",
|
||||
"loadpatchlong_fuzzer:fuzztest",
|
||||
"mapiteratorefget_fuzzer:fuzztest",
|
||||
"maprefgetsetkeyvaluesize_fuzzer:fuzztest",
|
||||
@ -323,7 +314,6 @@ group("fuzztest") {
|
||||
"numberrefnewuint32_fuzzer:fuzztest",
|
||||
"numberrefvalue_fuzzer:fuzztest",
|
||||
"objectbool_fuzzer:fuzztest",
|
||||
"objectcast_fuzzer:fuzztest",
|
||||
"objectdelete_fuzzer:fuzztest",
|
||||
"objectget_fuzzer:fuzztest",
|
||||
"objectgetinformation_fuzzer:fuzztest",
|
||||
@ -337,18 +327,14 @@ group("fuzztest") {
|
||||
"objectset_fuzzer:fuzztest",
|
||||
"parsefromtext_fuzzer:fuzztest",
|
||||
"primitiverefgetvalue_fuzzer:fuzztest",
|
||||
"promisecapabilityref_fuzzer:fuzztest",
|
||||
"promiseref_fuzzer:fuzztest",
|
||||
"promiserejectinfo_fuzzer:fuzztest",
|
||||
"propertyattribute_fuzzer:fuzztest",
|
||||
"proxyrefisrevoked_fuzzer:fuzztest",
|
||||
"publicapicollatorrefget_fuzzer:fuzztest",
|
||||
"publicapigeneratorobjectref_fuzzer:fuzztest",
|
||||
"publicapilocal_fuzzer:fuzztest",
|
||||
"publicapilocaloperatorsymbol_fuzzer:fuzztest",
|
||||
"publicapilocalregexpref_fuzzer:fuzztest",
|
||||
"readenablelist_fuzzer:fuzztest",
|
||||
"registerquickfixqueryfunc_fuzzer:fuzztest",
|
||||
"setbundlename_fuzzer:fuzztest",
|
||||
"setcpusamplinginterval_fuzzer:fuzztest",
|
||||
"setiteratorrefget_fuzzer:fuzztest",
|
||||
@ -376,10 +362,7 @@ group("fuzztest") {
|
||||
"stringrefwriteutf16_fuzzer:fuzztest",
|
||||
"symbolnew_fuzzer:fuzztest",
|
||||
"symbolrefgetdescription_fuzzer:fuzztest",
|
||||
"templateclassglobal_fuzzer:fuzztest",
|
||||
"tonativepointer_fuzzer:fuzztest",
|
||||
"trycatch_fuzzer:fuzztest",
|
||||
"typedarrayref_fuzzer:fuzztest",
|
||||
"uint16arrayrefnew_fuzzer:fuzztest",
|
||||
"uint32arrayrefbytelength_fuzzer:fuzztest",
|
||||
"uint32arrayrefnew_fuzzer:fuzztest",
|
||||
|
@ -1,44 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####################################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("ArrayRefFuzzTest") {
|
||||
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 += [ ":ArrayRefFuzzTest" ]
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#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;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ARRAYREF_FUZZER_H
|
||||
#define ARRAYREF_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "arrayref_fuzzer.h"
|
||||
|
||||
#endif
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1,46 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
##################################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("DataViewRefFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/dataviewref_fuzzer"
|
||||
|
||||
resource_config_file = "$js_root/test/resource/js_runtime/ohos_test.xml"
|
||||
|
||||
sources = [ "dataviewref_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 += [ ":DataViewRefFuzzTest" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "dataviewref_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 DataViewRefByteOffSetFuzzTest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
const int32_t length = 15;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, length);
|
||||
const uint32_t byteOffset = 5;
|
||||
const uint32_t byteLength = 7;
|
||||
Local<DataViewRef> dataView = DataViewRef::New(vm, arrayBuffer, byteOffset, byteLength);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
(void)dataView->ByteOffset();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void DataViewRefByteLengthFuzzTest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
const int32_t length = 15;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, length);
|
||||
const uint32_t byteOffset = 5;
|
||||
const uint32_t byteLength = 7;
|
||||
Local<DataViewRef> dataView = DataViewRef::New(vm, arrayBuffer, byteOffset, byteLength);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
(void)dataView->ByteLength();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void DataViewRefGetArrayBufferFuzzTest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
const int32_t length = 15;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, length);
|
||||
const uint32_t byteOffset = 5;
|
||||
const uint32_t byteLength = 7;
|
||||
Local<DataViewRef> dataView = DataViewRef::New(vm, arrayBuffer, byteOffset, byteLength);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
(void)dataView->GetArrayBuffer(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::DataViewRefByteOffSetFuzzTest(data, size);
|
||||
OHOS::DataViewRefByteLengthFuzzTest(data, size);
|
||||
OHOS::DataViewRefGetArrayBufferFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DATAVIEWREF_FUZZER_H
|
||||
#define DATAVIEWREF_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "dataviewref_fuzzer"
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1,46 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
##################################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" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#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;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DELETEWORKER_FUZZER_H
|
||||
#define DELETEWORKER_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "deleteworker_fuzzer.h"
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1,44 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
############################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" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#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;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef EXECUTIONSCOPE_FUZZER_H
|
||||
#define EXECUTIONSCOPE_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "executionscope_fuzzer"
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1,44 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####################################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("GetAssetPathFuzzTest") {
|
||||
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 += [ ":GetAssetPathFuzzTest" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#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;
|
||||
}
|
||||
std::string str = "/data/storage/el1/bundle/moduleName/ets/modules.abc";
|
||||
JSNApi::SetAssetPath(vm, str);
|
||||
[[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;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef GETASSETPATH_FUZZER_H
|
||||
#define GETASSETPATH_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "getassetpath_fuzzer.h"
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1,44 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####################################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("GlobalClassFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/globalclass_fuzzer"
|
||||
|
||||
sources = [ "globalclass_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 += [ ":GlobalClassFuzzTest" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
#include "globalclass_fuzzer.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
void GlobalFuzzerTest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
{
|
||||
JsiFastNativeScope scope(vm);
|
||||
Global<JSValueRef> param;
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
[[maybe_unused]]Global<JSValueRef> global(param);
|
||||
}
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void GlobalOperatorEqualFuzzerTest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
{
|
||||
JsiFastNativeScope scope(vm);
|
||||
Global<JSValueRef> param;
|
||||
Global<JSValueRef> global;
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
global = param;
|
||||
}
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void GlobalMoveFuzzerTest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
{
|
||||
JsiFastNativeScope scope(vm);
|
||||
Global<JSValueRef> param;
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
[[maybe_unused]]Global<JSValueRef> global(std::move(param));
|
||||
}
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void GlobalOperatorEqualMoveFuzzerTest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
{
|
||||
JsiFastNativeScope scope(vm);
|
||||
Global<JSValueRef> param;
|
||||
Global<JSValueRef> global;
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
global = std::move(param);
|
||||
}
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void GlobalVMLocalFuzzerTest([[maybe_unused]]const uint8_t *data, size_t size)
|
||||
{
|
||||
RuntimeOption option;
|
||||
option.SetLogLevel(RuntimeOption::LOG_LEVEL::ERROR);
|
||||
EcmaVM *vm = JSNApi::CreateJSVM(option);
|
||||
{
|
||||
JsiFastNativeScope scope(vm);
|
||||
Local<BooleanRef> current = BooleanRef::New(vm, true);
|
||||
if (size <= 0) {
|
||||
LOG_ECMA(ERROR) << "illegal input!";
|
||||
return;
|
||||
}
|
||||
Global<JSValueRef> global(vm, current);
|
||||
}
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::GlobalFuzzerTest(data, size);
|
||||
OHOS::GlobalOperatorEqualFuzzerTest(data, size);
|
||||
OHOS::GlobalMoveFuzzerTest(data, size);
|
||||
OHOS::GlobalOperatorEqualMoveFuzzerTest(data, size);
|
||||
OHOS::GlobalVMLocalFuzzerTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef GLOBALCLASS_FUZZER_H
|
||||
#define GLOBALCLASS_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "globalclass_fuzzer.h"
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1,44 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####################################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("IsQuickFixCausedExceptionFuzzTest") {
|
||||
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 += [ ":IsQuickFixCausedExceptionFuzzTest" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#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;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ISQUICKFIXCAUSEDEXCEPTION_FUZZER_H
|
||||
#define ISQUICKFIXCAUSEDEXCEPTION_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "isquickfixcausedexception_fuzzer.h"
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -34,19 +34,8 @@ void JSNApiGetAndClearUncaughtExceptionFuzzTest(const uint8_t *data, size_t size
|
||||
Local<StringRef> message = StringRef::NewFromUtf8(vm, (char *)data, (int)size);
|
||||
Local<JSValueRef> error = Exception::Error(vm, message);
|
||||
JSNApi::ThrowException(vm, error);
|
||||
JSNApi::GetAndClearUncaughtException(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void JSNApiPrintExceptionInfoFuzzTest([[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) {
|
||||
return;
|
||||
}
|
||||
JSNApi::PrintExceptionInfo(vm);
|
||||
JSNApi::GetAndClearUncaughtException(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
@ -71,7 +60,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::JSNApiGetAndClearUncaughtExceptionFuzzTest(data, size);
|
||||
OHOS::JSNApiPrintExceptionInfoFuzzTest(data, size);
|
||||
OHOS::JSNApiThrowExceptionFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####################################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("JSNApiUnloadPatchFuzzTest") {
|
||||
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 += [ ":JSNApiUnloadPatchFuzzTest" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#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;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef JSNAPIUNLOADPATCH_FUZZER_H
|
||||
#define JSNAPIUNLOADPATCH_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "jsnapiunloadpatch_fuzzer.h"
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1,46 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
##################################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" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#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;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef LOADPATCH_FUZZER_H
|
||||
#define LOADPATCH_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "loadpatch_fuzzer.h"
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1,44 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####################################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("ObjectCastFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/objectcast_fuzzer"
|
||||
|
||||
sources = [ "objectcast_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 += [ ":ObjectCastFuzzTest" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "objectcast_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
void ObjectCastFuzzTest([[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) {
|
||||
return;
|
||||
}
|
||||
Local<JSValueRef> value1 = ObjectRef::New(vm);
|
||||
ObjectRef::Cast(*value1);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::ObjectCastFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OBJECTCAST_FUZZER_H
|
||||
#define OBJECTCAST_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "objectcast_fuzzer.h"
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1,46 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
##################################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" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#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;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef PROMISECAPABILITYREF_FUZZER_H
|
||||
#define PROMISECAPABILITYREF_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "promisecapabilityref_fuzzer.h"
|
||||
|
||||
#endif
|
@ -42,20 +42,6 @@ namespace OHOS {
|
||||
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;
|
||||
@ -138,7 +124,6 @@ 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);
|
||||
|
@ -1,44 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####################################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("PublicApiLocalFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/publicapilocal_fuzzer"
|
||||
|
||||
sources = [ "publicapilocal_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 += [ ":PublicApiLocalFuzzTest" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "publicapilocal_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
void LocalIsEmptyFuzzTest([[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<IntegerRef> intValue = IntegerRef::New(vm, (int)size);
|
||||
intValue.IsEmpty();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void LocalIsNullFuzzTest([[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<IntegerRef> intValue = IntegerRef::New(vm, (int)size);
|
||||
intValue.IsNull();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::LocalIsEmptyFuzzTest(data, size);
|
||||
OHOS::LocalIsNullFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef PUBLICAPILOCAL_FUZZER_H
|
||||
#define PUBLICAPILOCAL_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "publicapilocal_fuzzer.h"
|
||||
|
||||
#endif
|
@ -1,45 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####################################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("PublicApiLocalOperatorSymbolFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file =
|
||||
"$js_root/test/fuzztest/publicapilocaloperatorsymbol_fuzzer"
|
||||
|
||||
sources = [ "publicapilocaloperatorsymbol_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 += [ ":PublicApiLocalOperatorSymbolFuzzTest" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "publicapilocaloperatorsymbol_fuzzer.h"
|
||||
#include "ecmascript/base/string_helper.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
||||
using namespace panda;
|
||||
using namespace panda::ecmascript;
|
||||
|
||||
namespace OHOS {
|
||||
void LocalOperatorOneFuzzTest([[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<IntegerRef> intValue = IntegerRef::New(vm, (int)size);
|
||||
intValue.operator->();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void LocalOperatorTowFuzzTest([[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<IntegerRef> intValue = IntegerRef::New(vm, (int)size);
|
||||
intValue.operator*();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::LocalOperatorOneFuzzTest(data, size);
|
||||
OHOS::LocalOperatorTowFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef PUBLICAPILOCALOPERATORSYMBOL_FUZZER_H
|
||||
#define PUBLICAPILOCALOPERATORSYMBOL_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "publicapilocaloperatorsymbol_fuzzer.h"
|
||||
|
||||
#endif
|
@ -1,44 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####################################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("RegisterQuickFixQueryFuncFuzzTest") {
|
||||
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 += [ ":RegisterQuickFixQueryFuncFuzzTest" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1,62 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#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, uint8_t **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<uint8_t *>(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;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef REGISTERQUICKFIXQUERYFUNC_FUZZER_H
|
||||
#define REGISTERQUICKFIXQUERYFUNC_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "registerquickfixqueryfunc_fuzzer.h"
|
||||
|
||||
#endif
|
@ -1,44 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####################################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("TemplateClassGlobalFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/templateclassglobal_fuzzer"
|
||||
|
||||
sources = [ "templateclassglobal_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 += [ ":TemplateClassGlobalFuzzTest" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1,203 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "templateclassglobal_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 TemplateGlobalFuzzerTest([[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<BooleanRef> current = BooleanRef::New(vm, true);
|
||||
[[maybe_unused]]Global<JSValueRef> global(vm, current);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void TemplateToLocalFuzzerTest([[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;
|
||||
}
|
||||
Global<BooleanRef> global(vm, BooleanRef::New(vm, true));
|
||||
[[maybe_unused]]Local<JSValueRef> local = global.ToLocal();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void TemplateToLocalFromVMFuzzerTest([[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;
|
||||
}
|
||||
Global<BooleanRef> global(vm, BooleanRef::New(vm, true));
|
||||
[[maybe_unused]]Local<JSValueRef> local = global.ToLocal(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void TemplateEmptyFuzzerTest([[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;
|
||||
}
|
||||
Global<BooleanRef> global(vm, BooleanRef::New(vm, true));
|
||||
global.Empty();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void TemplateFreeGlobalHandleAddrFuzzerTest([[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;
|
||||
}
|
||||
Global<BooleanRef> global(vm, BooleanRef::New(vm, true));
|
||||
global.FreeGlobalHandleAddr();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void GlobalOperatorStarFuzzerTest([[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;
|
||||
}
|
||||
Global<BooleanRef> global(vm, BooleanRef::New(vm, true));
|
||||
[[maybe_unused]]bool b = (*global)->BooleaValue(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void GlobalOperatorPointToFuzzerTest([[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;
|
||||
}
|
||||
Global<BooleanRef> global(vm, BooleanRef::New(vm, true));
|
||||
[[maybe_unused]]bool b = global->BooleaValue(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void GlobalIsEmptyFuzzerTest([[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;
|
||||
}
|
||||
Global<JSValueRef> global;
|
||||
[[maybe_unused]]bool b = global.IsEmpty();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void GlobalSetWeakFuzzerTest([[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;
|
||||
}
|
||||
Global<JSValueRef> global(vm, BooleanRef::New(vm, true));
|
||||
global.SetWeak();
|
||||
bool res = global.IsWeak();
|
||||
if (!res) {
|
||||
LOG_ECMA(ERROR) << "SetWeak failed";
|
||||
return;
|
||||
}
|
||||
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void GlobalClearWeakFuzzerTest([[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;
|
||||
}
|
||||
Global<JSValueRef> global(vm, BooleanRef::New(vm, true));
|
||||
global.ClearWeak();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void GlobalIsWeakFuzzerTest([[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;
|
||||
}
|
||||
Global<JSValueRef> global(vm, BooleanRef::New(vm, true));
|
||||
global.SetWeak();
|
||||
[[maybe_unused]]bool b = global.IsWeak();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::TemplateGlobalFuzzerTest(data, size);
|
||||
OHOS::TemplateToLocalFuzzerTest(data, size);
|
||||
OHOS::TemplateToLocalFromVMFuzzerTest(data, size);
|
||||
OHOS::TemplateEmptyFuzzerTest(data, size);
|
||||
OHOS::TemplateFreeGlobalHandleAddrFuzzerTest(data, size);
|
||||
OHOS::GlobalOperatorStarFuzzerTest(data, size);
|
||||
OHOS::GlobalOperatorPointToFuzzerTest(data, size);
|
||||
OHOS::GlobalIsEmptyFuzzerTest(data, size);
|
||||
OHOS::GlobalSetWeakFuzzerTest(data, size);
|
||||
OHOS::GlobalClearWeakFuzzerTest(data, size);
|
||||
OHOS::GlobalIsWeakFuzzerTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TEMPLATECLASSGLOBAL_FUZZER_H
|
||||
#define TEMPLATECLASSGLOBAL_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "templateclassglobal_fuzzer.h"
|
||||
|
||||
#endif
|
@ -1,44 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####################################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("TryCatchFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/trycatch_fuzzer"
|
||||
|
||||
sources = [ "trycatch_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 += [ ":TryCatchFuzzTest" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "trycatch_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 TryCatchNewFuzzerTest([[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;
|
||||
}
|
||||
TryCatch trycatch(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void TryCatchHasCaughtFuzzerTest([[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;
|
||||
}
|
||||
TryCatch trycatch(vm);
|
||||
trycatch.HasCaught();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void TryCatchRethrowFuzzerTest([[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;
|
||||
}
|
||||
TryCatch trycatch(vm);
|
||||
trycatch.Rethrow();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void GetAndClearExceptionFuzzTest([[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;
|
||||
}
|
||||
TryCatch trycatch(vm);
|
||||
trycatch.GetAndClearException();
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::TryCatchNewFuzzerTest(data, size);
|
||||
OHOS::TryCatchHasCaughtFuzzerTest(data, size);
|
||||
OHOS::TryCatchRethrowFuzzerTest(data, size);
|
||||
OHOS::GetAndClearExceptionFuzzTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TRYCATCH_FUZZER_H
|
||||
#define TRYCATCH_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "trycatch_fuzzer.h"
|
||||
|
||||
#endif
|
@ -1,44 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####################################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("TypedArrayrefFuzzTest") {
|
||||
module_out_path = ets_runtime_output_path
|
||||
|
||||
fuzz_config_file = "$js_root/test/fuzztest/typedarrayref_fuzzer"
|
||||
|
||||
sources = [ "typedarrayref_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 += [ ":TypedArrayrefFuzzTest" ]
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
FUZZ
|
@ -1,25 +0,0 @@
|
||||
<?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>
|
@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "typedarrayref_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 TypedArrayrefArrayLengthFuzzerTest([[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 byteOffset = 5;
|
||||
constexpr int length = 6;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (int32_t)size);
|
||||
Local<Int8ArrayRef> typedArray = Int8ArrayRef::New(vm, arrayBuffer, byteOffset, length);
|
||||
typedArray->ArrayLength(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void TypedArrayrefByteOffSetFuzzerTest([[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 byteOffset = 5;
|
||||
constexpr int length = 6;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (int32_t)size);
|
||||
Local<Int8ArrayRef> typedArray = Int8ArrayRef::New(vm, arrayBuffer, byteOffset, length);
|
||||
typedArray->ByteOffset(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
|
||||
void TypedArrayrefGetArrayBufferFuzzerTest([[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 byteOffset = 5;
|
||||
constexpr int length = 6;
|
||||
Local<ArrayBufferRef> arrayBuffer = ArrayBufferRef::New(vm, (int32_t)size);
|
||||
Local<Int8ArrayRef> typedArray = Int8ArrayRef::New(vm, arrayBuffer, byteOffset, length);
|
||||
typedArray->GetArrayBuffer(vm);
|
||||
JSNApi::DestroyJSVM(vm);
|
||||
}
|
||||
}
|
||||
|
||||
// Fuzzer entry point.
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
// Run your code on data.
|
||||
OHOS::TypedArrayrefArrayLengthFuzzerTest(data, size);
|
||||
OHOS::TypedArrayrefByteOffSetFuzzerTest(data, size);
|
||||
OHOS::TypedArrayrefGetArrayBufferFuzzerTest(data, size);
|
||||
return 0;
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef TYPEDARRAYREF_FUZZER_H
|
||||
#define TYPEDARRAYREF_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "typedarrayref_fuzzer.h"
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user