
Security News
The Nightmare Before Deployment
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.
aws-lambda-context
Advanced tools
A micro library that provides the AWS Lambda Context class for type checking and testing.
.. code-block::
pip install aws-lambda-context
Import the LambdaContext on your handler file and type hint the lambda function with it:
.. code-block:: python
from aws_lambda_context import LambdaContext
def my_lambda_handler(event: Any, context: LambdaContext) -> None:
...
The type hint should enables type checking with mypy_ and editor auto-completion
The class is also useful as a mock during tests:
.. code-block:: python
from aws_lambda_context import (
LambdaClientContext,
LambdaClientContextMobileClient,
LambdaCognitoIdentity,
LambdaContext
)
def test_handler():
lambda_cognito_identity = LambdaCognitoIdentity()
lambda_cognito_identity.cognito_identity_id = 'cognito_identity_id'
lambda_cognito_identity.cognito_identity_pool_id = 'cognito_identity_pool_id'
lambda_client_context_mobile_client = LambdaClientContextMobileClient()
lambda_client_context_mobile_client.installation_id = 'installation_id'
lambda_client_context_mobile_client.app_title = 'app_title'
lambda_client_context_mobile_client.app_version_name = 'app_version_name'
lambda_client_context_mobile_client.app_version_code = 'app_version_code'
lambda_client_context_mobile_client.app_package_name = 'app_package_name'
lambda_client_context = LambdaClientContext()
lambda_client_context.client = lambda_client_context_mobile_client
lambda_client_context.custom = {'custom': True}
lambda_client_context.env = {'env': 'test'}
lambda_context = LambdaContext()
lambda_context.function_name = 'function_name'
lambda_context.function_version = 'function_version'
lambda_context.invoked_function_arn = 'invoked_function_arn'
lambda_context.memory_limit_in_mb = 'memory_limit_in_mb'
lambda_context.aws_request_id = 'aws_request_id'
lambda_context.log_group_name = 'log_group_name'
lambda_context.log_stream_name = 'log_stream_name'
lambda_context.identity = lambda_cognito_identity
lambda_context.client_context = lambda_client_context
assert handler({}, lambda_context) == 'something'
.. _mypy: http://mypy-lang.org/
FAQs
AWS Lambda Context class for type checking and testing
We found that aws-lambda-context demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Season’s greetings from Socket, and here’s to a calm end of year: clean dependencies, boring pipelines, no surprises.

Research
/Security News
Impostor NuGet package Tracer.Fody.NLog typosquats Tracer.Fody and its author, using homoglyph tricks, and exfiltrates Stratis wallet JSON/passwords to a Russian IP address.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.