Security News
Highlights from the 2024 Rails Community Survey
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
@middy/function-shield
Advanced tools
FunctionShield middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda
⚠️ Warning: FunctionShield is no longer actively maintained and will unlikely be updated to have Node.js v12 support. See #460 ⚠️
Hardens AWS Lambda execution environment:
/tmp
is a bad practice as it may be leaked in subsequent invocationsMore info:
Please visit: https://www.puresec.io/function-shield-token-form
'block'
- Block and log to Cloudwatch Logs'alert'
- Allow and log to Cloudwatch Logs'allow'
- Allowpolicy.outbound_connectivity
- 'block'/'alert'/'allow'
(default: 'block'
)policy.read_write_tmp
- 'block'/'alert'/'allow'
(default: 'block'
)policy.create_child_process
- 'block'/'alert'/'allow'
(default: 'block'
)policy.read_handler
- 'block'/'alert'/'allow'
(default: 'block'
)token
- By default looks for FUNCTION_SHIELD_TOKEN
in process.env
and context
disable_analytics
- Periodically, during cold starts, FunctionShield sends basic analytics information to its backend. To disable analytics module set: true
. (default: false
)'use strict';
const fs = require('fs');
const middy = require('middy');
const {ssm, functionShield} = require('middy/middlewares');
async function hello(event) {
fs.openSync('/tmp/test', 'w');
}
const handler = middy(hello)
.use(ssm({
cache: true,
setToContext: true,
names: {
FUNCTION_SHIELD_TOKEN: 'function_shield_token'
}
}))
.use(functionShield(
{
policy: {
outbound_connectivity: 'alert'
}
}
));
module.exports = {
handler
};
START RequestId: f7b7305d-d785-11e8-baf1-9136b5c7aa75 Version: $LATEST
[TOKEN VERIFICATION] license is OK
{"function_shield":true,"policy":"read_write_tmp","details":{"path":"/tmp/test"},"mode":"block"}
2018-10-24 15:11:45.427 (+03:00) f7b7305d-d785-11e8-baf1-9136b5c7aa75 {"errorMessage":"Unknown system error -999: Unknown system error -999, open '/tmp/test'","errorType":"Error","stackTrace":["Object.fs.openSync (fs.js:646:18)","Function.hello (/var/task/handler.js:8:6)","runMiddlewares (/var/task/node_modules/middy/src/middy.js:180:42)","runNext (/var/task/node_modules/middy/src/middy.js:85:14)","before (/var/task/node_modules/middy/src/middlewares/functionShield.js:20:5)","runNext (/var/task/node_modules/middy/src/middy.js:70:24)","<anonymous>","process._tickDomainCallback (internal/process/next_tick.js:228:7)"]}
END RequestId: f7b7305d-d785-11e8-baf1-9136b5c7aa75
REPORT RequestId: f7b7305d-d785-11e8-baf1-9136b5c7aa75 Duration: 458.65 ms Billed Duration: 500 ms Memory Size: 1024 MB Max Memory Used: 38 MB
For more documentation and examples, refers to the main Middy monorepo on GitHub or Middy official website.
Everyone is very welcome to contribute to this repository. Feel free to raise issues or to submit Pull Requests.
Licensed under MIT License. Copyright (c) 2017-2018 Luciano Mammino and the Middy team.
FAQs
Hardens AWS Lambda execution environment
The npm package @middy/function-shield receives a total of 15 weekly downloads. As such, @middy/function-shield popularity was classified as not popular.
We found that @middy/function-shield demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 11 open source maintainers 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
A record 2,709 developers participated in the 2024 Ruby on Rails Community Survey, revealing key tools, practices, and trends shaping the Rails ecosystem.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.