From bc64c67014906671dc279ac9cd181c0bc209b240 Mon Sep 17 00:00:00 2001 From: Vadim Afanasyev Date: Tue, 18 Jun 2024 16:46:31 +0800 Subject: [PATCH] Added all the examples from ArkTS Kit HashMap to the initial corpus --- InitialArkTSCorpus/README.md | 17 +++++++++++++---- InitialArkTSCorpus/hashMapClear.fzil | Bin 0 -> 202 bytes InitialArkTSCorpus/hashMapClear.js | 6 ++++++ InitialArkTSCorpus/hashMapEntries.fzil | Bin 0 -> 451 bytes InitialArkTSCorpus/hashMapEntries.js | 12 ++++++++++++ InitialArkTSCorpus/hashMapForEach.fzil | Bin 0 -> 311 bytes InitialArkTSCorpus/hashMapForEach.js | 8 ++++++++ InitialArkTSCorpus/hashMapGet.fzil | Bin 0 -> 217 bytes InitialArkTSCorpus/hashMapGet.js | 6 ++++++ InitialArkTSCorpus/hashMapHasKey.fzil | Bin 0 -> 179 bytes InitialArkTSCorpus/hashMapHasKey.js | 5 +++++ InitialArkTSCorpus/hashMapHasValue.fzil | Bin 0 -> 173 bytes InitialArkTSCorpus/hashMapHasValue.js | 5 +++++ InitialArkTSCorpus/hashMapIterator.fzil | Bin 0 -> 665 bytes InitialArkTSCorpus/hashMapIterator.js | 19 +++++++++++++++++++ InitialArkTSCorpus/hashMapKeys.fzil | Bin 0 -> 357 bytes InitialArkTSCorpus/hashMapKeys.js | 11 +++++++++++ InitialArkTSCorpus/hashMapRemove.fzil | Bin 0 -> 220 bytes InitialArkTSCorpus/hashMapRemove.js | 6 ++++++ InitialArkTSCorpus/hashMapReplace.fzil | Bin 0 -> 189 bytes InitialArkTSCorpus/hashMapReplace.js | 5 +++++ InitialArkTSCorpus/hashMapSet.fzil | Bin 0 -> 144 bytes InitialArkTSCorpus/hashMapSet.js | 4 ++++ InitialArkTSCorpus/hashMapSetAll.fzil | Bin 0 -> 253 bytes InitialArkTSCorpus/hashMapSetAll.js | 8 ++++++++ InitialArkTSCorpus/hashMapValues.fzil | Bin 0 -> 359 bytes InitialArkTSCorpus/hashMapValues.js | 11 +++++++++++ 27 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 InitialArkTSCorpus/hashMapClear.fzil create mode 100644 InitialArkTSCorpus/hashMapClear.js create mode 100644 InitialArkTSCorpus/hashMapEntries.fzil create mode 100644 InitialArkTSCorpus/hashMapEntries.js create mode 100644 InitialArkTSCorpus/hashMapForEach.fzil create mode 100644 InitialArkTSCorpus/hashMapForEach.js create mode 100644 InitialArkTSCorpus/hashMapGet.fzil create mode 100644 InitialArkTSCorpus/hashMapGet.js create mode 100644 InitialArkTSCorpus/hashMapHasKey.fzil create mode 100644 InitialArkTSCorpus/hashMapHasKey.js create mode 100644 InitialArkTSCorpus/hashMapHasValue.fzil create mode 100644 InitialArkTSCorpus/hashMapHasValue.js create mode 100644 InitialArkTSCorpus/hashMapIterator.fzil create mode 100644 InitialArkTSCorpus/hashMapIterator.js create mode 100644 InitialArkTSCorpus/hashMapKeys.fzil create mode 100644 InitialArkTSCorpus/hashMapKeys.js create mode 100644 InitialArkTSCorpus/hashMapRemove.fzil create mode 100644 InitialArkTSCorpus/hashMapRemove.js create mode 100644 InitialArkTSCorpus/hashMapReplace.fzil create mode 100644 InitialArkTSCorpus/hashMapReplace.js create mode 100644 InitialArkTSCorpus/hashMapSet.fzil create mode 100644 InitialArkTSCorpus/hashMapSet.js create mode 100644 InitialArkTSCorpus/hashMapSetAll.fzil create mode 100644 InitialArkTSCorpus/hashMapSetAll.js create mode 100644 InitialArkTSCorpus/hashMapValues.fzil create mode 100644 InitialArkTSCorpus/hashMapValues.js diff --git a/InitialArkTSCorpus/README.md b/InitialArkTSCorpus/README.md index fb69546..860d8f6 100644 --- a/InitialArkTSCorpus/README.md +++ b/InitialArkTSCorpus/README.md @@ -1,12 +1,21 @@ -# How To Extend Initial ArkTS Corpus +# ArkTS Initial Corpus + +## How To Extend the Corpus This corpus is generated from ArkTS API examples: In order to extend the corpus please follow the steps: -1. Convert the given TypeScript code with the help from playground. Use import line so the compiler understands that you are using the API extension and is able to produce JavaScript code. +1. Convert the given TypeScript code with the help from playground. Use `import` line so the compiler understands that you are using the API extension and is able to produce JavaScript code. 2. Create a new `.js` file with this code in `InitialArkTSCorpus` folder. 3. Compile the given file to create corresponding `.fzil` program file (serialized `Program` class representation of FuzzIL program): `swift run FuzzILTool --compile ./InitialArkTSCorpus/.js` -4. Run fuzzing with importing of the initial ArkTS corpus. Provide the following options to FuzzilliCli: `--importCorpus=./InitialArkTSCorpus --corpusImportMode=full` -The full mode means you do not need to either assess or minimize the provided programs. They will be fed to mutators as is. +## How To Use the Corpus + +If you would like to limit your initial corpus to this one, then run fuzzing with importing of the initial ArkTS corpus. Provide the following options to FuzzilliCli: `--importCorpus=./InitialArkTSCorpus --corpusImportMode=full`. `Full` mode means you need neither to assess for usefulness nor to minimize the provided programs. They will be fed to mutators as is. These running options are also useful for testing your corpus while you are extending it. + +If you would like to use `GenerativeEngine` to generate more programs first then follow the next steps: + +1. Generate your initial corpus first by running the fuzzer with `--overwrite` option. +2. Copy the `InitalArkTSCorpus` content to your `corpus` folder where your generated programs are located. +3. Run the fuzzer with `--resume` option. diff --git a/InitialArkTSCorpus/hashMapClear.fzil b/InitialArkTSCorpus/hashMapClear.fzil new file mode 100644 index 0000000000000000000000000000000000000000..7343b1632b79fd32be01d66d893fc3ed56c42ba4 GIT binary patch literal 202 zcmYj}Jrcn{0EM$Z+1)&b%(_7uchKn+4226UGGt^XvFoQ$p)ro2a1NtX<_cPcW7ttC z-}k=v5Z~_S;qur$9j>pHX*WMwg9J}m2j+P(G5L6rIo$#c$c1~@wabyswq~8`7?jWp zk05)-Ee5944KPAkB?NfCFf%Pd8GndCH$lPf~Y^G;uJ|waN=L)D~Mnjhl%}M?ZoefzgqX z#o5(3G4ct#6r;rP-h1xvoCDrq^?GrzcT|6V`gq^JR5wZiG3J&F(2tU~<2S zsgCeMM3>4(eBs;_)hugt}hNEik7+ zG|}q@UUkL|%)u&Ewc2#4%`LROPU0+yG+MBl+9`5HNgqd2_a%q|upu_Kh?tnmtbqkkrcCM5 zC3{FqK}W~f1?|1(ejqz}yRqMg%l2b;{Eok0r-(qjE{FjtZSIx6s}~JUfqJCnPCT>A zTf5k*b%_~JLR%g}aG{#|TCH#bj8N7K0sP9S2MmBRz89V|h+jCcSt)DHvona8QTgf& z&V3Q|!UxurYm9)%!o{nN)+m95GbRso#AFEnSPU$RlTV)ml@!??JWPO03JGGX^rkFa zmQCXH$8EdHY^Yq8FQc3#`5>o2unXL$xp``gE{6?F^Xa&uO@*v;t!(Fem;>X{Q7;_) JXzaO~*MHV)JHY?| literal 0 HcmV?d00001 diff --git a/InitialArkTSCorpus/hashMapForEach.js b/InitialArkTSCorpus/hashMapForEach.js new file mode 100644 index 0000000..d62c47a --- /dev/null +++ b/InitialArkTSCorpus/hashMapForEach.js @@ -0,0 +1,8 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +let hashMap = new HashMap(); +hashMap.set("sparrow", 123); +hashMap.set("gull", 357); +hashMap.forEach((value, key) => { + console.log("value:" + value, "key:" + key); +}); \ No newline at end of file diff --git a/InitialArkTSCorpus/hashMapGet.fzil b/InitialArkTSCorpus/hashMapGet.fzil new file mode 100644 index 0000000000000000000000000000000000000000..057de3a257edf643228510a5703486a8c3fa8852 GIT binary patch literal 217 zcmYj}yA8rH07T80TW_Fz(_K!Qiq09Hkr>SCVdPIW;8a^k)m+V#xlJ6#*q0VVXr zV?<-^vZ=0A3ye_q6asuw>ZOW68NZ7_wL!uGAl+u0TWbnWi0D&!^b^iQ5j{l+=1lD~ jkpq9}Ds64KR}v)dGx?@JQ^xo=lYg@b#*@YmuT1>~B}y#` literal 0 HcmV?d00001 diff --git a/InitialArkTSCorpus/hashMapGet.js b/InitialArkTSCorpus/hashMapGet.js new file mode 100644 index 0000000..6c88320 --- /dev/null +++ b/InitialArkTSCorpus/hashMapGet.js @@ -0,0 +1,6 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +const hashMap = new HashMap(); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); +let result = hashMap.get("sparrow"); \ No newline at end of file diff --git a/InitialArkTSCorpus/hashMapHasKey.fzil b/InitialArkTSCorpus/hashMapHasKey.fzil new file mode 100644 index 0000000000000000000000000000000000000000..b49fbc6ad9ee6c2d434cdf85eb66e2786512d3e1 GIT binary patch literal 179 zcmd-QV6NCadsVw{$|k#yS}G+qqC!Gkj0}g^dAPXJbMliCb3!sQi-m-_m>3wlSb&0# zMcDyGnPrJ3sX_u=OpHujESy~I9*M;nzKI1wd|b?oOw6a)*tl4H@)J{p*twXPS$458 z2=Q|Bt<^W|F*_4<#s)1TqSXkNEPqDFbF&C$nfK+mzs1)F0X5rvG P#m2$KmXTQOomvS1zpN(3 literal 0 HcmV?d00001 diff --git a/InitialArkTSCorpus/hashMapHasKey.js b/InitialArkTSCorpus/hashMapHasKey.js new file mode 100644 index 0000000..48d511e --- /dev/null +++ b/InitialArkTSCorpus/hashMapHasKey.js @@ -0,0 +1,5 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +const hashMap = new HashMap(); +hashMap.set("squirrel", 123); +let result = hashMap.hasKey("squirrel"); diff --git a/InitialArkTSCorpus/hashMapHasValue.fzil b/InitialArkTSCorpus/hashMapHasValue.fzil new file mode 100644 index 0000000000000000000000000000000000000000..5fd5743fcf85369022046ab60d708caa99eae808 GIT binary patch literal 173 zcmd-Q*cQIq$akLqqP-4BdLM?%>=hE?Vq`eP&cnr(o|B)Hm=ltbSu7;X#l*na#R3#` zEXocj$}CGPNfi>{Vq#?KV&UXs_edU0slb@I(#LmUU%(9D( zL5QD=k=2Tei=()(G_$BEH3ule$fm@^Q4Q3>!oteNeu|Bii@7+p1SG)$mJs4%X5rvG Q#Rk-skysp-m{Xbx0GC-M#{d8T literal 0 HcmV?d00001 diff --git a/InitialArkTSCorpus/hashMapHasValue.js b/InitialArkTSCorpus/hashMapHasValue.js new file mode 100644 index 0000000..01a6ebf --- /dev/null +++ b/InitialArkTSCorpus/hashMapHasValue.js @@ -0,0 +1,5 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +const hashMap = new HashMap(); +hashMap.set("squirrel", 123); +let result = hashMap.hasValue(123); \ No newline at end of file diff --git a/InitialArkTSCorpus/hashMapIterator.fzil b/InitialArkTSCorpus/hashMapIterator.fzil new file mode 100644 index 0000000000000000000000000000000000000000..c244cb37f34028425a93d8babb97a9f47813cb29 GIT binary patch literal 665 zcmZ9Iy;9pi5XW^NmQHJ1md`-I#(X$@g-1}wq)Cy?WCC?&j&QL(2p>5K5>Gmc6e{xu zd4UuZDJUuZ2$Y#rlsrN96p!O^dAGa2{rwl>cn}?T2QPp9`1bzfXXEajlt8@upa#%S z&8bRH2E$CYfO@3h_<3Z{-`e4|%C(Gv5?b&Of>$aVyiu1j0!ApC_&)I0MxDt3DC2j& zCmTR234q8xT@9_(DOQNzqv9)$a9;6)iC+Ph=^WogB#6u|m9^%x6hOir6MtygDMFZa z)`9YBx$9hyGg${xyWs&;j;vKZiRRk^W_$k*BrXofl4oifNsf5|2LEy};ndciTqnHgyr z0$uMu`c!b~1L;0u2gcl(#f*SJ9GIR sad(c02D^K=oC@NYJA3<6=D{NKVE@G&leQ24Cqt{w;rGCk>`8ck0jHaNcmMzZ literal 0 HcmV?d00001 diff --git a/InitialArkTSCorpus/hashMapIterator.js b/InitialArkTSCorpus/hashMapIterator.js new file mode 100644 index 0000000..30ed098 --- /dev/null +++ b/InitialArkTSCorpus/hashMapIterator.js @@ -0,0 +1,19 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +let hashMap = new HashMap(); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); +// Method 1: +let keys = Array.from(hashMap.keys()); +for (let key of keys) { + console.log("key:" + key); + console.log("value:" + hashMap.get(key)); +} +// Method 2: +let iter = hashMap[Symbol.iterator](); +let temp = iter.next(); +while (!temp.done) { + console.log("key:" + temp.value[0]); + console.log("value:" + temp.value[1]); + temp = iter.next(); +} diff --git a/InitialArkTSCorpus/hashMapKeys.fzil b/InitialArkTSCorpus/hashMapKeys.fzil new file mode 100644 index 0000000000000000000000000000000000000000..0ae7509a6b0d64d06d1697b4b98a64a2ef12df03 GIT binary patch literal 357 zcmYL^y-or_6oq$wc4qdn3(EyxfY|v4TWO_*CYl&)N0|U&!{81e#y8l~7csPy*zp*~ zSWwc~I*y5!=iGDecP`{NtE(@0czU#cTOPcA-X0?Yi8e9?7?k!-m)FCQ!w%4h)ZCjV z)%da+E%eM_4wTTECm_$X8(!!sHh~e!wn6|ux4MrKDC27pVGBrH04Vn`A61np{e*}f zRnLBf^H|8Oh=DmX^O~r_pLA1QRrV1Tkfg`d2MtM;z+W;0${T?-Hct+{Y@|U>%yNe8 zT}3}$n$_Ib>D!6H1ZdXW392{>AkAG!kXE5UEOa?Hg=f$-uepRc7@p2rd3*o+0dAx( gc5f%nmd4*^*zSZjr5yx(_aE;+PrENNLbg}YH_q@yD*ylh literal 0 HcmV?d00001 diff --git a/InitialArkTSCorpus/hashMapKeys.js b/InitialArkTSCorpus/hashMapKeys.js new file mode 100644 index 0000000..b62b4bb --- /dev/null +++ b/InitialArkTSCorpus/hashMapKeys.js @@ -0,0 +1,11 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +let hashMap = new HashMap(); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); +let iter = hashMap.keys(); +let temp = iter.next(); +while (!temp.done) { + console.log("value:" + temp.value); + temp = iter.next(); +} \ No newline at end of file diff --git a/InitialArkTSCorpus/hashMapRemove.fzil b/InitialArkTSCorpus/hashMapRemove.fzil new file mode 100644 index 0000000000000000000000000000000000000000..7f6ce2003a9c5746343fbb484b317c9f889f4ac2 GIT binary patch literal 220 zcmYj}Jq`gu0EKscc6Rpp+l(7XTtbINL85Sh5fe66mKi^VxPW8mMNgto?hW*ugNaJ{ zzW2R{c!Dj1=x5CXiP>xqg$8NZ4^)j+})Al+({T5B@j5YeD=? nB3u5_Ew#1zPDzls!Q_knOc~?fEd84a7%!CzAt9_;b`f zi?RcXGRqQ6QiTM#m>8M5SU9=ZJravEd=m?V__&xEnV3(pv2n5ZS?5EgRxtNPnOF#-akQH)pF>)#~b3A1N WI*WycgOlqN8_<}d)PkJEb`f zi?RcXGRqQ6QiTM#m>8M5SU9=ZJravEd=m?V__&xEnV3(pv2n5Zl|VvMDifR0FlJu&}bRpJHR>VlGZC0RYT_9?<{* literal 0 HcmV?d00001 diff --git a/InitialArkTSCorpus/hashMapSet.js b/InitialArkTSCorpus/hashMapSet.js new file mode 100644 index 0000000..eadbae6 --- /dev/null +++ b/InitialArkTSCorpus/hashMapSet.js @@ -0,0 +1,4 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +let hashMap = new HashMap(); +let result = hashMap.set("squirrel", 123); diff --git a/InitialArkTSCorpus/hashMapSetAll.fzil b/InitialArkTSCorpus/hashMapSetAll.fzil new file mode 100644 index 0000000000000000000000000000000000000000..c815cd3f24c84df6d393e6814d3714e6b31bdf77 GIT binary patch literal 253 zcmX|*F;2rk5Jf$^>-GBEPORkyIflE40t%2QxWEDyu~_1;8;Ar2)Dc(U63`(*LFtM! zAP&NqBIV4y|K_9qetLQPG5gEU$NPhi=j&H%LCIHE0++r&bN+PEMY{))&{pws9k%T5Xd_dANo8+!bu*oL>;sKR!^85_ z&9B{TtycyMpoBI&0eP7Q6=A5a*g@_?l zPvM30Sjer2fqAnEGf`!*^h@oWeLw{y88Y=rTct|iPniSdovlzH*1D>V#|&sEZQ%>^ zxI*@!qVHXrH9Q0w+l9ddXx7~esyGTD-F>SddHHKn1`17!hD(TB*T83a(L4Nfz>N&i g?(D+b$^>tQy?&dgvXd4+_{WFt>EK01$POy{0%zbw9RL6T literal 0 HcmV?d00001 diff --git a/InitialArkTSCorpus/hashMapValues.js b/InitialArkTSCorpus/hashMapValues.js new file mode 100644 index 0000000..8b8effa --- /dev/null +++ b/InitialArkTSCorpus/hashMapValues.js @@ -0,0 +1,11 @@ +let arkPrivate = globalThis.ArkPrivate; +var HashMap = arkPrivate.Load(arkPrivate.HashMap); +let hashMap = new HashMap(); +hashMap.set("squirrel", 123); +hashMap.set("sparrow", 356); +let iter = hashMap.values(); +let temp = iter.next(); +while (!temp.done) { + console.log("value:" + temp.value); + temp = iter.next(); +} -- Gitee