FortiSOAR Knowledge Base
FortiSOAR: Security Orchestration and Response software provides innovative case management, automation, and orchestration. It pulls together all of an organization's tools, helps unify operations, and reduce alert fatigue, context switching, and the mean time to respond to incidents.
RuiChang
Staff
Staff
Article Id 297819
Description

 

This article describes how to avoid emojis in Python code output when using the Code Snippet connector. The same application can be applied to any playbook when an emoji is in the string and requires further action.

 

Scope

 

FortiSOAR.

 

Solution

 

In FortiSOAR Code Snippet is commonly used to process strings from logs or content from other connectors. In some cases, emoji may be present in the string especially for users from IOS or Android.

 

For this example, the Python code below is applied in Code Snippet:

 

RuiChang_0-1707186496813.png

 

As result, the error below will appear:

 

"500 Server Error: Internal Server Error for url: https://localhost:9595/integration/execute/?format=json :: \n<!doctype html>\n<html lang=\"en\">\n<head>\n  <title>Server Error (500)</title>\n</head>\n<body>\n  <h1>Server Error (500)</h1><p></p>\n</body>\n</html>\n"

 

RuiChang_0-1707186512755.png

 

To parse the emoji in the Jinja2 and JSON, additional lines below are required to escape ASCII characters:

 

print(json.dumps(test, ensure_ascii=False))

 

RuiChang_0-1707186539385.png

 

Successful results as below:

 

RuiChang_0-1707186557612.png

Contributors