diff --git a/Packs/rasterize/Integrations/rasterize/rasterize.py b/Packs/rasterize/Integrations/rasterize/rasterize.py index b8fcbb23549b..1470403fa504 100644 --- a/Packs/rasterize/Integrations/rasterize/rasterize.py +++ b/Packs/rasterize/Integrations/rasterize/rasterize.py @@ -996,15 +996,21 @@ def rasterize_email_command(): # pragma: no cover navigation_timeout = int(demisto.args().get('max_page_load_time', DEFAULT_PAGE_LOAD_TIME)) - with open('htmlBody.html', 'w', encoding='utf-8-sig') as f: - f.write(f'{html_body}') - - path = f'file://{os.path.realpath(f.name)}' - - rasterize_output = perform_rasterize(path=path, rasterize_type=rasterize_type, width=width, height=height, - offline_mode=offline, navigation_timeout=navigation_timeout, full_screen=full_screen) - - res = fileResult(filename=file_name, data=rasterize_output[0][0]) + try: + with tempfile.NamedTemporaryFile(mode='w', suffix='.html', encoding='utf-8-sig') as tf: + demisto.debug(f'rasterize-email, {html_body=}') + tf.write(f'{html_body}') + tf.flush() + path = f'file://{os.path.realpath(tf.name)}' + demisto.debug(f'rasterize-email, rasterizing {path=}') + rasterize_output = perform_rasterize(path=path, rasterize_type=rasterize_type, width=width, height=height, + offline_mode=offline, navigation_timeout=navigation_timeout, + full_screen=full_screen) + + res = fileResult(filename=file_name, data=rasterize_output[0][0]) + except Exception as err: + demisto.error(str(err)) + return_error(f'Failed to rasterize email: {err}') if rasterize_type == RasterizeType.PNG or str(rasterize_type).lower() == RasterizeType.PNG.value: res['Type'] = entryTypes['image'] diff --git a/Packs/rasterize/ReleaseNotes/2_0_29.md b/Packs/rasterize/ReleaseNotes/2_0_29.md new file mode 100644 index 000000000000..83874150afd2 --- /dev/null +++ b/Packs/rasterize/ReleaseNotes/2_0_29.md @@ -0,0 +1,6 @@ + +#### Integrations + +##### Rasterize + +- Improved implementation of the *rasterize-email* command. diff --git a/Packs/rasterize/pack_metadata.json b/Packs/rasterize/pack_metadata.json index 7f904a5f9b81..203abfdc0301 100644 --- a/Packs/rasterize/pack_metadata.json +++ b/Packs/rasterize/pack_metadata.json @@ -2,7 +2,7 @@ "name": "Rasterize", "description": "Converts URLs, PDF files, and emails to an image file or PDF file.", "support": "xsoar", - "currentVersion": "2.0.28", + "currentVersion": "2.0.29", "author": "Cortex XSOAR", "url": "https://www.paloaltonetworks.com/cortex", "email": "",