Skip to content

Commit

Permalink
AWS inspecto vulnerabilities and ddb warning fixes (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
imranalisyed506 authored Oct 15, 2024
1 parent 4f42e22 commit a545050
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alertlogic/paws-collector",
"version": "2.2.5",
"version": "2.2.6",
"license": "MIT",
"description": "Alert Logic AWS based API Poll Log Collector Library",
"repository": {
Expand Down Expand Up @@ -34,12 +34,12 @@
"mocha": "^10.4.0",
"nyc": "^17.0.0",
"rewire": "^7.0.0",
"sinon": "^18.0.0",
"sinon": "^19.0.2",
"yargs": "^17.7.2"
},
"dependencies": {
"@alertlogic/al-aws-collector-js": "4.1.26",
"@smithy/node-http-handler":"3.1.3",
"@alertlogic/al-aws-collector-js": "^4.1.28",
"@smithy/node-http-handler": "^3.2.4",
"async": "^3.2.5",
"datadog-lambda-js": "^9.112.0",
"debug": "^4.3.5",
Expand Down
16 changes: 7 additions & 9 deletions paws_collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ const nodeHttpHandler = new NodeHttpHandler({
httpsAgent: new https.Agent(agent)
});


const DDB_OPTIONS = {
maxAttempts: 10,
maxAttempts: 5,
requestHandler: nodeHttpHandler
}

const DDB = new DynamoDB(DDB_OPTIONS);

const DDB_DELETE_BATCH_OPTIONS = {
maxBatchSize: 25,
maxBatchSizeBytes: 16 * 1024 * 1024
Expand Down Expand Up @@ -373,8 +377,6 @@ class PawsCollector extends AlAwsCollector {
// there is a lot of logic here. not sur eif there is a better way of deduping. trying for an MVP
checkStateSqsMessage(stateSqsMsg, asyncCallback) {
const collector = this;
const DDB = new DynamoDB(DDB_OPTIONS);

const params = {
Key: {
"CollectorId": {S: collector._collectorId},
Expand Down Expand Up @@ -432,8 +434,6 @@ class PawsCollector extends AlAwsCollector {

updateStateDBEntry(stateSqsMsg, Status, asyncCallback) {
const collector = this;
const DDB = new DynamoDB(DDB_OPTIONS);

const updateParams = {
Key: {
CollectorId: {S: collector._collectorId},
Expand Down Expand Up @@ -941,7 +941,6 @@ class PawsCollector extends AlAwsCollector {
*/
removeDuplicatedItem(logs, paramName, asyncCallback) {
let collector = this;
const ddb = new DynamoDB(DDB_OPTIONS);
let uniqueLogs = [];
var promises = [];
let duplicateCount = 0;
Expand All @@ -958,7 +957,7 @@ class PawsCollector extends AlAwsCollector {
ConditionExpression: 'attribute_not_exists(Id)'
};
let promise = new Promise((resolve, reject) => {
ddb.putItem(params, (err, res) => {
DDB.putItem(params, (err, res) => {
if (err) {
if (err.name === 'ConditionalCheckFailedException') {
duplicateCount++;
Expand Down Expand Up @@ -1063,9 +1062,8 @@ class PawsCollector extends AlAwsCollector {
* @returns
*/
dDBBatchWriteItem(tableName, batch) {
const ddb = new DynamoDB(DDB_OPTIONS);
const batchParams = { RequestItems: { [tableName]: batch } };
return ddb.batchWriteItem(batchParams);
return DDB.batchWriteItem(batchParams);
}

/**
Expand Down

0 comments on commit a545050

Please sign in to comment.