diff --git a/Sources/FuzzilliCli/Profiles/ArkProfile.swift b/Sources/FuzzilliCli/Profiles/ArkProfile.swift index 3bcccb3222f904ac987e6a55ca5427864b789d73..e758468581147bcd3dda1d11280538976d2651d7 100644 --- a/Sources/FuzzilliCli/Profiles/ArkProfile.swift +++ b/Sources/FuzzilliCli/Profiles/ArkProfile.swift @@ -32,6 +32,13 @@ fileprivate let ArkTSObjectInstanceGenerator = ValueGenerator("ArkTSObjectInstan b.construct(constructor) } +/// ArkTS collections Generators +fileprivate let ArkTSCollectionsObjectInstanceGenerator = ValueGenerator("ArkTSCollectionsObjectInstanceGenerator") { b, n in + let builtin = chooseUniform(from: ["SharedMap"]) + let constructor = b.loadBuiltin(builtin) + b.construct(constructor) +} + /// Type of a ArkTS Stack object. fileprivate let arkTSStack = ILType.iterable + ILType.object(ofGroup: "Stack", withProperties: ["length"], withMethods: ["push", "pop", "peek", "locate", "forEach", "isEmpty"]) /// Type of a ArkTS HashMap object. @@ -39,6 +46,9 @@ fileprivate let arkTSHashMap = ILType.iterable + ILType.object(ofGroup: "HashMap /// Type of a ArkTS HashSet object. fileprivate let arkTSHashSet = ILType.iterable + ILType.object(ofGroup: "HashSet", withProperties: ["length"], withMethods: ["isEmpty", "has", "add", "remove", "clear", "values", "forEach", "entries"]) +/// Tpye of a ArkTS CollectionsMap object +fileprivate let collectionsMap = ILType.iterable + ILType.object(ofGroup: "SharedMap", withProperties: ["size"], withMethods: ["entries", "keys", "values", "clear", "delete", "forEach", "get", "has", "set"]) + /// Type of the ArkTS Stack constructor builtin. fileprivate let arkTSStackConstructor = ILType.constructor([] => arkTSStack) /// Type of the ArkTS HashMap constructor builtin. @@ -46,6 +56,9 @@ fileprivate let arkTSHashMapConstructor = ILType.constructor([] => arkTSHashMap) /// Type of the ArkTS HashMap constructor builtin. fileprivate let arkTSHashSetConstructor = ILType.constructor([] => arkTSHashSet) +/// Type of the ArkTs CollectionsMap constructor builtin. +fileprivate let collectionsMapConstructor = ILType.constructor([.object()] => collectionsMap) + /// ObjectGroup modelling ArkTS Stack objects fileprivate let arkTSStacks = ObjectGroup( name: "Stack", @@ -87,6 +100,26 @@ fileprivate let arkTSHashMaps = ObjectGroup( ] ) +///ObjectGroup modelling ArkTs Map objects +fileprivate let collectionsMaps = ObjectGroup( + name: "SharedMap", + instanceType: collectionsMap, + properties: [ + "size" : .number + ], + methods: [ + "entries" : [] => .object(), + "keys" : [] => .object(), + "values" : [] => .object(), + "clear" : [] => .undefined, + "delete" : [.anything] => .boolean, + "forEach" : [.function([.opt(.anything), .opt(.anything), .opt(collectionsMap)] => .undefined), .opt(.object())] => .undefined, + "get" : [.anything] => .anything, + "has" : [.anything] => .boolean, + "set" : [.anything, .anything] => collectionsMap, + ] +) + /// ObjectGroup modelling ArkTS HashSet objects fileprivate let arkTSHashSets = ObjectGroup( name: "HashSet", @@ -146,9 +179,10 @@ let arkProfile = Profile( crashTests: ["fuzzilli('FUZZILLI_CRASH', 0)", "fuzzilli('FUZZILLI_CRASH', 1)"], additionalCodeGenerators: [ - (PrintGenerator, 40), - (RunNearStackLimitGenerator, 5), - (ArkTSObjectInstanceGenerator, 20), + (PrintGenerator, 40), + (RunNearStackLimitGenerator, 5), + (ArkTSObjectInstanceGenerator, 20), + (ArkTSCollectionsObjectInstanceGenerator, 20), ], additionalProgramTemplates: WeightedList([]), @@ -170,12 +204,14 @@ let arkProfile = Profile( "bgc" : .function([] => .undefined), "Stack" : arkTSStackConstructor, "HashMap" : arkTSHashMapConstructor, + "SharedMap" : collectionsMapConstructor, "HashSet" : arkTSHashSetConstructor, ], additionalObjectGroups: [ arkTSStacks, arkTSHashMaps, + collectionsMaps, arkTSHashSets, ],