opensearch-project / reporting-cli

Apache License 2.0
4 stars 13 forks source link

[BUG] OpenSearch Reporting CLI Lambda always prepends "tmp" to email attachments #43

Closed aaronbrighton closed 6 months ago

aaronbrighton commented 1 year ago

What is the bug?

When using the OpenSearch Reporting CLI Lambda function, the filename for email attachments always has "tmp" prepended to the filename.

How can one reproduce the bug?

Follow the instructions here (https://opensearch.org/docs/latest/dashboards/reporting-cli/rep-cli-lambda/).

What is the expected behavior?

Attachment filename should look something like this: opensearch-report-2023-03-31T12-00-51.433Z instead of tmpopensearch-report-2023-03-31T12-00-51.433Z.

What is your host/environment?

N/A

Do you have any screenshots?

See description for observed behavior.

Do you have any additional context?

It appears the following code which defines where to temporarily save the file is being propagated to the email function that attaches the file to the email and incorporating the folder name "tmp" in the value:

https://github.com/opensearch-project/reporting-cli/blob/6feb950bff484e6c6ee3b75552c50c12c4a3f1a8/src/run.js#L13

https://github.com/opensearch-project/reporting-cli/blob/6feb950bff484e6c6ee3b75552c50c12c4a3f1a8/src/email-helpers.js#L111

Potentially easy fix by wrapping the value on line 111 above with path.basename()?

joshuali925 commented 1 year ago

i feel this was a workaround for current directory not writable but user can write to /tmp dir? @rupal-bq

rupal-bq commented 6 months ago

i feel this was a workaround for current directory not writable but user can write to /tmp dir? @rupal-bq

Yes. In Lambda we can write only to the /tmp.

https://repost.aws/questions/QUoCCNNS59RryAKeEBezXFcg/how-to-work-around-directory-permissions-in-aws-lambda