Variable Step?

I had an idea for a new step and wanted to see if there would be enough support from the community to suggest it.

What I was thinking would be kind of a cross between an Artifact and a Pattern Match and should be really easy to implement.
The idea comes from the workaround where you use an Artifact to present a string. Say I’m using a step that has an output of an array and I just want the first instance as an array, I can create an Artifact with that multidimensional array and the content of that Artifact will be a string.
Sometimes I want to return one value if a variable is set and another if it isn’t, this works in a simple form in an Artifact, but some of the handlebar functions only work in a Decision Step.
Also, this only presents a string, what if I want to present an object, integers, or an array?
The other thing is with large Workflows this adds an Artifact that I might not care to see on the Job page.
The idea that I had would be some kind of Variable Step where you could either define an object that you could add a member or change a member to or do handlebar logic like in a decision step or just build some output like you do in a Pattern Match?
You could do this with some Actions, but for speed reasons it would be nice to not need an Orchestrator.

Some ideas that I had for uses:

  • You have a LDAP Action that returns one user, you want the attributes to be at the top level of the output for future use
  • You have the output of multiple Actions that you want to make into an array for a loop
  • You have an Action that has multiple members for its output and you want to add to that from another Action
  • You have multiple paths in a Decision Step that you want to present some wording differently depending on the path that will be used in an Artifact latter after a Join Step

If the Community thinks this would be useful Like this and if I get a bunch I’ll put in an official feature request.

2 Likes

Hey Brandon! Thanks for the suggestion!

I had a few follow up questions for you:

To be clear, are you asking to be able to access the first item in an array? Or is there some other way you’d like to handle arrays of data?

This is a really great idea - let me ask one clarifying question. Do you want something that lets you:

  1. Try to get a variable, and if it’s found to use it. But if it is not found, use a provided default that you specify
  2. Check if a variable exists, and if it is found to use a value you provide, and if it’s not found to use a different value you also provide

These are all good use cases for sure, have you seen our new updates around managing loop outputs? I think you could accomplish some of what you’re looking for by looping over the arrays and using the new output features while configuring the step.

You can find the documentation for it here: https://insightconnect.help.rapid7.com/docs/loop-step#access-loop-data

As well as a post about the release here: New Release: Easily Use Loop Data Throughout InsightConnect Workflows

There should be some in-product guidance when you log in as well.

Let us know if this helps, and the answers to your other feedback.

I use the Teams trigger looking for the line !Disable “”, I use a Pattern Match looking for /[a-zA-Z@-.]/ then in my next step I have an Artifact called [“User Name”] that has {{[“Pattern Match”].["words’].[1]}} the I can just use {{[“User Name”].[content]}} for this value (I have an open ticket with support because this would give me an error in a Decision Step {{[“Pattern Match”].["words’].[1]}} =~ /test/)

sudo example of building out an object for an Active Directory user with logic to switch “LastName, FirstName” to “FirstName LastName”:
{
“sAMAccountName”:{{[“LDAP”].[results].[0].[attributes].[sAMAccountName]}}
“distinguishedName”:{{[“LDAP”].[results].[0].[attributes].[distinguishedName]}}
“mail”:{{[“LDAP”].[results].[0].[attributes].[mail]}}
“displayName”:{{#if [“LDAP”].[results].[0].[attributes].[displayName] = “{{[“LDAP”].[results].[0].[attributes].[sn]}}, {{[“LDAP”].[results].[0].[attributes].[givenName]}}”}}"{{[“LDAP”].[results].[0].[attributes].[givenName]}} {{[“LDAP”].[results].[0].[attributes].[sn]}}"{{else}}"{{[“LDAP”].[results].[0].[attributes].[displayName]}}"{{/if}}
}

I did see the announcement for the Loop Outputs and haven’t had a change to try them yet, but that will definitely clean up some of my Artifact logic after Loops. I thought about a Loop before posting this but one issue that I had is I want to do the same sequence of Actions twice, once for the AD sAMAccountName then again for the mail. I did this with a Type Converter - String to List Action, but being on the Orchestrator this was slower than just defining the two variables in a JSON format.