From 2ad0b80253505bc3d29a64c65405c7df8818f208 Mon Sep 17 00:00:00 2001 From: Yi2255 Date: Thu, 14 Nov 2024 11:32:56 +0000 Subject: [PATCH] feature/void operator --- .../Fuzzilli/Base/JavaScriptLifterUtil.swift | 4 ++++ .../Fuzzilli/Lifting/JavaScriptLifter.swift | 19 ++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 Sources/Fuzzilli/Base/JavaScriptLifterUtil.swift diff --git a/Sources/Fuzzilli/Base/JavaScriptLifterUtil.swift b/Sources/Fuzzilli/Base/JavaScriptLifterUtil.swift new file mode 100644 index 000000000..6c340f9d6 --- /dev/null +++ b/Sources/Fuzzilli/Base/JavaScriptLifterUtil.swift @@ -0,0 +1,4 @@ + +func insertVoid() -> String{ + return probability(0.05) ? "void " : "" +} \ No newline at end of file diff --git a/Sources/Fuzzilli/Lifting/JavaScriptLifter.swift b/Sources/Fuzzilli/Lifting/JavaScriptLifter.swift index 240f3ea99..ae6a3b337 100644 --- a/Sources/Fuzzilli/Lifting/JavaScriptLifter.swift +++ b/Sources/Fuzzilli/Lifting/JavaScriptLifter.swift @@ -746,13 +746,14 @@ public class JavaScriptLifter: Lifter { // the function is a MemberExpression since it would otherwise be interpreted as a method call, not a function call. let f = inputAsIdentifier(0) let args = inputs.dropFirst() - let expr = CallExpression.new() + f + "(" + liftCallArguments(args) + ")" + let expr = CallExpression.new() + insertVoid() + f + "(" + liftCallArguments(args) + ")" w.assign(expr, to: instr.output) case .callFunctionWithSpread(let op): let f = inputAsIdentifier(0) let args = inputs.dropFirst() - let expr = CallExpression.new() + f + "(" + liftCallArguments(args, spreading: op.spreads) + ")" + let vo = probability(0.05) ? "void " : "" + let expr = CallExpression.new() + insertVoid() + f + "(" + liftCallArguments(args, spreading: op.spreads) + ")" w.assign(expr, to: instr.output) case .construct: @@ -773,28 +774,28 @@ public class JavaScriptLifter: Lifter { let obj = input(0) let method = MemberExpression.new() + obj + "." + op.methodName let args = inputs.dropFirst() - let expr = CallExpression.new() + method + "(" + liftCallArguments(args) + ")" + let expr = CallExpression.new() + insertVoid() + method + "(" + liftCallArguments(args) + ")" w.assign(expr, to: instr.output) case .callMethodWithSpread(let op): let obj = input(0) let method = MemberExpression.new() + obj + "." + op.methodName let args = inputs.dropFirst() - let expr = CallExpression.new() + method + "(" + liftCallArguments(args, spreading: op.spreads) + ")" + let expr = CallExpression.new() + insertVoid() + method + "(" + liftCallArguments(args, spreading: op.spreads) + ")" w.assign(expr, to: instr.output) case .callComputedMethod: let obj = input(0) let method = MemberExpression.new() + obj + "[" + input(1).text + "]" let args = inputs.dropFirst(2) - let expr = CallExpression.new() + method + "(" + liftCallArguments(args) + ")" + let expr = CallExpression.new() + insertVoid() + method + "(" + liftCallArguments(args) + ")" w.assign(expr, to: instr.output) case .callComputedMethodWithSpread(let op): let obj = input(0) let method = MemberExpression.new() + obj + "[" + input(1).text + "]" let args = inputs.dropFirst(2) - let expr = CallExpression.new() + method + "(" + liftCallArguments(args, spreading: op.spreads) + ")" + let expr = CallExpression.new() + insertVoid() + method + "(" + liftCallArguments(args, spreading: op.spreads) + ")" w.assign(expr, to: instr.output) case .unaryOperation(let op): @@ -951,11 +952,11 @@ public class JavaScriptLifter: Lifter { break case .callSuperConstructor: - let EXPR = CallExpression.new() + "super(" + liftCallArguments(inputs) + ")" + let EXPR = CallExpression.new() + insertVoid() + "super(" + liftCallArguments(inputs) + ")" w.emit("\(EXPR);") case .callSuperMethod(let op): - let expr = CallExpression.new() + "super.\(op.methodName)(" + liftCallArguments(inputs) + ")" + let expr = CallExpression.new() + insertVoid() + "super.\(op.methodName)(" + liftCallArguments(inputs) + ")" w.assign(expr, to: instr.output) case .getPrivateProperty(let op): @@ -981,7 +982,7 @@ public class JavaScriptLifter: Lifter { let obj = input(0) let method = MemberExpression.new() + obj + ".#" + op.methodName let args = inputs.dropFirst() - let expr = CallExpression.new() + method + "(" + liftCallArguments(args) + ")" + let expr = CallExpression.new() + insertVoid() + method + "(" + liftCallArguments(args) + ")" w.assign(expr, to: instr.output) case .getSuperProperty(let op):