Thanks a lot.
I have used below script and working fine for me.
import re
s = incident.description.content
plain_body = re.compile(r'(<([^>]+)>)', re.IGNORECASE | re.MULTILINE ).sub("\n", s).strip()
des = re.match('(([\w\s.-]+):([\s\w\.-]+))', plain_body)
des_incident = des.group(3)
incident.properties.incident_desc = des_incident
log.info(des_incident)
Regards
Abhishek
------------------------------
Abhishek Mahadik
------------------------------
Original Message:
Sent: Tue April 02, 2019 03:09 PM
From: Andrew Wadsworth
Subject: Need to capture the specific data from one field to another field
Hello Abhishek,
The in-product scripting is fairly limited and only certain libraries and functions are available.
Here are some resources you may find useful:
Example scripts:
https://success.resilientsystems.com/hc/en-us/articles/115001805365-In-Product-Script-Examples
Use Cases:
https://developer.ibm.com/security/resilient/scripts/
I have also attached the Playbook Designer Guide which goes into some details of the Scripts as well.
In response to what you are trying to do, one option would be to use the "re" library which is avaiable in this context.
See Example below:
import re description_pieces = re.search('(\S.+\S)\s*:\s*(\S.+\S)', incident.description.content)if description_pieces: description_1 = description_pieces.group(1) description_2 = description_pieces.group(2) log.info("1" + description_1) log.info("2" + description_2)I hope this helps.
------------------------------
Andrew Wadsworth
Original Message:
Sent: Tue April 02, 2019 04:22 AM
From: Abhishek Mahadik
Subject: Need to capture the specific data from one field to another field
I am working on the requirement to remove below information before a creating incident in the service now.
* "Short Description" is having extra sub strings [ex: INC0011372 - 10 events 0 flows magnitude 3 : Firewall Accept by External Host Watchlistn containing Firewall Permitn].
I am trying to use the script module of resilient script to divide the string in the two parts separated by the : and capture the second string in the new field i.e. incident.properties.description.
but it seems split and many other library are missing in the resilient script module.
Expected output - Firewall Accept by External Host Watchlistn containing Firewall Permitn
Sample code -
s = incident.description
if s is None:
log.info("No description.")
elif s.format == "text":
log.info("Description is text: {}".format(s.content))
else:
abc = log.info("{}".format(s.content))
print abc
x = abc.split(":", 1)
print x – just for testing – idea to capture and write using below command.
incident.properties.incident_description(helper.createRichText("{}".format(x.content)))
Can you please share if document is available to get more details on the available library and functions.
------------------------------
Abhishek Mahadik
------------------------------