Skip to content

Commit

Permalink
FIX: Allow unsafe eval through lambda function. If this parameter is …
Browse files Browse the repository at this point in the history
…set during class invocation, the Lambda function will be built the with proper environment variable.

NOTE: we need to pass the setting in to the lambda function to actually activate the unsafe evaluation
  • Loading branch information
mlshapiro committed Nov 5, 2019
1 parent ce8dd68 commit bbe251a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions podpac/core/managers/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def _session_default(self):
function_source_bucket = tl.Unicode(default_value="podpac-dist", allow_none=True).tag(readonly=True)
function_source_dist_key = tl.Unicode().tag(readonly=True) # see default below
function_source_dependencies_key = tl.Unicode().tag(readonly=True) # see default below
function_allow_unsafe_eval = tl.Bool(default_value=False).tag(readonly=True)
_function_arn = tl.Unicode(default_value=None, allow_none=True)
_function_last_modified = tl.Unicode(default_value=None, allow_none=True)
_function_version = tl.Unicode(default_value=None, allow_none=True)
Expand Down Expand Up @@ -495,11 +496,11 @@ def delete(self, confirm=False):
_log.info("Removing all cloud resources associated with this Lamba node")

if confirm:
self.remove_triggers()
self.delete_function()
self.delete_role()
self.delete_api()
self.delete_bucket(delete_objects=True)
self.remove_triggers()

def describe(self):
"""Show a description of the Lambda Utilities
Expand Down Expand Up @@ -634,6 +635,10 @@ def create_function(self):
if self.function_name is None:
raise AttributeError("Function name is not defined")

if self.function_allow_unsafe_eval:
_log.info("Lambda function will allow unsafe evaluation of Nodes with the current settings")
self.function_env_variables["PODPAC_UNSAFE_EVAL"] = settings["UNSAFE_EVAL_HASH"]

# if function already exists, this will return existing function
function = create_function(
self.session,
Expand Down Expand Up @@ -724,7 +729,7 @@ def add_trigger(self, statement_id, principle, source_arn):
source_arn : str
Source ARN for trigger
"""
add_trigger(self.session, self.function_name, statement_id, principle, source_arn)
add_function_trigger(self.session, self.function_name, statement_id, principle, source_arn)
self._function_triggers[statement_id] = source_arn

def remove_trigger(self, statement_id):
Expand Down Expand Up @@ -1761,7 +1766,7 @@ def delete_function(session, function_name):
_log.debug("Removed lambda function '{}'".format(function_name))


def add_trigger(session, function_name, statement_id, principle, source_arn):
def add_function_trigger(session, function_name, statement_id, principle, source_arn):
"""Add trigger (permission) to lambda function
Parameters
Expand Down

0 comments on commit bbe251a

Please sign in to comment.