Skip to content

Commit

Permalink
rasterize-email-unique-file (#37323)
Browse files Browse the repository at this point in the history
* rasterize-email-unique-file

* rn

* typo

* rn

* fix conflicts

* use tempFile with context manager

* remove comment

* CR fixes

* fixes

* fix build failure

* pre-commit fixes

* pre-commit fixes

* remove incident logs

---------

Co-authored-by: meichler <[email protected]>
Co-authored-by: Moshe Eichler <[email protected]>
  • Loading branch information
3 people authored Nov 26, 2024
1 parent 25b2ada commit ba57df4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
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

0 comments on commit ba57df4

Please sign in to comment.