How to Format Python 3 Script Function in Workflow

Hi,

Looking for a bit of help with how to format the Python 3 Script functions in a Rapid7 Workflow. I’m looking to take two inputs which are arrays containing a single string each (One is the sender domain of an email, and the other is the envelope-from domain of an email), convert each array into a string and see if they match.

def run(params={}):
senderArr = params.get(‘senderArr’)
senderString = ‘’.join(senderArr)
envelopeArr = params.get(‘envelopeArr’)
envelopeString = ‘’.join(envelopeArr)
stringMatch = senderString==envelopeString
return {‘match’: match}

Input: {“senderArr”:“{{["Extract Envelope-From Domain"].[EnvelopeFromDomain]}}”,“envelopeArr”:“{{["Extract Envelope-From Domain"].[EnvelopeFromDomain]}}”}

When this runs though, it looks as if the input isn’t making its way into the params of the function so it’s not running properly. Am I missing something with my syntax?

Hey Ross,

Can you try naming your variables differently from your inputs, for example:
senderArr1 = params.get(‘senderArr’)

Then let us know the outcome.

Cheers!

Try escaping the double quotes inside the input json as below.

Input: {“senderArr”:“{{[\"Extract Envelope-From Domain\"].[EnvelopeFromDomain]}}”,“envelopeArr”:“{{[\"Extract Envelope-From Domain\"].[EnvelopeFromDomain]}}”}