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

Add ability to encrypt excel files [SC-SC-203035] #14

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [Version 1.0.2](https://github.com/dataiku/dss-plugin-sendmail/releases/tag/v1.0.2) - Feature release - 2024-05

- Features added
- Ability to specify a password to encrypt Excel files

## [Version 1.0.1](https://github.com/dataiku/dss-plugin-sendmail/releases/tag/v1.0.1) - Feature release - 2024-04

- Recipe configurations saved in version 1.0.0 with "Attachments format" set to "Nothing selected" will no longer send CSV attachments.
Expand Down
8 changes: 8 additions & 0 deletions custom-recipes/send-mails-from-contacts-dataset/recipe.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,14 @@
"description" : "File format for attachments"
},

{
"name": "encryption_password_excel",
"label" : "Encryption password",
"type": "PASSWORD",
"description" : "(Optional) Password to encrypt excel files, requires DSS 13.0 or above",
"visibilityCondition" : "model.attachment_type == 'excel_can_ac'"
},

{
"name": "sep_cond_format",
"label": "Conditional formatting",
Expand Down
3 changes: 2 additions & 1 deletion custom-recipes/send-mails-from-contacts-dataset/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def does_channel_have_sender(channel_id):
channel_has_sender = does_channel_have_sender(mail_channel)

attachment_type = config.get('attachment_type', "send_no_attachments")
encryption_password_excel = config.get('encryption_password_excel', None)

# Validation part 1 - Check some kind of value/column exists for body, subject, sender and recipient

Expand Down Expand Up @@ -139,7 +140,7 @@ def does_channel_have_sender(channel_id):
output_schema.append({'name': 'sendmail_error', 'type': 'string'})
output.write_schema(output_schema)

attachment_files = build_attachment_files(attachment_datasets, attachment_type, apply_coloring_excel)
attachment_files = build_attachment_files(attachment_datasets, attachment_type, apply_coloring_excel, encryption_password_excel)

attachments_templating_dict = attachments_template_dict(attachment_datasets, project_key, apply_coloring_excel)

Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "sendmail",
"version": "1.0.1",
"version": "1.0.2",
"meta": {
"label": "Send emails",
"description": "Send emails based on a dataset containing a list of contacts, with optional attachments (other datasets)",
Expand Down
6 changes: 5 additions & 1 deletion python-lib/dku_attachment_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def attachments_template_dict(attachment_datasets, home_project_key, apply_color
return attachments_dict


def build_attachment_files(attachment_datasets, attachment_type, apply_coloring_excel):
def build_attachment_files(attachment_datasets, attachment_type, apply_coloring_excel, encryption_password_excel):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to add param to docstring

"""
:param attachment_datasets: List of attachment datasets
:param attachment_type: str, e.g. "excel", "csv" - "excel_can_ac" is treated as excel, "send_no_attachments" means none
Expand All @@ -54,6 +54,10 @@ def build_attachment_files(attachment_datasets, attachment_type, apply_coloring_
request_fmt = "excel"
if apply_coloring_excel and attachment_type == "excel_can_ac":
format_params = {"applyColoring": True}
if encryption_password_excel:
if format_params is None:
format_params = {}
format_params["password"] = encryption_password_excel
else:
request_fmt = "tsv-excel-header"

Expand Down