Skip to content

Commit

Permalink
Applying suggestion from PR Review, refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
bbielinski-splunk committed Dec 11, 2023
1 parent 9a1c9e8 commit 6cb03bd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
1 change: 0 additions & 1 deletion smtp.json
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,6 @@
}
}
],
"pip_dependencies": {},
"pip39_dependencies": {
"wheel": [
{
Expand Down
15 changes: 5 additions & 10 deletions smtp_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,19 +693,14 @@ def _add_attachments(self, outer, attachments, action_result, message_encoding):
return action_result.set_status(phantom.APP_ERROR, SMTP_ERROR_SMTP_SEND_EMAIL)

phantom_home_path = self.get_phantom_home()
report_dir_pre_4_0 = os.path.join(phantom_home_path, "www", "reports")
report_dir_post_4_0 = os.path.join(phantom_home_path, "vault", "reports")
report_dir = os.path.join(phantom_home_path, "vault", "reports")

filename = ''
for report_dir in (report_dir_post_4_0, report_dir_pre_4_0):
test_filename = os.path.join(report_dir, attachment_vault_id)
test_filename = os.path.abspath(test_filename)
test_filename = os.path.join(report_dir, attachment_vault_id)
test_filename = os.path.abspath(test_filename)

if os.path.isfile(test_filename):
filename = test_filename
break
filename = test_filename if os.path.isfile(test_filename) else ""

is_valid_path = filename.startswith(report_dir_pre_4_0) or filename.startswith(report_dir_post_4_0)
is_valid_path = filename.startswith(report_dir)

if not filename or not is_valid_path:
return action_result.set_status(phantom.APP_ERROR, SMTP_ERROR_SMTP_SEND_EMAIL)
Expand Down

0 comments on commit 6cb03bd

Please sign in to comment.