New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

serverless-log-forwarding

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

serverless-log-forwarding - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

10

index.js

@@ -40,2 +40,3 @@ const _ = require('underscore');

}
const filterPattern = service.custom.logForwarding.filterPattern || '';
// Get options and parameters to make resources object

@@ -63,3 +64,3 @@ const serviceName = service.service;

const subscriptionFilter = LogForwardingPlugin.makeSubscriptionFilter(serviceName,
stage, arn, functions[i]);
stage, arn, functions[i], filterPattern);
_.extend(resourceObj, subscriptionFilter);

@@ -77,5 +78,6 @@ }

* @param {String} functionName name of function to make SubscriptionFilter for
* @return {Object} SubscriptionFilter
* @param {String} filterPattern filter pattern for the Subscription
* @return {Object} SubscriptionFilter
*/
static makeSubscriptionFilter(serviceName, stage, arn, functionName) {
static makeSubscriptionFilter(serviceName, stage, arn, functionName, filterPattern) {
const logGroupName = `/aws/lambda/${serviceName}-${stage}-${functionName}`;

@@ -87,3 +89,3 @@ const filter = {};

DestinationArn: arn,
FilterPattern: '',
FilterPattern: filterPattern,
LogGroupName: logGroupName,

@@ -90,0 +92,0 @@ },

2

package.json
{
"name": "serverless-log-forwarding",
"version": "1.0.1",
"version": "1.1.0",
"description": "a serverless plugin to forward logs to given lambda function",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -36,2 +36,4 @@ # serverless-log-forwarding

destinationARN: '[ARN of Lambda Function to forward logs to]'
# optional:
filterPattern: `[filter pattern for logs that are sent to Lambda function]'
```

@@ -38,0 +40,0 @@

@@ -9,2 +9,6 @@ const chai = require('chai');

};
const correctConfigWithFilterPattern = {
destinationARN: 'arn:aws:lambda:us-moon-1:314159265358:function:testforward-test-forward',
filterPattern: 'Test Pattern',
};
const constructPluginResources = (logForwarding) => {

@@ -30,2 +34,3 @@ const serverless = {

name: 'functionOne',
filterPattern: 'Pattern',
},

@@ -157,2 +162,44 @@ testFunctionTwo: {

});
it('uses the filterPattern property if set', () => {
const plugin = constructPluginResources(correctConfigWithFilterPattern);
const expectedResources = {
Resources: {
TestExistingFilter: {
Type: 'AWS:Test:Filter',
},
LogForwardingLambdaPermission: {
Type: 'AWS::Lambda::Permission',
Properties: {
FunctionName: 'arn:aws:lambda:us-moon-1:314159265358:function:testforward-test-forward',
Action: 'lambda:InvokeFunction',
Principal: 'logs.us-moon-1.amazonaws.com',
},
},
SubscriptionFiltertestFunctionOne: {
Type: 'AWS::Logs::SubscriptionFilter',
Properties: {
DestinationArn: 'arn:aws:lambda:us-moon-1:314159265358:function:testforward-test-forward',
FilterPattern: 'Test Pattern',
LogGroupName: '/aws/lambda/test-service-test-stage-testFunctionOne',
},
DependsOn: [
'LogForwardingLambdaPermission',
],
},
SubscriptionFiltertestFunctionTwo: {
Type: 'AWS::Logs::SubscriptionFilter',
Properties: {
DestinationArn: 'arn:aws:lambda:us-moon-1:314159265358:function:testforward-test-forward',
FilterPattern: 'Test Pattern',
LogGroupName: '/aws/lambda/test-service-test-stage-testFunctionTwo',
},
DependsOn: [
'LogForwardingLambdaPermission',
],
},
},
};
plugin.updateResources();
expect(plugin.serverless.service.resources).to.eql(expectedResources);
});
});

@@ -159,0 +206,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc