Skip to content

Commit

Permalink
Bump all paws collector to upgrade aws-sdk v2 to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Rakhi Mundhada authored and Rakhi Mundhada committed Nov 8, 2023
1 parent 54b903c commit 3aaac44
Show file tree
Hide file tree
Showing 28 changed files with 247 additions and 168 deletions.
11 changes: 6 additions & 5 deletions collectors/auth0/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auth0-collector",
"version": "1.1.52",
"version": "1.1.53",
"description": "Alert Logic AWS based Auth0 Log Collector extension",
"repository": {},
"private": true,
Expand All @@ -9,18 +9,19 @@
"test": "JUNIT_REPORT_PATH=./test/report.xml nyc --reporter=text mocha --colors"
},
"devDependencies": {
"aws-sdk-mock": "*",
"@aws-sdk/client-kms": "^3.441.0",
"@aws-sdk/client-ssm": "^3.441.0",
"@aws-sdk/client-cloudwatch": "^3.423.0",
"jshint": "^2.9.5",
"mocha": "^10.2.0",
"mocha-jenkins-reporter": "^0.4.2",
"nyc": "^15.1.0",
"rewire": "^7.0.0",
"sinon": "^15.2.0"
"sinon": "17.0.0"
},
"dependencies": {
"@alertlogic/al-collector-js": "^3.0.10",
"@alertlogic/paws-collector": "^2.1.21",
"aws-sdk": "^2.1457.0",
"@alertlogic/paws-collector": "^2.2.0",
"async": "^3.2.4",
"auth0": "^3.1.2",
"debug": "^4.3.4",
Expand Down
18 changes: 11 additions & 7 deletions collectors/auth0/test/auth0_test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const assert = require('assert');
const sinon = require('sinon');
const moment = require('moment');
var AWS = require('aws-sdk-mock');
const m_response = require('cfn-response');

const auth0Mock = require('./auth0_mock');
Expand All @@ -10,6 +9,9 @@ var Auth0Collector = require('../auth0_collector').Auth0Collector;
const m_al_aws = require('@alertlogic/al-aws-collector-js').Util;
const utils = require("../utils");

const { CloudWatch } = require("@aws-sdk/client-cloudwatch"),
{ KMS } = require("@aws-sdk/client-kms"),
{ SSM } = require("@aws-sdk/client-ssm");

var alserviceStub = {};
var responseStub = {};
Expand Down Expand Up @@ -93,14 +95,14 @@ function mockSetEnvStub() {
describe('Unit Tests', function () {

beforeEach(function () {
AWS.mock('SSM', 'getParameter', function (params, callback) {
const data = new Buffer('test-secret');
sinon.stub(SSM.prototype, 'getParameter').callsFake(function (params, callback) {
const data = Buffer.from('test-secret');
return callback(null, { Parameter: { Value: data.toString('base64') } });
});

AWS.mock('KMS', 'decrypt', function (params, callback) {
sinon.stub(KMS.prototype, 'decrypt').callsFake(function (params, callback) {
const data = {
Plaintext: 'decrypted-sercret-key'
Plaintext: Buffer.from('decrypted-sercret-key')
};
return callback(null, data);
});
Expand All @@ -118,8 +120,8 @@ describe('Unit Tests', function () {
restoreAlServiceStub();
setEnvStub.restore();
responseStub.restore();
AWS.restore('KMS');
AWS.restore('SSM');
KMS.prototype.decrypt.restore();
SSM.prototype.getParameter.restore();
});

describe('pawsInitCollectionState', function () {
Expand Down Expand Up @@ -322,11 +324,13 @@ describe('Unit Tests', function () {
};

var reportSpy = sinon.spy(collector, 'reportApiThrottling');
let putMetricDataStub = sinon.stub(CloudWatch.prototype, 'putMetricData').callsFake((params, callback) => callback(null));
collector.pawsGetLogs(curState, (err, logs, newState, newPollInterval) => {
assert.equal(true, reportSpy.calledOnce);
assert.equal(logs.length, 0);
assert.equal(newState.poll_interval_sec, 10);
getAPILogs.restore();
putMetricDataStub.restore();
done();
});
});
Expand Down
10 changes: 5 additions & 5 deletions collectors/carbonblack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "carbonblack-collector",
"version": "1.0.49",
"version": "1.0.50",
"description": "Alert Logic AWS based Carbonblack Log Collector",
"repository": {},
"private": true,
Expand All @@ -9,18 +9,18 @@
"test": "JUNIT_REPORT_PATH=./test/report.xml nyc --reporter=text mocha --colors"
},
"devDependencies": {
"aws-sdk-mock": "*",
"@aws-sdk/client-kms": "^3.441.0",
"@aws-sdk/client-ssm": "^3.441.0",
"jshint": "^2.9.5",
"mocha": "^10.2.0",
"mocha-jenkins-reporter": "^0.4.2",
"nyc": "^15.1.0",
"rewire": "^7.0.0",
"sinon": "^15.0.1"
"sinon": "^17.0.0"
},
"dependencies": {
"@alertlogic/al-collector-js": "3.0.10",
"@alertlogic/paws-collector": "2.1.21",
"aws-sdk": "^2.1457.0",
"@alertlogic/paws-collector": "2.2.0",
"async": "^3.2.4",
"debug": "^4.3.4",
"moment": "2.29.4",
Expand Down
13 changes: 8 additions & 5 deletions collectors/carbonblack/test/Carbonblack_test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const assert = require('assert');
const sinon = require('sinon');
var AWS = require('aws-sdk-mock');
const m_response = require('cfn-response');
const carbonblackMock = require('./carbonblack_mock');
var CarbonblackCollector = require('../collector').CarbonblackCollector;
const moment = require('moment');
const utils = require("../utils");

const { KMS } = require("@aws-sdk/client-kms"),
{ SSM } = require("@aws-sdk/client-ssm");

var responseStub = {};
let getAPIDetails;
Expand Down Expand Up @@ -41,13 +42,13 @@ function restoreAlServiceStub() {
describe('Unit Tests', function () {

beforeEach(function () {
AWS.mock('SSM', 'getParameter', function (params, callback) {
const data = new Buffer('test-secret');
sinon.stub(SSM.prototype, 'getParameter').callsFake(function (params, callback) {
const data = Buffer.from('test-secret');
return callback(null, { Parameter: { Value: data.toString('base64') } });
});
AWS.mock('KMS', 'decrypt', function (params, callback) {
sinon.stub(KMS.prototype, 'decrypt').callsFake(function (params, callback) {
const data = {
Plaintext: '{}'
Plaintext: Buffer.from('{}')
};
return callback(null, data);
});
Expand All @@ -61,6 +62,8 @@ describe('Unit Tests', function () {
afterEach(function () {
restoreAlServiceStub();
responseStub.restore();
KMS.prototype.decrypt.restore();
SSM.prototype.getParameter.restore();
});

describe('Paws Init Collection State', function () {
Expand Down
11 changes: 6 additions & 5 deletions collectors/ciscoamp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ciscoamp-collector",
"version": "1.0.49",
"version": "1.0.50",
"description": "Alert Logic AWS based Ciscoamp Log Collector",
"repository": {},
"private": true,
Expand All @@ -9,18 +9,19 @@
"test": "JUNIT_REPORT_PATH=./test/report.xml nyc --reporter=text mocha --colors"
},
"devDependencies": {
"aws-sdk-mock": "*",
"@aws-sdk/client-cloudwatch": "^3.441.0",
"@aws-sdk/client-kms": "^3.441.0",
"@aws-sdk/client-ssm": "^3.441.0",
"jshint": "^2.9.5",
"mocha": "^10.2.0",
"mocha-jenkins-reporter": "^0.4.2",
"nyc": "^15.1.0",
"rewire": "^7.0.0",
"sinon": "^15.0.1"
"sinon": "^17.0.0"
},
"dependencies": {
"@alertlogic/al-collector-js": "3.0.10",
"@alertlogic/paws-collector": "2.1.21",
"aws-sdk": "^2.1457.0",
"@alertlogic/paws-collector": "2.2.0",
"async": "^3.2.4",
"debug": "^4.3.4",
"moment": "2.29.4"
Expand Down
16 changes: 11 additions & 5 deletions collectors/ciscoamp/test/ciscoamp_test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
const assert = require('assert');
const sinon = require('sinon');
var AWS = require('aws-sdk-mock');
const m_response = require('cfn-response');
const ciscoampMock = require('./ciscoamp_mock');
var CiscoampCollector = require('../collector').CiscoampCollector;
const RestServiceClient = require('@alertlogic/al-collector-js').RestServiceClient;
const moment = require('moment');
const utils = require("../utils");
const { CloudWatch } = require("@aws-sdk/client-cloudwatch"),
{ KMS } = require("@aws-sdk/client-kms"),
{ SSM } = require("@aws-sdk/client-ssm");


var responseStub = {};
Expand All @@ -15,13 +17,13 @@ var alserviceStub = {};

describe('Unit Tests', function () {
beforeEach(function () {
AWS.mock('SSM', 'getParameter', function (params, callback) {
const data = new Buffer('test-secret');
sinon.stub(SSM.prototype, 'getParameter').callsFake(function (params, callback) {
const data = Buffer.from('test-secret');
return callback(null, { Parameter: { Value: data.toString('base64') } });
});
AWS.mock('KMS', 'decrypt', function (params, callback) {
sinon.stub(KMS.prototype, 'decrypt').callsFake(function (params, callback) {
const data = {
Plaintext: '{}'
Plaintext: Buffer.from('{}')
};
return callback(null, data);
});
Expand All @@ -36,6 +38,8 @@ describe('Unit Tests', function () {
getAPILogs.restore();
getAPIDetails.restore();
responseStub.restore();
KMS.prototype.decrypt.restore();
SSM.prototype.getParameter.restore();
});

describe('Paws Init Collection State', function () {
Expand Down Expand Up @@ -427,12 +431,14 @@ describe('Unit Tests', function () {
poll_interval_sec: 1
};
var reportSpy = sinon.spy(collector, 'reportApiThrottling');
let putMetricDataStub = sinon.stub(CloudWatch.prototype, 'putMetricData').callsFake((params, callback) => callback(null)) ;
collector.pawsGetLogs(curState, (err, logs, newState, newPollInterval) => {
assert.equal(err, null);
assert.equal(true, reportSpy.calledOnce);
assert.equal(logs.length, 0);
assert.notEqual(newState.apiQuotaResetDate, null);
assert.equal(newState.poll_interval_sec, newPollInterval);
putMetricDataStub.restore();
done();
});
});
Expand Down
11 changes: 6 additions & 5 deletions collectors/ciscoduo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ciscoduo-collector",
"version": "1.0.48",
"version": "1.0.49",
"description": "Alert Logic AWS based Ciscoduo Log Collector",
"repository": {},
"private": true,
Expand All @@ -9,18 +9,19 @@
"test": "JUNIT_REPORT_PATH=./test/report.xml nyc --reporter=text mocha --colors"
},
"devDependencies": {
"aws-sdk-mock": "*",
"@aws-sdk/client-cloudwatch": "^3.441.0",
"@aws-sdk/client-kms": "^3.441.0",
"@aws-sdk/client-ssm": "^3.441.0",
"jshint": "^2.9.5",
"mocha": "^10.2.0",
"mocha-jenkins-reporter": "^0.4.2",
"nyc": "^15.1.0",
"rewire": "^7.0.0",
"sinon": "^15.2.0"
"sinon": "^17.0.0"
},
"dependencies": {
"@alertlogic/al-collector-js": "3.0.10",
"@alertlogic/paws-collector": "2.1.21",
"aws-sdk": "^2.1457.0",
"@alertlogic/paws-collector": "2.2.0",
"@duosecurity/duo_api": "^1.2.3",
"async": "^3.2.4",
"debug": "^4.3.4",
Expand Down
16 changes: 11 additions & 5 deletions collectors/ciscoduo/test/ciscoduo_test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
const assert = require('assert');
const sinon = require('sinon');
var AWS = require('aws-sdk-mock');
const m_response = require('cfn-response');
const ciscoduoMock = require('./ciscoduo_mock');
var CiscoduoCollector = require('../collector').CiscoduoCollector;
const moment = require('moment');
const utils = require("../utils");
const { CloudWatch } = require("@aws-sdk/client-cloudwatch"),
{ KMS } = require("@aws-sdk/client-kms"),
{ SSM } = require("@aws-sdk/client-ssm");


var responseStub = {};
Expand All @@ -14,13 +16,13 @@ let getAPILogs;

describe('Unit Tests', function () {
beforeEach(function () {
AWS.mock('SSM', 'getParameter', function (params, callback) {
const data = new Buffer('test-secret');
sinon.stub(SSM.prototype, 'getParameter').callsFake(function (params, callback) {
const data = Buffer.from('test-secret');
return callback(null, { Parameter: { Value: data.toString('base64') } });
});
AWS.mock('KMS', 'decrypt', function (params, callback) {
sinon.stub(KMS.prototype, 'decrypt').callsFake(function (params, callback) {
const data = {
Plaintext: '{}'
Plaintext: Buffer.from('{}')
};
return callback(null, data);
});
Expand All @@ -33,6 +35,8 @@ describe('Unit Tests', function () {

afterEach(function () {
responseStub.restore();
KMS.prototype.decrypt.restore();
SSM.prototype.getParameter.restore();
});


Expand Down Expand Up @@ -269,12 +273,14 @@ describe('Unit Tests', function () {
};

var reportSpy = sinon.spy(collector, 'reportApiThrottling');
let putMetricDataStub = sinon.stub(CloudWatch.prototype, 'putMetricData').callsFake((params, callback) => callback());
collector.pawsGetLogs(curState, (err, logs, newState, newPollInterval) => {
assert.equal(true, reportSpy.calledOnce);
assert.equal(logs.length, 0);
assert.equal(newState.poll_interval_sec, 120);
getAPILogs.restore();
getAPIDetails.restore();
putMetricDataStub.restore();
done();
});

Expand Down
10 changes: 5 additions & 5 deletions collectors/crowdstrike/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crowdstrike-collector",
"version": "1.0.30",
"version": "1.0.31",
"description": "Alert Logic AWS based Crowdstrike Log Collector",
"repository": {},
"private": true,
Expand All @@ -9,18 +9,18 @@
"test": "JUNIT_REPORT_PATH=./test/report.xml nyc --reporter=text mocha --colors"
},
"devDependencies": {
"aws-sdk-mock": "*",
"@aws-sdk/client-kms": "^3.441.0",
"@aws-sdk/client-ssm": "^3.441.0",
"jshint": "^2.9.5",
"mocha": "^10.2.0",
"mocha-jenkins-reporter": "^0.4.2",
"nyc": "^15.1.0",
"rewire": "^7.0.0",
"sinon": "^15.2.0"
"sinon": "^17.0.0"
},
"dependencies": {
"@alertlogic/al-collector-js": "^3.0.10",
"@alertlogic/paws-collector": "^2.1.21",
"aws-sdk": "^2.1457.0",
"@alertlogic/paws-collector": "2.2.0",
"async": "^3.2.4",
"debug": "^4.3.4",
"moment": "2.29.4"
Expand Down
Loading

0 comments on commit 3aaac44

Please sign in to comment.