Skip to content

Commit

Permalink
[sane-pdf-reports] - fix issue where large customer logos were not pa…
Browse files Browse the repository at this point in the history
…rsed correctly (#34862)

* test

* bla

* [SanePDFReport] - fix large logos

* docker-image

* bump rn

* pre-commit-shit

* docker image

* bump rn
  • Loading branch information
GuyAfik authored and barryyosi-panw committed Jun 25, 2024
1 parent e1b479c commit cf85e46
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
7 changes: 7 additions & 0 deletions Packs/Base/ReleaseNotes/1_34_16.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

#### Scripts

##### SanePdfReports

- Added support for large customer logos up to 5MB.
- Updated the Docker image to: *demisto/sane-pdf-reports:1.0.0.96883*.
15 changes: 11 additions & 4 deletions Packs/Base/Scripts/SanePdfReport/SanePdfReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def do_GET(self):


def main(): # pragma: no cover
isMDImagesSupported = is_demisto_version_ge(MD_IMAGE_SUPPORT_MIN_VER)
try:
sane_json_b64 = demisto.args().get('sane_pdf_report_base64', '').encode(
'utf-8')
Expand Down Expand Up @@ -196,6 +197,13 @@ def main(): # pragma: no cover
with open(input_file, 'wb') as f:
f.write(base64.b64decode(sane_json_b64))

if headerLeftImage:
customer_logo_file_path = tmpdir + "/customer-logo-base64.txt"
with open(customer_logo_file_path, "w") as f:
f.write(headerLeftImage)
extra_cmd = extra_cmd.replace(headerLeftImage, customer_logo_file_path)
headerLeftImage = customer_logo_file_path

cmd = ['./reportsServer', input_file, output_file, dist_dir] + shlex.split(
extra_cmd)

Expand All @@ -210,15 +218,14 @@ def main(): # pragma: no cover
if isMDImagesSupported:
params += f', markdownArtifactsServerAddress="{mdServerAddress}"'

LOG(f"Sane-pdf parameters: {params}]")
demisto.debug(f"Sane-PDF parameters: {params}]")
cmd_string = " ".join(cmd)
LOG(f"Sane-pdf cmd: {cmd_string}")
LOG.print_log()
demisto.debug(f'Sane-PDF report commmad: {cmd_string}')

# Execute the report creation
out = subprocess.check_output(cmd, cwd=WORKING_DIR,
stderr=subprocess.STDOUT)
LOG(f"Sane-pdf output: {str(out)}")
demisto.debug(f"Sane-pdf output: {str(out)}")

with open(output_file, 'rb') as f:
encoded = base64.b64encode(f.read()).decode('utf-8', 'ignore')
Expand Down
2 changes: 1 addition & 1 deletion Packs/Base/Scripts/SanePdfReport/SanePdfReport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ tags:
- pdf
timeout: '0'
type: python
dockerimage: demisto/sane-pdf-reports:1.0.0.95847
dockerimage: demisto/sane-pdf-reports:1.0.0.96883
runas: DBotWeakRole
tests:
- No Test
Expand Down
2 changes: 1 addition & 1 deletion Packs/Base/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Base",
"description": "The base pack for Cortex XSOAR.",
"support": "xsoar",
"currentVersion": "1.34.15",
"currentVersion": "1.34.16",
"author": "Cortex XSOAR",
"serverMinVersion": "6.0.0",
"url": "https://www.paloaltonetworks.com/cortex",
Expand Down

0 comments on commit cf85e46

Please sign in to comment.