
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@itcutives/serverless-helpers
Advanced tools
Serverless Request/Response Handlers
Request
, Response
, and LambdaResponseFormatter
Require
const Request = require('@itcutives/serverless-helpers/src/request');
const Response = require('@itcutives/serverless-helpers/src/response');
const LambdaResponseFormatter = require('@itcutives/serverless-helpers/src/lambdaResponseFormatter');
Usage
module.exports.handler = async () => {
const request = REQ.normaliseLambdaRequest(event);
const response = new RES();
try {
//... open db connection, handle request etc ...
const resp = await handleEvent(request, response);
// response.respond(<status-code>, <response-body>, <headers>);
// eg. response.respond(200, JSON.stringify({test: 1}), { 'content-type': 'application/json' });
return LambdaResponseFormatter.responseHandler(resp);
} catch (e) {
return LambdaResponseFormatter.errorHandler(e);
}
};
LambdaResponseFormatter
middlewareTo handle the clean up operations before responding. such as close db connection etc...
const LambdaResponseFormatter = require('@itcutives/serverless-helpers/src/lambdaResponseFormatter');
class ResponseHandler extends LambdaResponseFormatter {
static async middleware(response) {
// add remove header etc.
// close db connection
return true;
}
}
module.exports = ResponseHandler;
Once you have above, your handler
function should use ResponseHandler
class instead of LambdaResponseFormatter
Require
const boomToJsonAPI = require('@itcutives/serverless-helpers/src/boom-to-jsonapi');
Unclassified Error
boomToJsonAPI(new Error('random error'));
// {
// errors: [{
// status: '500',
// title: 'Internal Server Error',
// detail: 'An internal server error occurred',
// code: undefined
// }]
// }
Boom Error
boomToJsonAPI(Boom.badRequest('BAD Request'));
// {
// errors: [{
// status: '400',
// title: 'Bad Request',
// detail: 'BAD Request',
// code: undefined
// }]
// }
Boom Error with Code
boomToJsonAPI(Boom.badRequest('CODE :Some Error:it happened'));
// {
// errors: [{
// status: '400',
// title: 'Bad Request',
// detail: 'Some Error:it happened',
// code: 'CODE'
// }]
// }
cd example
# install dependencies
npm i
# run api offline
npm run offline
to see Success Response: http://localhost:3000/v1/success
to see Error Response: http://localhost:3000/v1/error
FAQs
Serverless Helper Functions
The npm package @itcutives/serverless-helpers receives a total of 1 weekly downloads. As such, @itcutives/serverless-helpers popularity was classified as not popular.
We found that @itcutives/serverless-helpers demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.