IBM QRadar SOAR

 View Only
Expand all | Collapse all

Outbound Email inline template macros

  • 1.  Outbound Email inline template macros

    Posted Wed October 04, 2023 03:58 PM

    Hey Community, 

    I'm attempting to adopt @Nick Mumaw's example email template written in CSS/HTML. The primary issue I'm running into is rendering macros within the inline email template in a playbook. 

    For example, I want to generate the incident URL within the email template using the V2 function, however, SOAR is unable to interpret the following macro as suggested in the app's documentation. 

    {% set inc_url = template_helper.generate_incident_url(incident.id) %}
    <a target='_blank' href='{ inc_url }'>{ incident.id }: { incident.name }</a>

     Are macros not supported for HTML formats? No issues implementing these in a standard jinja format.


    ------------------------------
    Nick B
    ------------------------------


  • 2.  RE: Outbound Email inline template macros

    Posted Thu October 05, 2023 05:17 AM

    Hi Nick,

    Are you are missing some curly braces in your template e.g .

    <a target='_blank' href='{{ inc_url }}'>{{ incident.id }}: {{ incident.name }}</a>



    ------------------------------
    JOHN PRENDERGAST
    ------------------------------



  • 3.  RE: Outbound Email inline template macros

    Posted Thu October 05, 2023 02:32 PM

    Hey John, 

    I appreciate the second pair of eyes on this -- yes, i've tried with both single and double braces. 

    Here's the specific error that is thrown by the playbook, 

    KeyError: '% set inc_url = template_helper'

    I did just try wrapping the macro command with double braces as well which allowed the function to execute:

    {{% set inc_url = template_helper.generate_incident_url(incident.id) %}}

    however, the inc url still doesn't get set with either single or double braces. 



    ------------------------------
    Nick B
    ------------------------------



  • 4.  RE: Outbound Email inline template macros

    Posted Mon October 09, 2023 02:10 PM

    Hey Nick!

    Looking this over, I wanted to point to my video that discusses that this is meant as an inline HTML template not a Jinja template that can be filled in from the macros using the Jinja templates. This means that the way you will fill this out would be the standard <python_string>.format(<variables>) method. I have not done a lot with the Jinja templates to understand how to do that, but I can look into these if you are wanting to use the template in that way. I just can't tell you when that will be ready. Give me a little time to try to figure that out for you!

    If you want me to create a simple playbook to show how to use the template currently I can do that quicker as I already have that existing!

    Thanks!



    ------------------------------
    Nick Mumaw, GPEN, GPYC
    Cyber Security Specialist - SOAR
    IBM - Security
    ------------------------------



  • 5.  RE: Outbound Email inline template macros

    Posted Tue October 10, 2023 12:04 AM
    Edited by Nick Mumaw Tue October 17, 2023 10:40 PM

    I have created a new template that will work with inline. Check the link. If you want to customize the template at all, change lines between 328 and 350. This is where you will be able to add your own fields and such like John mentioned above.

    Thanks!



    ------------------------------
    Nick Mumaw, GPEN, GPYC
    Cyber Security Specialist - SOAR
    IBM - Security
    ------------------------------



  • 6.  RE: Outbound Email inline template macros

    Posted Tue October 17, 2023 05:26 PM

    Thanks a lot for your help, Nick. Your videos are super helpful. 

    The template worked out great, looks like I just needed to add the macros and drop the .format portion at the end of the script. The only issue I'm running into now is incorporating the notes macro in the template. 



    ------------------------------
    Nick B
    ------------------------------



  • 7.  RE: Outbound Email inline template macros

    Posted Wed October 18, 2023 01:00 AM

    Sounds good. Started playing around again with the templates since you asked and I created a few more which include both Notes and Artifacts. It appears that there is capability to do dataTables too, but I am currently missing something on that. When I get that template created, I will upload it to the GitHub as well. But for now check out my templates here.

    https://github.com/TheIRGurus/Playbooks/tree/main/Outbound%20Email%20Playbooks



    ------------------------------
    Nick Mumaw, GPEN, GPYC
    Cyber Security Specialist - SOAR
    IBM - Security
    ------------------------------



  • 8.  RE: Outbound Email inline template macros

    Posted Wed October 18, 2023 03:54 PM

    Hey Nick, Thanks for your response. 

    So, I ended up doing exactly what you did in your notes template. Unfortunately, it throws a nonetype error (no attribute 'lower') which isn't present when using the other macros.



    ------------------------------
    Nick B
    ------------------------------



  • 9.  RE: Outbound Email inline template macros

    Posted Fri October 20, 2023 06:02 PM

    Sorry, Just saw this. But have you checked the version of your app to make sure that it is the most recent version? I have tested all of the templates and have got this working. I do plan on releasing a follow up video next week about template building using the Jinja files next week. Hopefully that will help?!



    ------------------------------
    Nick Mumaw, GPEN, GPYC
    Cyber Security Specialist - SOAR
    IBM - Security
    ------------------------------