Skip to content

Commit

Permalink
consumer input simple Context, Input
Browse files Browse the repository at this point in the history
  • Loading branch information
cschneider-vertical-relevance committed May 6, 2022
1 parent bc929d0 commit 1c7c44c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
3 changes: 3 additions & 0 deletions supplementary_files/handlers_stack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ get_approved_context(*,consumer_requested_context,authorization_header):
return consumer_requested_context # auto-approve for now, pending full implementation
```

### Input Analyzed Object

the object passed by the Consumer's request that is subject to PaC analysis

```
-i /tmp/input_analyzed_object.json \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,7 @@ def lambda_handler(event,context):

print(f'input_analyzed:\n{input_analyzed}')

consumer_metadata= request_json_body['ConsumerMetadata']

print(f'consumer_metadata:\n{consumer_metadata}')

# write eval enginge configuration to tmp
# write eval enginge configuration to tmp

approved_context_path = '/tmp/approved_context.json'

Expand All @@ -132,11 +128,15 @@ def lambda_handler(event,context):
)

# write ConsumerMetadata to /tmp

consumer_request_context= request_json_body['ConsumerRequestContext']

print(f'consumer_request_context:\n{consumer_request_context}')

consumer_metadata_path = '/tmp/consumer_metadata.json'

with open(consumer_metadata_path,'w') as f:
json.dump(consumer_metadata,f,indent=2)
json.dump(consumer_request_context,f,indent=2)

# write input_analyzed_object to /tmp

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def get_host(*,full_invoke_url):
m = re.search('https://(.*)/.*',full_invoke_url)
return m.group(1)

def get_approved_context(*,consumer_requested_context,authorization_header):
def get_approved_context(*,consumer_request_context,authorization_header):

# some Authz call

return consumer_requested_context # auto-approve for now, pending full implementation
return consumer_request_context # auto-approve for now, pending full implementation

def lambda_handler(event,context):

Expand Down Expand Up @@ -52,18 +52,18 @@ def lambda_handler(event,context):

print(f'BotoAWSRequestsAuth:\n{auth}')

consumer_requested_context = request_json_body['Metadata']['Context']
consumer_request_context = request_json_body['Context']

print(f'consumer_requested_context:\n{consumer_requested_context}')
print(f'consumer_request_context:\n{consumer_request_context}')

approved_context = get_approved_context(
consumer_requested_context = consumer_requested_context,
consumer_request_context = consumer_request_context,
authorization_header = authorization_header
)

eval_engine_input = {
"ConsumerMetadata":request_json_body['Metadata'],
"InputAnalyzed":request_json_body['InputAnalyzed'],
"ConsumerRequestContext":consumer_request_context,
"InputAnalyzed":request_json_body['Input'],
"EvalEngineConfiguration": {
"ApprovedContext":approved_context
}
Expand Down

0 comments on commit 1c7c44c

Please sign in to comment.