diff --git a/Sources/FuzzilliCli/Profiles/XSProfile.swift b/Sources/FuzzilliCli/Profiles/XSProfile.swift index 502b63ac5..1947c7d4e 100644 --- a/Sources/FuzzilliCli/Profiles/XSProfile.swift +++ b/Sources/FuzzilliCli/Profiles/XSProfile.swift @@ -15,7 +15,6 @@ import Fuzzilli fileprivate let StressXSGC = CodeGenerator("StressXSGC", inputs: .required(.function())) { b, f in - guard b.type(of: f).Is(.function()) else { return } //@@ where did this come from?? let arguments = b.randomArguments(forCalling: f) let index = b.loadInt(1) @@ -26,15 +25,13 @@ fileprivate let StressXSGC = CodeGenerator("StressXSGC", inputs: .required(.func b.callFunction(f, withArgs: arguments) b.unary(.PostInc, index) let result = b.callFunction(gc, withArgs: [index]) - b.buildIfElse(result, ifBody: { + b.buildIf(result) { b.loopBreak(); - }, elseBody: { - }); + } } } fileprivate let StressXSMemoryFail = CodeGenerator("StressXSMemoryFail", inputs: .required(.function())) { b, f in - guard b.type(of: f).Is(.function()) else { return } //@@ where did this come from?? let arguments = b.randomArguments(forCalling: f) let index = b.loadInt(1) @@ -54,9 +51,9 @@ fileprivate let StressXSMemoryFail = CodeGenerator("StressXSMemoryFail", inputs: fileprivate let HardenGenerator = CodeGenerator("HardenGenerator", inputs: .required(.object())) { b, obj in let harden = b.loadBuiltin("harden") - if (Int.random(in: 0...20) < 1) { + if probability(0.05) { let lockdown = b.loadBuiltin("lockdown") - b.callFunction(lockdown, withArgs: []) + b.callFunction(lockdown) } b.callFunction(harden, withArgs: [obj]) } @@ -104,7 +101,7 @@ fileprivate let CompartmentGenerator = RecursiveCodeGenerator("CompartmentGenera options["loadNowHook"] = loadNowHook; options["loadHook"] = loadHook; - if (Int.random(in: 0...100) < 50) { + if probability(0.5) { options["globalLexicals"] = endowmentsObject endowmentsObject = b.createObject(with: [:]) } @@ -112,7 +109,7 @@ fileprivate let CompartmentGenerator = RecursiveCodeGenerator("CompartmentGenera let compartment = b.construct(compartmentConstructor, withArgs: [endowmentsObject, moduleMapObject, optionsObject]) - if (Int.random(in: 0...100) < 50) { + if probability(0.5) { let code = b.buildCodeString() { b.buildRecursive(block: 4, of: 4) } @@ -120,7 +117,7 @@ fileprivate let CompartmentGenerator = RecursiveCodeGenerator("CompartmentGenera } } -fileprivate let UnicodeStringGenerator = CodeGenerator("UnicodeStringGenerator", inputs: .required(.object())) { b, obj in +fileprivate let UnicodeStringGenerator = CodeGenerator("UnicodeStringGenerator") { b in var s = "" for _ in 0.. .jsCompartment) + .object(ofGroup: "CompartmentConstructor", withProperties: ["prototype"], withMethods: []) + static let jsCompartmentConstructor = ILType.constructor([.opt(.object()), .opt(.object()), .opt(.object())] => .jsCompartment) + .object(ofGroup: "CompartmentConstructor", withProperties: ["prototype"], withMethods: []) static let jsModuleSource = ILType.object(ofGroup: "ModuleSource", withProperties: ["bindings", "needsImport", "needsImportMeta"]) - static let jsModuleSourceConstructor = ILType.constructor([.function()] => .jsModuleSource) + .object(ofGroup: "ModuleSourceConstructor", withProperties: ["prototype"], withMethods: []) + static let jsModuleSourceConstructor = ILType.constructor([.opt(.string)] => .jsModuleSource) + .object(ofGroup: "ModuleSourceConstructor", withProperties: ["prototype"], withMethods: []) } /// Object group modelling JavaScript compartments. @@ -336,12 +408,15 @@ let xsProfile = Profile( ], additionalCodeGenerators: [ - (StressXSMemoryFail, 5), - (StressXSGC, 5), - (HardenGenerator, 5), - (CompartmentGenerator, 5), - (UnicodeStringGenerator, 2), - (ModuleSourceGenerator, 3) + (StressXSMemoryFail, 5), + (StressXSGC, 5), + (HardenGenerator, 5), + (CompartmentGenerator, 5), + (CompartmentEvaluateGenerator, 5), + (UnicodeStringGenerator, 2), + (ModuleSourceGenerator, 3), + (HexGenerator, 2), + (Base64Generator, 2), ], additionalProgramTemplates: WeightedList([ @@ -358,12 +433,12 @@ let xsProfile = Profile( "print" : .function([.string] => .undefined), // hardened javascript - "Compartment" : .function([] => .jsCompartmentConstructor), - "ModuleSource" : .function([] => .jsModuleSourceConstructor), - "harden" : .function([.plain(.anything)] => .undefined), + "Compartment" : .function([.opt(.object()), .opt(.object()), .opt(.object())] => .jsCompartmentConstructor), + "ModuleSource" : .function([.opt(.string)] => .jsModuleSourceConstructor), + "harden" : .function([.object()] => .object()), "lockdown" : .function([] => .undefined) , - "petrify" : .function([.plain(.anything)] => .undefined), - "mutabilities" : .function([.plain(.anything)] => .object()) + "petrify" : .function([.anything] => .anything), + "mutabilities" : .function([.object()] => .object()) ], additionalObjectGroups: [jsCompartments, jsCompartmentConstructor, jsModuleSources, jsModuleSourceConstructor],