runThen(SetVariable, myObject) - what is the right object format? #23
-
I've a variable ('myGlobalTokenResponseBody') containing this JSON response: {"access_token":"token-Miguel","token_type":"Bearer","expires_in":1799} Although I can use a "Set Variable" Then to do it, I would like to use part of a script, so I've set this object: const mySetVariable = { and tried to execute: Reshaper.event.runThen('SetVariable', mySetVariable); |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Sorry, clicked sent without completing the message. I got this error: { "message" : "Failure running rule", "exception" : "Wrapped synfron.reshaper.burp.core.exceptions.WrappedException: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot coerce empty String (\"\") to `synfron.reshaper.burp.core.messages.MessageValue` value (but could if coercion was enabled using `CoercionConfig`)\n at [Source: (String)\"{\"text\":\"{\\\"access_token\\\":\\\"token-Miguel\\\",\\\"token_type\\\":\\\"Bearer\\\",\\\"expires_in\\\":1799}\",\"useMessageValue\":false,\"sourceMessageValueType\":\"JSON\",\"sourceIdentifier\":\"\",\"sourceMessageValuePath\":\"access_token\",\"sourceMessageValue\":\"\",\"useReplace\":false,\"regexPattern\":\"\",\"replacementText\":\"\",\"destinationMessageValueType\":\"\",\"destinationMessageValuePath\":\"\",\"targetSource\":\"Global\",\"variableName\":\"NewToken2\",\"@class\":\".ThenSetVariable\"}\"; line: 1, column: 419] (through reference chain: synfron.reshaper.burp.core.rules.thens.ThenSetVariable[\"sourceMessageValue\"]) (#68)\norg.mozilla.javascript.WrappedException: Wrapped synfron.reshaper.burp.core.exceptions.WrappedException: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot coerce empty String (\"\") to `synfron.reshaper.burp.core.messages.MessageValue` value (but could if coercion was enabled using `CoercionConfig`)\n at [Source: (String)\"{\"text\":\"{\\\"access_token\\\":\\\"token-Miguel\\\",\\\"token_type\\\":\\\"Bearer\\\",\\\"expires_in\\\":1799}\",\"useMessageValue\":false,\"sourceMessageValueType\":\"JSON\",\"sourceIdentifier\":\"\",\"sourceMessageValuePath\":\"access_token\",\"sourceMessageValue\":\"\",\"useReplace\":false,\"regexPattern\":\"\",\"replacementText\":\"\",\"destinationMessageValueType\":\"\",\"destinationMessageValuePath\":\"\",\"targetSource\":\"Global\",\"variableName\":\"NewToken2\",\"@class\":\".ThenSetVariable\"}\"; line: 1, column: 419] (through reference chain: synfron.reshaper.burp.core.rules.thens.ThenSetVariable[\"sourceMessageValue\"]) (#68)\n\tat org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1899)\n\tat org.mozilla.javascript.MemberBox.invoke(MemberBox.java:160)\n\tat org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:226)\n\tat org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:55)\n\tat org.mozilla.javascript.gen._cmd__5._c_script_0(:68)\n\tat org.mozilla.javascript.gen._cmd__5.call()\n\tat org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:412)\n\tat org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3578)\n\tat org.mozilla.javascript.gen._cmd__5.call()\n\tat org.mozilla.javascript.gen._cmd__5.exec()\n\tat org.mozilla.javascript.Context.evaluateString(Context.java:1234)\n\tat synfron.reshaper.burp.core.rules.thens.ThenRunScript.lambda$perform$0(ThenRunScript.java:25)\n\tat synfron.reshaper.burp.core.rules.thens.entities.script.Dispatcher.lambda$getRunner$0(Dispatcher.java:53)\n\tat java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)\n\tat java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)\n\tat java.base/java.lang.Thread.run(Thread.java:831)\nCaused by: synfron.reshaper.burp.core.exceptions.WrappedException: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot coerce empty String (\"\") to `synfron.reshaper.burp.core.messages.MessageValue` value (but could if coercion was enabled using `CoercionConfig`)\n at [Source: (String)\"{\"text\":\"{\\\"access_token\\\":\\\"token-Miguel\\\",\\\"token_type\\\":\\\"Bearer\\\",\\\"expires_in\\\":1799}\",\"useMessageValue\":false,\"sourceMessageValueType\":\"JSON\",\"sourceIdentifier\":\"\",\"sourceMessageValuePath\":\"access_token\",\"sourceMessageValue\":\"\",\"useReplace\":false,\"regexPattern\":\"\",\"replacementText\":\"\",\"destinationMessageValueType\":\"\",\"destinationMessageValuePath\":\"\",\"targetSource\":\"Global\",\"variableName\":\"NewToken2\",\"@class\":\".ThenSetVariable\"}\"; line: 1, column: 419] (through reference chain: synfron.reshaper.burp.core.rules.thens.ThenSetVariable[\"sourceMessageValue\"])\n\tat synfron.reshaper.burp.core.utils.Serializer.deserialize(Serializer.java:106)\n\tat synfron.reshaper.burp.core.rules.thens.entities.script.ReshaperObj$EventObj.runThen(ReshaperObj.java:138)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat java.base/java.lang.reflect.Method.invoke(Method.java:567)\n\tat org.mozilla.javascript.MemberBox.invoke(MemberBox.java:138)\n\t... 17 more\nCaused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot coerce empty String (\"\") to `synfron.reshaper.burp.core.messages.MessageValue` value (but could if coercion was enabled using `CoercionConfig`)\n at [Source: (String)\"{\"text\":\"{\\\"access_token\\\":\\\"token-Miguel\\\",\\\"token_type\\\":\\\"Bearer\\\",\\\"expires_in\\\":1799}\",\"useMessageValue\":false,\"sourceMessageValueType\":\"JSON\",\"sourceIdentifier\":\"\",\"sourceMessageValuePath\":\"access_token\",\"sourceMessageValue\":\"\",\"useReplace\":false,\"regexPattern\":\"\",\"replacementText\":\"\",\"destinationMessageValueType\":\"\",\"destinationMessageValuePath\":\"\",\"targetSource\":\"Global\",\"variableName\":\"NewToken2\",\"@class\":\".ThenSetVariable\"}\"; line: 1, column: 419] (through reference chain: synfron.reshaper.burp.core.rules.thens.ThenSetVariable[\"sourceMessageValue\"])\n\tat com.fasterxml.jackson.databind.exc.InvalidFormatException.from(InvalidFormatException.java:67)\n\tat com.fasterxml.jackson.databind.DeserializationContext.reportBadCoercion(DeserializationContext.java:1806)\n\tat com.fasterxml.jackson.databind.deser.std.StdDeserializer._checkCoercionFail(StdDeserializer.java:1443)\n\tat com.fasterxml.jackson.databind.deser.std.EnumDeserializer._deserializeAltString(EnumDeserializer.java:306)\n\tat com.fasterxml.jackson.databind.deser.std.EnumDeserializer._fromString(EnumDeserializer.java:231)\n\tat com.fasterxml.jackson.databind.deser.std.EnumDeserializer.deserialize(EnumDeserializer.java:198)\n\tat com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:138)\n\tat com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:313)\n\tat com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:214)\n\tat com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:186)\n\tat com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:144)\n\tat com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:110)\n\tat com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeWithType(BeanDeserializerBase.java:1292)\n\tat com.fasterxml.jackson.databind.deser.impl.TypeWrappedDeserializer.deserialize(TypeWrappedDeserializer.java:74)\n\tat com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:322)\n\tat com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4674)\n\tat com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3629)\n\tat com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3597)\n\tat synfron.reshaper.burp.core.utils.Serializer.deserialize(Serializer.java:104)\n\t... 23 more\n", "payload" : "\tat :68\n" } So I'm pretty sure something in my construction is wrong. Any help welcome! |
Beta Was this translation helpful? Give feedback.
-
Got it working, it was like this: const mySetVariable = { Next time I'll try harder before asking hehehe. |
Beta Was this translation helpful? Give feedback.
-
Two more options:
FYI, in case this is useful later, the same fields in the UI that support variable tags also support them when using
|
Beta Was this translation helpful? Give feedback.
Two more options:
sourceMessageValue
is not needed (becauseuseMessageValue
is false) in your use case, you can specifynull
or exclude the property entirely rather than using empty string. Given the other defaults as well, the below should be all you need.FYI, in case this is useful later, the same fields in the UI that support variable tags also support them when using
Reshaper.event.runThen
. So if you set themyGlobalTok…