Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rasterize-email-unique-file #37323

Merged
merged 17 commits into from
Nov 26, 2024
Merged
24 changes: 15 additions & 9 deletions Packs/rasterize/Integrations/rasterize/rasterize.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 style="background:white";>{html_body}</html>')

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 style="background:white";>{html_body}</html>')
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']
Expand Down
6 changes: 6 additions & 0 deletions Packs/rasterize/ReleaseNotes/2_0_29.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#### Integrations

##### Rasterize

- Improved implementation of the *rasterize-email* command.
2 changes: 1 addition & 1 deletion Packs/rasterize/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down
Loading