IBM QRadar SOAR

IBM QRadar SOAR

Join this online user 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.

 View Only
  • 1.  Jinja context in outbound email

    Posted Mon March 27, 2023 11:29 AM

    Hi there!

    I'm using the app Outbound email 2. My question is: 

    In normal python you can pass a context to a jinja2 template. can something similar be done here?

    Say, for example I want my template to reference a variable that was previously set on my script. Take this example:

    inputs.mail_to = "mail@mail.com"
    inputs.mail_incident_id = incident.id
    inputs.mail_subject = "TEST JINJA"
    inputs.mail_message_id = f"someid@resilient.ypf.com"
    foo = 3
    inputs.mail_inline_template ='''
    {{ foo }}
    '''

    I need to reference 'foo' inside the template. But this snippet of code gives error 'unknown foo in template line 2'. 

    Any idea how can this be done?



    ------------------------------
    Diego Mastrolorenzo
    ------------------------------


  • 2.  RE: Jinja context in outbound email

    Posted Tue April 25, 2023 03:23 AM

    I think you need to use something like set foo = 3

    this was a bit while ago , I don't remember exactly how I came up with this snippet but its working , hope it helps.

    {% set numOfAlarms = template_helper.get_incident_value(incident,'number_of_alarms') | int %}
    {% if numOfAlarms > 1 %}
    	{{ template_helper.get_datatable('log_r_events',template_helper.get_incident_value(incident,'id'))|safe}}
    {% endif %}


    ------------------------------
    mohamad islam hamadieh
    ------------------------------