IBM QRadar SOAR

IBM QRadar

Join this online topic group to communicate across Security product users and IBM experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#Security
#QRadar
#SecuringhybridcloudandAI
 View Only
  • 1.  How to extract plaintext from HTML in Script?

    Posted 04/02/19 01:49 PM
    ​Hello all - I would like to extract the plaintext equivalent from a marked-up (HTML? SGML?) field (resolution_summary) while working in the built-in, jython Script environment.

    This is the sort of thing I would do using html2text in more open Python settings but this appears not to be an available import.  I could use help in identifying how I might achieve this extraction.

    Thanks and regards.

    ------------------------------
    Edwin Bolton
    ------------------------------


  • 2.  RE: How to extract plaintext from HTML in Script?

    Posted 04/02/19 03:47 PM
    Hello Edwin,

    You can access the content of the "resolution_summary" field by adding "content" when referencing it.
    resolution_summary_content = incident.resolution_summary.content
    
    # You can also use the "helper" module
    
    resolution_summary_content = helper.createPlainText(incident.resolution_summary.content)
    Is this what you were looking for?

    ------------------------------
    Andrew Wadsworth
    ------------------------------



  • 3.  RE: How to extract plaintext from HTML in Script?

    Posted 04/03/19 07:02 AM
    Hello, Andrew and thanks for responding.​

    My objective is to preserve the current resolution summary as a Note before resetting it to a blank, in a Script that will be run from a Rule when the Status becomes Active - the best indicator of ticket re-opening that I can find.

    In essence:

    incident.addNote("Ticket reopened.  Previous Resolution Summary: {}".format(incident.resolution_summary.content))

    But the content of my new Note contains the markup tags from the Resolution Summary:

    Ticket reopened. Previous Resolution Summary: <div class="rte"><div>A possible resolution summary here...</div></div>

    So I already used incident.resolution_summary.content and also tried incident.resolution_summary["content"] but these output the content inclusive of Tags.

    I tried helper.createPlainText and this does not appear to help - I am unsure if it is needed for addNote and more significantly it also appears to pass through the tags unchanged.

    As I said, in an open Python environment, the html2text library would support the tag stripping I need to do but does not seem to be available in the internal, jython scripting environment provided within Resilient - so I am looking for an alternative.

    Best regards


    ------------------------------
    Edwin Bolton
    ------------------------------