Skip to content

Instantly share code, notes, and snippets.

@gyrospectre
Created October 4, 2021 01:33
Show Gist options
  • Save gyrospectre/df3fcfbdda2e075c2fcba1807ef40fb1 to your computer and use it in GitHub Desktop.
Save gyrospectre/df3fcfbdda2e075c2fcba1807ef40fb1 to your computer and use it in GitHub Desktop.
def get_entrypoint():
stack = inspect.stack()
entrypoint = {
'filename': stack[-1].filename,
'code_context': stack[-1].code_context
}
return entrypoint
def check_entrypoint():
entrypoint = get_entrypoint()
LOGGER.info(json.dumps(entrypoint))
entry_file = entrypoint.get('filename')
if not entry_file.startswith('/var/runtime/'):
msg = f'Runtime has been tampered with, aborting! File: {entry_file}'
LOGGER.critical(msg)
raise Exception(msg)
def handler(event, context):
try:
check_entrypoint()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment