From c7fe5b1a4bbe48106bf364bae4bda7f8287acf0d Mon Sep 17 00:00:00 2001 From: Dmytro Date: Wed, 5 May 2021 09:40:03 +0300 Subject: [PATCH 01/64] feat(redis-client): Fix of issue when redis is restarted after shutting down. Two new methods for getting clients. --- package-lock.json | 181 ++++++++++++++++--------------- package.json | 2 +- ts/index.ts | 5 + ts/lib/request_response/index.ts | 11 +- 4 files changed, 109 insertions(+), 90 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0dd44f9..4f511f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -36,8 +36,8 @@ "resolved": "https://registry.npmjs.org/@types/redis/-/redis-2.8.6.tgz", "integrity": "sha512-kaSI4XQwCfJtPiuyCXvLxCaw2N0fMZesdob3Jh01W20vNFct+3lfvJ/4yCJxbSopXOBOzpg+pGxkW6uWZrPZHA==", "requires": { - "@types/events": "1.2.0", - "@types/node": "8.0.20" + "@types/events": "*", + "@types/node": "*" } }, "@types/uuid": { @@ -45,7 +45,7 @@ "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-3.4.3.tgz", "integrity": "sha512-5fRLCYhLtDb3hMWqQyH10qtF+Ud2JnNCXTCZ+9ktNdCcgslcuXkDTkFcJNk++MT29yDntDnlF1+jD+uVGumsbw==", "requires": { - "@types/node": "8.0.20" + "@types/node": "*" } }, "bluebird": { @@ -59,12 +59,12 @@ "integrity": "sha1-nkHoCOF6fxCAdyHirFpYnVuwkII=", "dev": true, "requires": { - "assertion-error": "1.1.0", - "check-error": "1.0.2", - "deep-eql": "2.0.2", - "get-func-name": "2.0.0", - "pathval": "1.1.0", - "type-detect": "4.0.8" + "assertion-error": "^1.0.1", + "check-error": "^1.0.1", + "deep-eql": "^2.0.1", + "get-func-name": "^2.0.0", + "pathval": "^1.0.0", + "type-detect": "^4.0.0" }, "dependencies": { "assertion-error": { @@ -85,7 +85,7 @@ "integrity": "sha1-sbrAblbwp2d3aG1Qyf63XC7XZ5o=", "dev": true, "requires": { - "type-detect": "3.0.0" + "type-detect": "^3.0.0" }, "dependencies": { "type-detect": { @@ -116,6 +116,11 @@ } } }, + "denque": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.0.tgz", + "integrity": "sha512-CYiCSgIF1p6EUByQPlGkKnP1M9g0ZV3qMIrqMqZqdwazygIA/YP2vrbcyl1h/WppKJTdl1F85cXIle+394iDAQ==" + }, "mocha": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.0.tgz", @@ -147,7 +152,7 @@ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { - "balanced-match": "1.0.0", + "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, @@ -163,7 +168,7 @@ "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", "dev": true, "requires": { - "graceful-readlink": "1.0.1" + "graceful-readlink": ">= 1.0.0" } }, "concat-map": { @@ -205,12 +210,12 @@ "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", "dev": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.2", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "graceful-readlink": { @@ -237,8 +242,8 @@ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "once": "^1.3.0", + "wrappy": "1" } }, "inherits": { @@ -259,8 +264,8 @@ "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", "dev": true, "requires": { - "lodash._basecopy": "3.0.1", - "lodash.keys": "3.1.2" + "lodash._basecopy": "^3.0.0", + "lodash.keys": "^3.0.0" } }, "lodash._basecopy": { @@ -293,9 +298,9 @@ "integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=", "dev": true, "requires": { - "lodash._baseassign": "3.2.0", - "lodash._basecreate": "3.0.3", - "lodash._isiterateecall": "3.0.9" + "lodash._baseassign": "^3.0.0", + "lodash._basecreate": "^3.0.0", + "lodash._isiterateecall": "^3.0.0" } }, "lodash.isarguments": { @@ -316,9 +321,9 @@ "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", "dev": true, "requires": { - "lodash._getnative": "3.9.1", - "lodash.isarguments": "3.1.0", - "lodash.isarray": "3.0.4" + "lodash._getnative": "^3.0.0", + "lodash.isarguments": "^3.0.0", + "lodash.isarray": "^3.0.0" } }, "minimatch": { @@ -327,7 +332,7 @@ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "brace-expansion": "1.1.11" + "brace-expansion": "^1.1.7" } }, "minimist": { @@ -357,7 +362,7 @@ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } }, "path-is-absolute": { @@ -372,7 +377,7 @@ "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=", "dev": true, "requires": { - "has-flag": "1.0.0" + "has-flag": "^1.0.0" } }, "wrappy": { @@ -384,30 +389,32 @@ } }, "redis": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/redis/-/redis-2.7.1.tgz", - "integrity": "sha1-fVb3h1uYsgQQtxU58dh47Vjr9Go=", + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/redis/-/redis-3.1.2.tgz", + "integrity": "sha512-grn5KoZLr/qrRQVwoSkmzdbw6pwF+/rwODtrOr6vuBRiR/f3rjSTGupbF90Zpqm2oenix8Do6RV7pYEkGwlKkw==", "requires": { - "double-ended-queue": "2.1.0-0", - "redis-commands": "1.3.5", - "redis-parser": "2.6.0" - }, - "dependencies": { - "double-ended-queue": { - "version": "2.1.0-0", - "resolved": "https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz", - "integrity": "sha1-ED01J/0xUo9AGIEwyEHv3XgmTlw=" - }, - "redis-commands": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.3.5.tgz", - "integrity": "sha512-foGF8u6MXGFF++1TZVC6icGXuMYPftKXt1FBT2vrfU9ZATNtZJ8duRC5d1lEfE8hyVe3jhelHGB91oB7I6qLsA==" - }, - "redis-parser": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.6.0.tgz", - "integrity": "sha1-Uu0J2srBCPGmMcB+m2mUHnoZUEs=" - } + "denque": "^1.5.0", + "redis-commands": "^1.7.0", + "redis-errors": "^1.2.0", + "redis-parser": "^3.0.0" + } + }, + "redis-commands": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz", + "integrity": "sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ==" + }, + "redis-errors": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", + "integrity": "sha1-62LSrbFeTq9GEMBK/hUpOEJQq60=" + }, + "redis-parser": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", + "integrity": "sha1-tm2CjNyv5rS4pCin3vTGvKwxyLQ=", + "requires": { + "redis-errors": "^1.0.0" } }, "tslint": { @@ -416,16 +423,16 @@ "integrity": "sha1-EOjas+MGH6YelELozuOYKs8gpqo=", "dev": true, "requires": { - "babel-code-frame": "6.26.0", - "colors": "1.2.1", - "commander": "2.15.1", - "diff": "3.5.0", - "glob": "7.1.2", - "minimatch": "3.0.4", - "resolve": "1.7.1", - "semver": "5.5.0", - "tslib": "1.9.0", - "tsutils": "2.26.1" + "babel-code-frame": "^6.22.0", + "colors": "^1.1.2", + "commander": "^2.9.0", + "diff": "^3.2.0", + "glob": "^7.1.1", + "minimatch": "^3.0.4", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.7.1", + "tsutils": "^2.5.1" }, "dependencies": { "ansi-regex": { @@ -446,9 +453,9 @@ "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", "dev": true, "requires": { - "chalk": "1.1.3", - "esutils": "2.0.2", - "js-tokens": "3.0.2" + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" } }, "balanced-match": { @@ -463,7 +470,7 @@ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { - "balanced-match": "1.0.0", + "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, @@ -473,11 +480,11 @@ "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" } }, "colors": { @@ -528,12 +535,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, "has-ansi": { @@ -542,7 +549,7 @@ "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "inflight": { @@ -551,8 +558,8 @@ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "once": "^1.3.0", + "wrappy": "1" } }, "inherits": { @@ -573,7 +580,7 @@ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "brace-expansion": "1.1.11" + "brace-expansion": "^1.1.7" } }, "once": { @@ -582,7 +589,7 @@ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "wrappy": "1.0.2" + "wrappy": "1" } }, "path-is-absolute": { @@ -603,7 +610,7 @@ "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", "dev": true, "requires": { - "path-parse": "1.0.5" + "path-parse": "^1.0.5" } }, "semver": { @@ -618,7 +625,7 @@ "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, "requires": { - "ansi-regex": "2.1.1" + "ansi-regex": "^2.0.0" } }, "supports-color": { @@ -639,7 +646,7 @@ "integrity": "sha512-bnm9bcjOqOr1UljleL94wVCDlpa6KjfGaTkefeLch4GRafgDkROxPizbB/FxTEdI++5JqhxczRy/Qub0syNqZA==", "dev": true, "requires": { - "tslib": "1.9.0" + "tslib": "^1.8.1" } }, "wrappy": { diff --git a/package.json b/package.json index 12a248c..3484dac 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "@types/uuid": "3.4.3", "@types/node": "8.0.20", "bluebird": "3.5.0", - "redis": "2.7.1", + "redis": "^3.1.2", "uuid": "3.2.1" }, "devDependencies": { diff --git a/ts/index.ts b/ts/index.ts index 0e6ba6e..cd74104 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -3,6 +3,7 @@ import { request, server, closeAllClients, enableServers, disableServers } from import { EpicurusRedisConfig, serverCallback, subscribeCallback } from './interface' import * as redis from 'redis' import * as bluebird from 'bluebird' +import { RedisClient } from 'redis' bluebird.promisifyAll(redis.RedisClient.prototype) bluebird.promisifyAll(redis.Multi.prototype) @@ -20,6 +21,8 @@ export default function Epicurus (redisConfig: EpicurusRedisConfig = { enableServers() return { + getRedisClient: () => redisClient, + getRedisSubClient: () => redisSub, subscribe: (channel: string, callback: subscribeCallback) => subscribe(redisSub, channel, callback), publish: (channel: string, body: any) => publish(redisClient, channel, body), server: (channel: string, callback: serverCallback) => server(redisClient, channel, callback), @@ -39,6 +42,8 @@ export default function Epicurus (redisConfig: EpicurusRedisConfig = { } export type EpicurusPublicInterface = { + getRedisClient: () => RedisClient + getRedisSubClient: () => RedisClient subscribe: (channel: string, callback: subscribeCallback) => Promise publish: (channel: string, body: any) => void server: (channel: string, callback: serverCallback) => Promise diff --git a/ts/lib/request_response/index.ts b/ts/lib/request_response/index.ts index beb7cca..84d0190 100644 --- a/ts/lib/request_response/index.ts +++ b/ts/lib/request_response/index.ts @@ -77,10 +77,17 @@ export async function server(redisClient, channel: string, callback: serve function brpop () { clientClone.brpop(channel, 0, async function (_null, popInfo) { + if (_null) { + console.error('BRPOP ERROR', _null) + } if (enableServers) { brpop() } + if (!popInfo) { + return + } + const reqId = popInfo[1] const rawRequest: string = await redisClient.getAsync(`${reqId}-ref`) await redisClient.delAsync(`${reqId}-ref`) @@ -90,8 +97,8 @@ export async function server(redisClient, channel: string, callback: serve if (req.ttl > Date.now() - config.requestValidityPeriod) { callback(req.body, async function (error, result) { const errorRef = error - ? { name: error.name, message: error.message, stack: error.stack, severity: error.severity || 1 } - : null + ? { name: error.name, message: error.message, stack: error.stack, severity: error.severity || 1 } + : null let redisResponse: EpicurusResponse = { error: errorRef, From 0aade77ca6c8993c674c75277ab5191843f2eaa2 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Wed, 5 May 2021 10:23:44 +0300 Subject: [PATCH 02/64] AUTH-75. Fix of issue when redis is restarted after shutting down. Two new methods for getting clients. --- .gitignore | 2 +- js/config.d.ts | 3 + js/config.js | 6 ++ js/config.js.map | 1 + js/index.d.ts | 13 +++ js/index.js | 38 ++++++++ js/index.js.map | 1 + js/integration/client.d.ts | 1 + js/integration/client.js | 22 +++++ js/integration/client.js.map | 1 + js/integration/server.d.ts | 1 + js/integration/server.js | 15 +++ js/integration/server.js.map | 1 + js/interface.d.ts | 22 +++++ js/interface.js | 3 + js/interface.js.map | 1 + js/lib/error.d.ts | 17 ++++ js/lib/error.js | 18 ++++ js/lib/error.js.map | 1 + js/lib/pub_sub/index.d.ts | 6 ++ js/lib/pub_sub/index.js | 50 ++++++++++ js/lib/pub_sub/index.js.map | 1 + js/lib/request_response/index.d.ts | 6 ++ js/lib/request_response/index.js | 133 +++++++++++++++++++++++++++ js/lib/request_response/index.js.map | 1 + js/test/pub_sub.spec.d.ts | 1 + js/test/pub_sub.spec.js | 73 +++++++++++++++ js/test/pub_sub.spec.js.map | 1 + js/test/request_response.spec.d.ts | 1 + js/test/request_response.spec.js | 111 ++++++++++++++++++++++ js/test/request_response.spec.js.map | 1 + 31 files changed, 551 insertions(+), 1 deletion(-) create mode 100644 js/config.d.ts create mode 100644 js/config.js create mode 100644 js/config.js.map create mode 100644 js/index.d.ts create mode 100644 js/index.js create mode 100644 js/index.js.map create mode 100644 js/integration/client.d.ts create mode 100644 js/integration/client.js create mode 100644 js/integration/client.js.map create mode 100644 js/integration/server.d.ts create mode 100644 js/integration/server.js create mode 100644 js/integration/server.js.map create mode 100644 js/interface.d.ts create mode 100644 js/interface.js create mode 100644 js/interface.js.map create mode 100644 js/lib/error.d.ts create mode 100644 js/lib/error.js create mode 100644 js/lib/error.js.map create mode 100644 js/lib/pub_sub/index.d.ts create mode 100644 js/lib/pub_sub/index.js create mode 100644 js/lib/pub_sub/index.js.map create mode 100644 js/lib/request_response/index.d.ts create mode 100644 js/lib/request_response/index.js create mode 100644 js/lib/request_response/index.js.map create mode 100644 js/test/pub_sub.spec.d.ts create mode 100644 js/test/pub_sub.spec.js create mode 100644 js/test/pub_sub.spec.js.map create mode 100644 js/test/request_response.spec.d.ts create mode 100644 js/test/request_response.spec.js create mode 100644 js/test/request_response.spec.js.map diff --git a/.gitignore b/.gitignore index 091f0a9..eb79dd5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ node_modules -js +.idea diff --git a/js/config.d.ts b/js/config.d.ts new file mode 100644 index 0000000..1401757 --- /dev/null +++ b/js/config.d.ts @@ -0,0 +1,3 @@ +export declare const config: { + requestValidityPeriod: number; +}; diff --git a/js/config.js b/js/config.js new file mode 100644 index 0000000..286d043 --- /dev/null +++ b/js/config.js @@ -0,0 +1,6 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.config = { + requestValidityPeriod: 10000 +}; +//# sourceMappingURL=config.js.map \ No newline at end of file diff --git a/js/config.js.map b/js/config.js.map new file mode 100644 index 0000000..6843f87 --- /dev/null +++ b/js/config.js.map @@ -0,0 +1 @@ +{"version":3,"file":"config.js","sourceRoot":"","sources":["../ts/config.ts"],"names":[],"mappings":";;AAAa,QAAA,MAAM,GAAG;IACpB,qBAAqB,EAAE,KAAK;CAC7B,CAAA"} \ No newline at end of file diff --git a/js/index.d.ts b/js/index.d.ts new file mode 100644 index 0000000..8a1ee98 --- /dev/null +++ b/js/index.d.ts @@ -0,0 +1,13 @@ +import { EpicurusRedisConfig, serverCallback, subscribeCallback } from './interface'; +import { RedisClient } from 'redis'; +export default function Epicurus(redisConfig?: EpicurusRedisConfig): EpicurusPublicInterface; +export declare type EpicurusPublicInterface = { + getRedisClient: () => RedisClient; + getRedisSubClient: () => RedisClient; + subscribe: (channel: string, callback: subscribeCallback) => Promise; + publish: (channel: string, body: any) => void; + server: (channel: string, callback: serverCallback) => Promise; + request: (channel: string, body: any) => Promise; + shutdown: () => void; + close: () => void; +}; diff --git a/js/index.js b/js/index.js new file mode 100644 index 0000000..ffa000d --- /dev/null +++ b/js/index.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const pub_sub_1 = require("./lib/pub_sub"); +const request_response_1 = require("./lib/request_response"); +const redis = require("redis"); +const bluebird = require("bluebird"); +bluebird.promisifyAll(redis.RedisClient.prototype); +bluebird.promisifyAll(redis.Multi.prototype); +function Epicurus(redisConfig = { + host: 'localhost', + port: 6379 +}) { + const redisClient = redis.createClient(redisConfig); + const redisSub = redis.createClient(redisConfig); + pub_sub_1.setupSubscriptionListener(redisSub); + request_response_1.enableServers(); + return { + getRedisClient: () => redisClient, + getRedisSubClient: () => redisSub, + subscribe: (channel, callback) => pub_sub_1.subscribe(redisSub, channel, callback), + publish: (channel, body) => pub_sub_1.publish(redisClient, channel, body), + server: (channel, callback) => request_response_1.server(redisClient, channel, callback), + request: (channel, body) => request_response_1.request(redisClient, channel, body), + shutdown: () => { + pub_sub_1.shutdownSubscribers(); + request_response_1.disableServers(); + }, + close: () => { + redisSub.unsubscribe(); + redisSub.quit(); + redisClient.quit(); + pub_sub_1.removeCallbacks(); + request_response_1.closeAllClients(); + } + }; +} +exports.default = Epicurus; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/js/index.js.map b/js/index.js.map new file mode 100644 index 0000000..1f6e184 --- /dev/null +++ b/js/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;AAAA,2CAAmH;AACnH,6DAAwG;AAExG,+BAA8B;AAC9B,qCAAoC;AAEpC,QAAQ,CAAC,YAAY,CAA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;KACF,CAAA;AACH,CAAC;AAhCD,2BAgCC"} \ No newline at end of file diff --git a/js/integration/client.d.ts b/js/integration/client.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/js/integration/client.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/js/integration/client.js b/js/integration/client.js new file mode 100644 index 0000000..f0eb3bd --- /dev/null +++ b/js/integration/client.js @@ -0,0 +1,22 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const http = require("http"); +const index_1 = require("../index"); +const epicurus = index_1.default(); +const server = http.createServer((req, res) => { + epicurus.request('findAccountBalanceHistory', { hello: 'world' }).then((r) => { + res.setHeader('Content-Type', 'text/html'); + res.writeHead(200, { 'Content-Type': 'text/plain' }); + res.end('ok'); + }).catch((e) => { + console.log(e.message); + res.writeHead(500, { 'Content-Type': 'text/plain' }); + res.end(); + }); +}); +server.on('clientError', (err, socket) => { + socket.end('HTTP/1.1 400 Bad Request\r\n\r\n'); +}); +server.listen(22222); +console.log('Epicurus Client booted on 22222. Will request findAccountBalanceHistory'); +//# sourceMappingURL=client.js.map \ No newline at end of file diff --git a/js/integration/client.js.map b/js/integration/client.js.map new file mode 100644 index 0000000..fca6b19 --- /dev/null +++ b/js/integration/client.js.map @@ -0,0 +1 @@ +{"version":3,"file":"client.js","sourceRoot":"","sources":["../../ts/integration/client.ts"],"names":[],"mappings":";;AAAA,6BAA4B;AAC5B,oCAAwC;AACxC,MAAM,QAAQ,GAAG,eAAiB,EAAE,CAAA;AAEpC,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IAC5C,QAAQ,CAAC,OAAO,CAAC,2BAA2B,EAAE,EAAC,KAAK,EAAE,OAAO,EAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;QAEzE,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA;QAC1C,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAC,cAAc,EAAE,YAAY,EAAC,CAAC,CAAA;QAClD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACf,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACb,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;QACtB,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAC,cAAc,EAAE,YAAY,EAAC,CAAC,CAAA;QAClD,GAAG,CAAC,GAAG,EAAE,CAAA;IACX,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA;AAEF,MAAM,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;IACvC,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAA;AAChD,CAAC,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACpB,OAAO,CAAC,GAAG,CAAC,yEAAyE,CAAC,CAAA"} \ No newline at end of file diff --git a/js/integration/server.d.ts b/js/integration/server.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/js/integration/server.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/js/integration/server.js b/js/integration/server.js new file mode 100644 index 0000000..d438266 --- /dev/null +++ b/js/integration/server.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const index_1 = require("../index"); +const epicurus = index_1.default(); +epicurus.server('findAccountBalanceHistory', function (msg, done) { + const responseBody = { + key: 'cake', + speed: 'slow', + distance: 'close', + when: 'now' + }; + done(null, responseBody); +}); +console.log('Epicurus Server booted. Listening on findAccountBalanceHistory'); +//# sourceMappingURL=server.js.map \ No newline at end of file diff --git a/js/integration/server.js.map b/js/integration/server.js.map new file mode 100644 index 0000000..a991429 --- /dev/null +++ b/js/integration/server.js.map @@ -0,0 +1 @@ +{"version":3,"file":"server.js","sourceRoot":"","sources":["../../ts/integration/server.ts"],"names":[],"mappings":";;AAAA,oCAAwC;AACxC,MAAM,QAAQ,GAAG,eAAiB,EAAE,CAAA;AAEpC,QAAQ,CAAC,MAAM,CAAC,2BAA2B,EAAE,UAAU,GAAG,EAAE,IAAI;IAC9D,MAAM,YAAY,GAAG;QACnB,GAAG,EAAE,MAAM;QACX,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,KAAK;KACZ,CAAA;IAED,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAA;AAC1B,CAAC,CAAC,CAAA;AAEF,OAAO,CAAC,GAAG,CAAC,gEAAgE,CAAC,CAAA"} \ No newline at end of file diff --git a/js/interface.d.ts b/js/interface.d.ts new file mode 100644 index 0000000..6713b22 --- /dev/null +++ b/js/interface.d.ts @@ -0,0 +1,22 @@ +export declare type serverCallback = (body: T & { + channel: string; +}, responseCallback: (error: any, response?: S) => any) => any; +export declare type subscribeCallback = (body: T & { + channel: string; +}) => any; +export interface EpicurusPubSubCallbackReference { + [channel: string]: Function[]; +} +export interface EpicurusRequest { + reqId: string; + body: any; + ttl: number; +} +export interface EpicurusResponse { + error?: any; + result?: any; +} +export interface EpicurusRedisConfig { + host: string; + port: number; +} diff --git a/js/interface.js b/js/interface.js new file mode 100644 index 0000000..d549d1f --- /dev/null +++ b/js/interface.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=interface.js.map \ No newline at end of file diff --git a/js/interface.js.map b/js/interface.js.map new file mode 100644 index 0000000..593f380 --- /dev/null +++ b/js/interface.js.map @@ -0,0 +1 @@ +{"version":3,"file":"interface.js","sourceRoot":"","sources":["../ts/interface.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/js/lib/error.d.ts b/js/lib/error.d.ts new file mode 100644 index 0000000..d8b3219 --- /dev/null +++ b/js/lib/error.d.ts @@ -0,0 +1,17 @@ +export declare class EpicurusError extends Error { + id: number; + context: {}; + status: {}; + severity: number; + constructor(message: string, meta: { + context?: {}; + args?: any; + requestReference?: any; + severity: number; + status?: number; + id?: number; + stack?: string; + name?: string; + }); + toString(): string; +} diff --git a/js/lib/error.js b/js/lib/error.js new file mode 100644 index 0000000..f526d2b --- /dev/null +++ b/js/lib/error.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +class EpicurusError extends Error { + constructor(message, meta) { + super(message); + this.id = meta.id || Number((Math.random() * 100000).toFixed(0)); + this.name = meta.name || this.name; + this.context = meta.context; + this.stack = new Error().stack; + this.status = meta.stack || meta.status; + this.severity = meta.severity; + } + toString() { + return this.name + ': ' + this.message; + } +} +exports.EpicurusError = EpicurusError; +//# sourceMappingURL=error.js.map \ No newline at end of file diff --git a/js/lib/error.js.map b/js/lib/error.js.map new file mode 100644 index 0000000..54be11b --- /dev/null +++ b/js/lib/error.js.map @@ -0,0 +1 @@ +{"version":3,"file":"error.js","sourceRoot":"","sources":["../../ts/lib/error.ts"],"names":[],"mappings":";;AAAA,mBAA2B,SAAQ,KAAK;IAMtC,YACE,OAAe,EACf,IASC;QAED,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;QAChE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC3B,IAAI,CAAC,KAAK,GAAS,IAAI,KAAK,EAAG,CAAC,KAAK,CAAA;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,CAAA;QACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;IAC/B,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,OAAO,CAAA;IACxC,CAAC;CACF;AA/BD,sCA+BC"} \ No newline at end of file diff --git a/js/lib/pub_sub/index.d.ts b/js/lib/pub_sub/index.d.ts new file mode 100644 index 0000000..93249a3 --- /dev/null +++ b/js/lib/pub_sub/index.d.ts @@ -0,0 +1,6 @@ +import { subscribeCallback } from '../../interface'; +export declare function subscribe(subClient: any, channel: string, callback: subscribeCallback): Promise; +export declare function publish(redisClient: any, channel: string, body: any): void; +export declare function setupSubscriptionListener(subClient: any): void; +export declare function shutdownSubscribers(): void; +export declare function removeCallbacks(): void; diff --git a/js/lib/pub_sub/index.js b/js/lib/pub_sub/index.js new file mode 100644 index 0000000..c8deeaa --- /dev/null +++ b/js/lib/pub_sub/index.js @@ -0,0 +1,50 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let callbackReference = {}; +let enableMessageEvents; +function subscribe(subClient, channel, callback) { + subClient.subscribe(channel); + if (callbackReference[channel]) { + callbackReference[channel].push(callback); + } + else { + callbackReference[channel] = [callback]; + } + return new Promise((res) => { + subClient.on('subscribe', (channelSubscribedTo) => { + if (channel === channelSubscribedTo) { + res(); + } + }); + }); +} +exports.subscribe = subscribe; +function publish(redisClient, channel, body) { + const message = JSON.stringify(body); + redisClient.publish(channel, message); +} +exports.publish = publish; +function setupSubscriptionListener(subClient) { + enableMessageEvents = true; + subClient.on('message', function (channel, message) { + if (!enableMessageEvents) { + return; + } + const callbacks = callbackReference[channel]; + if (callbacks) { + let response = JSON.parse(message); + response.channel = channel; + callbacks.forEach(callback => callback(response)); + } + }); +} +exports.setupSubscriptionListener = setupSubscriptionListener; +function shutdownSubscribers() { + enableMessageEvents = false; +} +exports.shutdownSubscribers = shutdownSubscribers; +function removeCallbacks() { + callbackReference = {}; +} +exports.removeCallbacks = removeCallbacks; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/js/lib/pub_sub/index.js.map b/js/lib/pub_sub/index.js.map new file mode 100644 index 0000000..726edfa --- /dev/null +++ b/js/lib/pub_sub/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/lib/pub_sub/index.ts"],"names":[],"mappings":";;AAEA,IAAI,iBAAiB,GAAoC,EAAE,CAAA;AAC3D,IAAI,mBAAmB,CAAA;AAEvB,mBAA6B,SAAS,EAAE,OAAe,EAAE,QAA8B;IACrF,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;IAE5B,IAAI,iBAAiB,CAAC,OAAO,CAAC,EAAE;QAC9B,iBAAiB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;KAC1C;SAAM;QACL,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;KACxC;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACzB,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC,mBAAmB,EAAE,EAAE;YAChD,IAAI,OAAO,KAAK,mBAAmB,EAAE;gBACnC,GAAG,EAAE,CAAA;aACN;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC;AAhBD,8BAgBC;AAED,iBAAwB,WAAW,EAAE,OAAe,EAAE,IAAI;IACxD,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IACpC,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC;AAHD,0BAGC;AAED,mCAA2C,SAAS;IAClD,mBAAmB,GAAG,IAAI,CAAA;IAE1B,SAAS,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,OAAe,EAAE,OAAO;QACxD,IAAI,CAAC,mBAAmB,EAAE;YACxB,OAAM;SACP;QAED,MAAM,SAAS,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAA;QAC5C,IAAI,SAAS,EAAE;YACb,IAAI,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;YAClC,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAA;YAC1B,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAA;SAClD;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAfD,8DAeC;AAED;IACE,mBAAmB,GAAG,KAAK,CAAA;AAC7B,CAAC;AAFD,kDAEC;AAED;IACE,iBAAiB,GAAG,EAAE,CAAA;AACxB,CAAC;AAFD,0CAEC"} \ No newline at end of file diff --git a/js/lib/request_response/index.d.ts b/js/lib/request_response/index.d.ts new file mode 100644 index 0000000..6fe6e23 --- /dev/null +++ b/js/lib/request_response/index.d.ts @@ -0,0 +1,6 @@ +import { serverCallback } from '../../interface'; +export declare function request(redisClient: any, channel: string, body: any): Promise; +export declare function server(redisClient: any, channel: string, callback: serverCallback): Promise; +export declare function disableServers(): void; +export declare function enableServers(): void; +export declare function closeAllClients(): void; diff --git a/js/lib/request_response/index.js b/js/lib/request_response/index.js new file mode 100644 index 0000000..ecd27f2 --- /dev/null +++ b/js/lib/request_response/index.js @@ -0,0 +1,133 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const v4 = require("uuid/v4"); +const config_1 = require("../../config"); +const error_1 = require("../error"); +let clients = []; +let serversEnabled; +function request(redisClient, channel, body) { + return new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () { + let responseValid = true; + const reqId = v4(); + const ttl = Date.now(); + const redisBody = { reqId, body, ttl }; + let timeout; + let timeoutFallback; + const clientClone = redisClient.duplicate(); + timeout = setTimeout(function () { + return __awaiter(this, void 0, void 0, function* () { + const reqCheck = yield redisClient.getAsync(`${reqId}-ref`); + if (!reqCheck) { + timeoutFallback = setTimeout(function () { + return __awaiter(this, void 0, void 0, function* () { + rej(new error_1.EpicurusError('No response from server', { + context: { originalRequest: body, channel: channel }, + severity: 2 + })); + responseValid = false; + clientClone.quit(); + }); + }, config_1.config.requestValidityPeriod); + } + else { + rej(new error_1.EpicurusError('Server not found', { + context: { originalRequest: body, channel: channel }, + severity: 2 + })); + responseValid = false; + clientClone.quit(); + } + }); + }, config_1.config.requestValidityPeriod + 100); + clientClone.brpop(reqId, 0, function (_null, popInfo) { + clearTimeout(timeout); + clearTimeout(timeoutFallback); + if (!responseValid) { + return; + } + const redisResponse = popInfo[1]; + const response = JSON.parse(redisResponse); + if (response.error) { + rej(new error_1.EpicurusError(response.error.message, { + severity: response.error.severity, + context: { + context: { originalRequest: body, channel: channel }, + stack: response.error.stack, + name: response.error.name + } + })); + } + else { + res(response.result); + } + clientClone.quit(); + }); + yield redisClient.setAsync(`${reqId}-ref`, JSON.stringify(redisBody)); + yield redisClient.lpushAsync(channel, reqId); + })); +} +exports.request = request; +function server(redisClient, channel, callback) { + return __awaiter(this, void 0, void 0, function* () { + const clientClone = redisClient.duplicate(); + clients.push(clientClone); + function brpop() { + clientClone.brpop(channel, 0, function (_null, popInfo) { + return __awaiter(this, void 0, void 0, function* () { + if (_null) { + console.error('BRPOP ERROR', _null); + } + if (enableServers) { + brpop(); + } + if (!popInfo) { + return; + } + const reqId = popInfo[1]; + const rawRequest = yield redisClient.getAsync(`${reqId}-ref`); + yield redisClient.delAsync(`${reqId}-ref`); + const req = JSON.parse(rawRequest); + req.body.channel = channel; + if (req.ttl > Date.now() - config_1.config.requestValidityPeriod) { + callback(req.body, function (error, result) { + return __awaiter(this, void 0, void 0, function* () { + const errorRef = error + ? { name: error.name, message: error.message, stack: error.stack, severity: error.severity || 1 } + : null; + let redisResponse = { + error: errorRef, + result: result + }; + redisClient.lpush(req.reqId, JSON.stringify(redisResponse)); + }); + }); + } + }); + }); + } + brpop(); + }); +} +exports.server = server; +function disableServers() { + serversEnabled = false; + closeAllClients(); +} +exports.disableServers = disableServers; +function enableServers() { + serversEnabled = true; +} +exports.enableServers = enableServers; +function closeAllClients() { + clients.forEach(c => c.end(false)); +} +exports.closeAllClients = closeAllClients; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/js/lib/request_response/index.js.map b/js/lib/request_response/index.js.map new file mode 100644 index 0000000..1eef314 --- /dev/null +++ b/js/lib/request_response/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/lib/request_response/index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,8BAA6B;AAC7B,yCAAqC;AACrC,oCAAwC;AAExC,IAAI,OAAO,GAAG,EAAE,CAAA;AAChB,IAAI,cAAc,CAAA;AAElB,iBAA2B,WAAW,EAAE,OAAe,EAAE,IAAS;IAChE,OAAO,IAAI,OAAO,CAAC,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;QACpC,IAAI,aAAa,GAAG,IAAI,CAAA;QACxB,MAAM,KAAK,GAAG,EAAE,EAAE,CAAA;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACtB,MAAM,SAAS,GAAoB,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;QACvD,IAAI,OAAO,CAAA;QACX,IAAI,eAAe,CAAA;QACnB,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS,EAAE,CAAA;QAE3C,OAAO,GAAG,UAAU,CAAC;;gBACnB,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,QAAQ,CAAC,GAAG,KAAK,MAAM,CAAC,CAAA;gBAG3D,IAAI,CAAC,QAAQ,EAAE;oBACb,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nD,GAAG,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;oBAE1B,IAAI,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,eAAM,CAAC,qBAAqB,EAAE;wBACvD,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,UAAgB,KAAK,EAAE,MAAM;;gCAC9C,MAAM,QAAQ,GAAG,KAAK;oCACpB,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,CAAC,EAAE;oCACjG,CAAC,CAAC,IAAI,CAAA;gCAER,IAAI,aAAa,GAAqB;oCACpC,KAAK,EAAE,QAAQ;oCACf,MAAM,EAAE,MAAM;iCACf,CAAA;gCAED,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAA;4BAC7D,CAAC;yBAAA,CAAC,CAAA;qBACH;gBACH,CAAC;aAAA,CAAC,CAAA;QACJ,CAAC;QAED,KAAK,EAAE,CAAA;IACT,CAAC;CAAA;AAzCD,wBAyCC;AAED;IACE,cAAc,GAAG,KAAK,CAAA;IACtB,eAAe,EAAE,CAAA;AACnB,CAAC;AAHD,wCAGC;AAED;IACE,cAAc,GAAG,IAAI,CAAA;AACvB,CAAC;AAFD,sCAEC;AAED;IACE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;AACpC,CAAC;AAFD,0CAEC"} \ No newline at end of file diff --git a/js/test/pub_sub.spec.d.ts b/js/test/pub_sub.spec.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/js/test/pub_sub.spec.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/js/test/pub_sub.spec.js b/js/test/pub_sub.spec.js new file mode 100644 index 0000000..8b416ca --- /dev/null +++ b/js/test/pub_sub.spec.js @@ -0,0 +1,73 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const chai_1 = require("chai"); +const index_1 = require("../index"); +describe('pubsub', () => { + let epicurus; + beforeEach(() => { + epicurus = index_1.default(); + }); + afterEach(() => { + epicurus.close(); + }); + describe('subscribe', () => { + it('a subscriber receives the correct message as an object', (done) => { + const msg = { hello: 'world' }; + epicurus.subscribe('sampleChannel', (msgReceived) => { + chai_1.expect(msgReceived).to.eql({ hello: 'world', channel: 'sampleChannel' }); + done(); + }).then(() => { + epicurus.publish('sampleChannel', msg); + }).catch(done); + }); + it('subscribers are correctly selective on message identity', (done) => { + const msg = { hello: 'world' }; + epicurus.subscribe('sampleChannel', (msgReceived) => { + chai_1.expect(msgReceived).to.eql({ hello: 'world', channel: 'sampleChannel' }); + done(); + }).then(() => { + return epicurus.subscribe('settlementReserved', (msgReceived) => { + done(new Error('Incorrect sub block')); + }); + }).then(() => { + epicurus.publish('sampleChannel', msg); + }).catch(done); + }); + it('does not process a message after the shutdown event has been received', (done) => { + const msg = { hello: 'world' }; + epicurus.subscribe('sampleChannel', (msgReceived) => { + done(new Error('Message should not have been received')); + }).then(() => { + epicurus.shutdown(); + epicurus.publish('sampleChannel', msg); + setTimeout(() => { + done(); + }, 10); + }).catch(done); + }); + }); + describe('publish', () => { + it('is able to send a message to multiple subscribers', (done) => { + let count = 0; + const msg = { hello: 'world' }; + epicurus.subscribe('sampleChannel', (msgReceived) => { + chai_1.expect(msgReceived).to.eql({ hello: 'world', channel: 'sampleChannel' }); + count++; + if (count === 2) { + done(); + } + }).then(() => { + return epicurus.subscribe('sampleChannel', (msgReceived) => { + chai_1.expect(msgReceived).to.eql({ hello: 'world', channel: 'sampleChannel' }); + count++; + if (count === 2) { + done(); + } + }); + }).then(() => { + epicurus.publish('sampleChannel', msg); + }).catch(done); + }); + }); +}); +//# sourceMappingURL=pub_sub.spec.js.map \ No newline at end of file diff --git a/js/test/pub_sub.spec.js.map b/js/test/pub_sub.spec.js.map new file mode 100644 index 0000000..542bf8b --- /dev/null +++ b/js/test/pub_sub.spec.js.map @@ -0,0 +1 @@ +{"version":3,"file":"pub_sub.spec.js","sourceRoot":"","sources":["../../ts/test/pub_sub.spec.ts"],"names":[],"mappings":";;AAAA,+BAA6B;AAC7B,oCAA+B;AAE/B,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,IAAI,QAAqC,CAAA;IACzC,UAAU,CAAC,GAAG,EAAE;QACd,QAAQ,GAAG,eAAQ,EAAE,CAAA;IACvB,CAAC,CAAC,CAAA;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,QAAQ,CAAC,KAAK,EAAE,CAAA;IAClB,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;QACzB,EAAE,CAAC,wDAAwD,EAAE,CAAC,IAAI,EAAE,EAAE;YACpE,MAAM,GAAG,GAAG,EAAC,KAAK,EAAE,OAAO,EAAC,CAAA;YAE5B,QAAQ,CAAC,SAAS,CAAoB,eAAe,EAAE,CAAC,WAAW,EAAE,EAAE;gBACrE,aAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAC,CAAC,CAAA;gBACtE,IAAI,EAAE,CAAA;YACR,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;gBACX,QAAQ,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAA;YACxC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAChB,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,yDAAyD,EAAE,CAAC,IAAI,EAAE,EAAE;YACrE,MAAM,GAAG,GAAG,EAAC,KAAK,EAAE,OAAO,EAAC,CAAA;YAC5B,QAAQ,CAAC,SAAS,CAAC,e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AE,CAAC,mDAAmD,EAAE,CAAC,IAAI,EAAE,EAAE;YAC/D,IAAI,KAAK,GAAG,CAAC,CAAA;YACb,MAAM,GAAG,GAAG,EAAC,KAAK,EAAE,OAAO,EAAC,CAAA;YAE5B,QAAQ,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC,WAAW,EAAE,EAAE;gBAClD,aAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAC,CAAC,CAAA;gBACtE,KAAK,EAAE,CAAA;gBACP,IAAI,KAAK,KAAK,CAAC,EAAE;oBACf,IAAI,EAAE,CAAA;iBACP;YACH,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;gBACX,OAAO,QAAQ,CAAC,SAAS,CAAC,eAAe,EAAE,CAAC,WAAW,EAAE,EAAE;oBACzD,aAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,eAAe,EAAC,CAAC,CAAA;oBACtE,KAAK,EAAE,CAAA;oBACP,IAAI,KAAK,KAAK,CAAC,EAAE;wBACf,IAAI,EAAE,CAAA;qBACP;gBACH,CAAC,CAAC,CAAA;YACJ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;gBACX,QAAQ,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAA;YACxC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAEhB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/js/test/request_response.spec.d.ts b/js/test/request_response.spec.d.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/js/test/request_response.spec.d.ts @@ -0,0 +1 @@ +export {}; diff --git a/js/test/request_response.spec.js b/js/test/request_response.spec.js new file mode 100644 index 0000000..6fde319 --- /dev/null +++ b/js/test/request_response.spec.js @@ -0,0 +1,111 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const chai_1 = require("chai"); +const index_1 = require("../index"); +describe('request response', () => { + let epicurus; + beforeEach(() => { + epicurus = index_1.default(); + }); + afterEach(() => { + epicurus.close(); + }); + describe('request', () => { + it('a request returns a promise that is resolved when the server finishes its callback', () => __awaiter(this, void 0, void 0, function* () { + epicurus.server('sampleEndpoint', function (request, callback) { + callback(null, { msg: 'hello' }); + }); + const result = yield epicurus.request('sampleEndpoint', {}); + chai_1.expect(result).to.eql({ msg: 'hello' }); + })); + it('a request is appropriately selective', () => __awaiter(this, void 0, void 0, function* () { + epicurus.server('sampleEndpoint', function (request, callback) { + callback(null, { msg: 'hello' }); + }); + epicurus.server('nonValidEndpoint', function (request, callback) { + callback(null, { msg: 'goodbye' }); + }); + const result = yield epicurus.request('sampleEndpoint', {}); + chai_1.expect(result).to.eql({ msg: 'hello' }); + })); + it('a request can receive multiple responses from the one server', () => __awaiter(this, void 0, void 0, function* () { + epicurus.server('sampleEndpoint', function (request, callback) { + callback(null, { msg: 'hello' }); + }); + const result = yield epicurus.request('sampleEndpoint', {}); + chai_1.expect(result).to.eql({ msg: 'hello' }); + const resultTwo = yield epicurus.request('sampleEndpoint', {}); + chai_1.expect(resultTwo).to.eql({ msg: 'hello' }); + const resultThree = yield epicurus.request('sampleEndpoint', {}); + chai_1.expect(resultThree).to.eql({ msg: 'hello' }); + })); + it('a request promise will be rejected if the server callbacks with an error', (done) => { + epicurus.server('sampleEndpoint', function (request, callback) { + callback(new Error('Err')); + }); + epicurus.request('sampleEndpoint', {}).catch((e) => { + chai_1.expect(e.name).to.eql('Error'); + chai_1.expect(e.message).to.eql('Err'); + done(); + }); + }); + it('only a single server receives a request', () => __awaiter(this, void 0, void 0, function* () { + let count = 0; + epicurus.server('sampleEndpoint', function (request, callback) { + count++; + callback(null, { msg: 'hello' }); + }); + epicurus.server('sampleEndpoint', function (request, callback) { + count++; + callback(null, { msg: 'hello' }); + }); + const result = yield epicurus.request('sampleEndpoint', {}); + chai_1.expect(result).to.eql({ msg: 'hello' }); + chai_1.expect(count).to.eql(1); + })); + it('a server receives a request with the channel on it', () => __awaiter(this, void 0, void 0, function* () { + let serverChannelName = ''; + epicurus.server('sampleEndpoint', function (request, callback) { + serverChannelName = request.channel; + callback(null, { msg: 'hello' }); + }); + yield epicurus.request('sampleEndpoint', {}); + chai_1.expect(serverChannelName).to.eql('sampleEndpoint'); + })); + it('a server stops processing requests when shutdown is called', () => __awaiter(this, void 0, void 0, function* () { + const epicurusTwo = index_1.default(); + let count = 0; + let countTwo = 0; + epicurus.server('sampleEndpoint', (request, callback) => { + count++; + callback(null, { msg: 'hello' }); + }); + yield epicurus.request('sampleEndpoint', {}); + epicurus.shutdown(); + yield Promise.all([ + epicurus.request('sampleEndpoint', {}).then(() => { + chai_1.expect(count).to.eql(1); + chai_1.expect(countTwo).to.eql(1); + }), + new Promise((res, rej) => { + setTimeout(() => { + res(); + epicurusTwo.server('sampleEndpoint', (request, callback) => { + countTwo++; + callback(null, { msg: 'hello' }); + }); + }, 20); + }) + ]); + })); + }); +}); +//# sourceMappingURL=request_response.spec.js.map \ No newline at end of file diff --git a/js/test/request_response.spec.js.map b/js/test/request_response.spec.js.map new file mode 100644 index 0000000..6fdda4a --- /dev/null +++ b/js/test/request_response.spec.js.map @@ -0,0 +1 @@ +{"version":3,"file":"request_response.spec.js","sourceRoot":"","sources":["../../ts/test/request_response.spec.ts"],"names":[],"mappings":";;;;;;;;;;AA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,WAAW,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;4BACzD,QAAQ,EAAE,CAAA;4BACV,QAAQ,CAAC,IAAI,EAAE,EAAC,GAAG,EAAE,OAAO,EAAC,CAAC,CAAA;wBAChC,CAAC,CAAC,CAAA;oBACJ,CAAC,EAAE,EAAE,CAAC,CAAA;gBACR,CAAC,CAAC;aACH,CAAC,CAAA;QACJ,CAAC,CAAA,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"} \ No newline at end of file From e6e11a85b264c3cd229835a07f3e41cdced3c901 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Mon, 17 May 2021 11:32:32 +0300 Subject: [PATCH 03/64] AUTH-75. Add error status to server response --- ts/lib/request_response/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts/lib/request_response/index.ts b/ts/lib/request_response/index.ts index 84d0190..6326915 100644 --- a/ts/lib/request_response/index.ts +++ b/ts/lib/request_response/index.ts @@ -97,7 +97,7 @@ export async function server(redisClient, channel: string, callback: serve if (req.ttl > Date.now() - config.requestValidityPeriod) { callback(req.body, async function (error, result) { const errorRef = error - ? { name: error.name, message: error.message, stack: error.stack, severity: error.severity || 1 } + ? { name: error.name, message: error.message, stack: error.stack, severity: error.severity || 1, status: error.status } : null let redisResponse: EpicurusResponse = { From 212aa7ef9f0eee2f58e8225717fdfeb45f65812d Mon Sep 17 00:00:00 2001 From: Dmytro Date: Mon, 17 May 2021 11:33:32 +0300 Subject: [PATCH 04/64] AUTH-75. Up to v.0.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3484dac..3846f0d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "epicurus-node", - "version": "0.3.0", + "version": "0.3.1", "description": "Redis request/response and PubSub sugar", "main": "js/index.js", "types": "js/index.d.ts", From ae07422a8a5df1e9ac2400be97a407d266f098a5 Mon Sep 17 00:00:00 2001 From: abhinavpaliwal271contentstack Date: Mon, 17 May 2021 14:16:32 +0530 Subject: [PATCH 05/64] AUTH-75 | Upgrade minor version --- package.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 3846f0d..e2e95ed 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,15 @@ { - "name": "epicurus-node", - "version": "0.3.1", + "name": "@contentstack/epicurus-node", + "version": "0.3.2", "description": "Redis request/response and PubSub sugar", "main": "js/index.js", "types": "js/index.d.ts", "files": [ "js/" ], + "publishConfig": { + "registry": "https://npm.pkg.github.com" + }, "scripts": { "prepublish": "npm run lint && rm -rf js/* && tsc --sourcemap -p ts/", "lint": "tslint 'ts/**/*.ts'", @@ -15,7 +18,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/ABXTrading/epicurus-node.git" + "url": "git+https://github.com/contentstack/epicurus-node.git" }, "keywords": [ "Redis" From 5ec29d89199c2d0711d1e76fb2769d51e0ebfae6 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Mon, 17 May 2021 11:51:17 +0300 Subject: [PATCH 06/64] AUTH-75. Up to v.0.3.2 --- js/lib/request_response/index.js | 2 +- js/lib/request_response/index.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/lib/request_response/index.js b/js/lib/request_response/index.js index ecd27f2..fcf5784 100644 --- a/js/lib/request_response/index.js +++ b/js/lib/request_response/index.js @@ -100,7 +100,7 @@ function server(redisClient, channel, callback) { callback(req.body, function (error, result) { return __awaiter(this, void 0, void 0, function* () { const errorRef = error - ? { name: error.name, message: error.message, stack: error.stack, severity: error.severity || 1 } + ? { name: error.name, message: error.message, stack: error.stack, severity: error.severity || 1, status: error.status } : null; let redisResponse = { error: errorRef, diff --git a/js/lib/request_response/index.js.map b/js/lib/request_response/index.js.map index 1eef314..3be7f10 100644 --- a/js/lib/request_response/index.js.map +++ b/js/lib/request_response/index.js.map @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AAI,CAAA;gCAER,IAAI,aAAa,GAAqB;oCACpC,KAAK,EAAE,QAAQ;oCACf,MAAM,EAAE,MAAM;iCACf,CAAA;gCAED,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAA;4BAC7D,CAAC;yBAAA,CAAC,CAAA;qBACH;gBACH,CAAC;aAAA,CAAC,CAAA;QACJ,CAAC;QAED,KAAK,EAAE,CAAA;IACT,CAAC;CAAA;AAzCD,wBAyCC;AAED;IACE,cAAc,GAAG,KAAK,CAAA;IACtB,eAAe,EAAE,CAAA;AACnB,CAAC;AAHD,wCAGC;AAED;IACE,cAAc,GAAG,IAAI,CAAA;AACvB,CAAC;AAFD,sCAEC;AAED;IACE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;AACpC,CAAC;AAFD,0CAEC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/lib/request_response/index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,8BAA6B;AAC7B,yCAAqC;AACrC,oCAAwC;AAExC,IAAI,OAAO,GAAG,EAAE,CAAA;AAChB,IAAI,cAAc,CAAA;AAElB,iBAA2B,WAAW,EAAE,OAAe,EAAE,IAAS;IAChE,OAAO,IAAI,OAAO,CAAC,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;QACpC,IAAI,aAAa,GAAG,IAAI,CAAA;QACxB,MAAM,KAAK,GAAG,EAAE,EAAE,CAAA;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACtB,MAAM,SAAS,GAAoB,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;QACvD,IAAI,OAAO,CAAA;QACX,IAAI,eAAe,CAAA;QACnB,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS,EAAE,CAAA;QAE3C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AACpC,CAAC;AAFD,0CAEC"} \ No newline at end of file From 3351237258bc3fabb223d79cd6b51cf84e9f793e Mon Sep 17 00:00:00 2001 From: Dmytro Date: Mon, 17 May 2021 12:02:25 +0300 Subject: [PATCH 07/64] AUTH-75. Add error status to request error handling --- ts/lib/error.ts | 2 +- ts/lib/request_response/index.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ts/lib/error.ts b/ts/lib/error.ts index ad996da..e6edfdb 100644 --- a/ts/lib/error.ts +++ b/ts/lib/error.ts @@ -22,7 +22,7 @@ export class EpicurusError extends Error { this.name = meta.name || this.name this.context = meta.context this.stack = (new Error()).stack - this.status = meta.stack || meta.status + this.status = meta.status || meta.stack this.severity = meta.severity } diff --git a/ts/lib/request_response/index.ts b/ts/lib/request_response/index.ts index 6326915..2ad5b10 100644 --- a/ts/lib/request_response/index.ts +++ b/ts/lib/request_response/index.ts @@ -52,6 +52,7 @@ export function request(redisClient, channel: string, body: any): Promise if (response.error) { rej(new EpicurusError(response.error.message, { + status: response.error.status, severity: response.error.severity, context: { context: { originalRequest: body, channel: channel }, From dde3b6136dc2428ca25636098c530674f619cba7 Mon Sep 17 00:00:00 2001 From: Dmytro Date: Mon, 17 May 2021 12:07:49 +0300 Subject: [PATCH 08/64] AUTH-75. Add error status to request error handling --- js/lib/error.js | 2 +- js/lib/error.js.map | 2 +- js/lib/request_response/index.js | 1 + js/lib/request_response/index.js.map | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/js/lib/error.js b/js/lib/error.js index f526d2b..9f917bf 100644 --- a/js/lib/error.js +++ b/js/lib/error.js @@ -7,7 +7,7 @@ class EpicurusError extends Error { this.name = meta.name || this.name; this.context = meta.context; this.stack = new Error().stack; - this.status = meta.stack || meta.status; + this.status = meta.status || meta.stack; this.severity = meta.severity; } toString() { diff --git a/js/lib/error.js.map b/js/lib/error.js.map index 54be11b..3c08b30 100644 --- a/js/lib/error.js.map +++ b/js/lib/error.js.map @@ -1 +1 @@ -{"version":3,"file":"error.js","sourceRoot":"","sources":["../../ts/lib/error.ts"],"names":[],"mappings":";;AAAA,mBAA2B,SAAQ,KAAK;IAMtC,YACE,OAAe,EACf,IASC;QAED,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;QAChE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC3B,IAAI,CAAC,KAAK,GAAS,IAAI,KAAK,EAAG,CAAC,KAAK,CAAA;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,CAAA;QACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;IAC/B,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,OAAO,CAAA;IACxC,CAAC;CACF;AA/BD,sCA+BC"} \ No newline at end of file +{"version":3,"file":"error.js","sourceRoot":"","sources":["../../ts/lib/error.ts"],"names":[],"mappings":";;AAAA,mBAA2B,SAAQ,KAAK;IAMtC,YACE,OAAe,EACf,IASC;QAED,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,MAAM,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;QAChE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAA;QAC3B,IAAI,CAAC,KAAK,GAAS,IAAI,KAAK,EAAG,CAAC,KAAK,CAAA;QACrC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAA;QACvC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;IAC/B,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,OAAO,CAAA;IACxC,CAAC;CACF;AA/BD,sCA+BC"} \ No newline at end of file diff --git a/js/lib/request_response/index.js b/js/lib/request_response/index.js index fcf5784..4d86dc7 100644 --- a/js/lib/request_response/index.js +++ b/js/lib/request_response/index.js @@ -57,6 +57,7 @@ function request(redisClient, channel, body) { const response = JSON.parse(redisResponse); if (response.error) { rej(new error_1.EpicurusError(response.error.message, { + status: response.error.status, severity: response.error.severity, context: { context: { originalRequest: body, channel: channel }, diff --git a/js/lib/request_response/index.js.map b/js/lib/request_response/index.js.map index 3be7f10..248121e 100644 --- a/js/lib/request_response/index.js.map +++ b/js/lib/request_response/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/lib/request_response/index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,8BAA6B;AAC7B,yCAAqC;AACrC,oCAAwC;AAExC,IAAI,OAAO,GAAG,EAAE,CAAA;AAChB,IAAI,cAAc,CAAA;AAElB,iBAA2B,WAAW,EAAE,OAAe,EAAE,IAAS;IAChE,OAAO,IAAI,OAAO,CAAC,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;QACpC,IAAI,aAAa,GAAG,IAAI,CAAA;QACxB,MAAM,KAAK,GAAG,EAAE,EAAE,CAAA;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACtB,MAAM,SAAS,GAAoB,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;QACvD,IAAI,OAAO,CAAA;QACX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,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;AACpC,CAAC;AAFD,0CAEC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/lib/request_response/index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,8BAA6B;AAC7B,yCAAqC;AACrC,oCAAwC;AAExC,IAAI,OAAO,GAAG,EAAE,CAAA;AAChB,IAAI,cAAc,CAAA;AAElB,iBAA2B,WAAW,EAAE,OAAe,EAAE,IAAS;IAChE,OAAO,IAAI,OAAO,CAAC,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;QACpC,IAAI,aAAa,GAAG,IAAI,CAAA;QACxB,MAAM,KAAK,GAAG,EAAE,EAAE,CAAA;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACtB,MAAM,SAAS,GAAoB,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;QACvD,IAAI,OAAO,CAAA;QACX,IAAI,eAAe,CAAA;QACnB,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS,EAAE,CAAA;QAE3C,OAAO,GAAG,UAAU,CAAC;;gBACnB,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,QAAQ,CAAC,GAAG,KAAK,MAAM,CAAC,CAAA;gBAG3D,IAAI,CAAC,QAAQ,EAAE;oBACb,eAAe,GAAG,UAAU,CAAC;;4BAC3B,GAAG,CAAC,IAAI,qBAAa,CAAC,yBAAyB,EAAE;gCAC/C,OAAO,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE;gCACpD,QAAQ,EAAE,CAAC;6BACZ,CAAC,CAAC,CAAA;4BAEH,aAAa,GAAG,KAAK,CAAA;4BACrB,WAAW,CAAC,IAAI,EAAE,CAAA;wBACpB,CAAC;qBAAA,EAAE,eAAM,CAAC,qBAAqB,CAAC,CAAA;iBACjC;qBAAM;oBACL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IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;oCACvH,CAAC,CAAC,IAAI,CAAA;gCAER,IAAI,aAAa,GAAqB;oCACpC,KAAK,EAAE,QAAQ;oCACf,MAAM,EAAE,MAAM;iCACf,CAAA;gCAED,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAA;4BAC7D,CAAC;yBAAA,CAAC,CAAA;qBACH;gBACH,CAAC;aAAA,CAAC,CAAA;QACJ,CAAC;QAED,KAAK,EAAE,CAAA;IACT,CAAC;CAAA;AAzCD,wBAyCC;AAED;IACE,cAAc,GAAG,KAAK,CAAA;IACtB,eAAe,EAAE,CAAA;AACnB,CAAC;AAHD,wCAGC;AAED;IACE,cAAc,GAAG,IAAI,CAAA;AACvB,CAAC;AAFD,sCAEC;AAED;IACE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;AACpC,CAAC;AAFD,0CAEC"} \ No newline at end of file From 9b6aa2d6c35d3f40f8df6466de788813f8d49191 Mon Sep 17 00:00:00 2001 From: anujcontentstack Date: Tue, 3 Aug 2021 13:15:35 +0530 Subject: [PATCH 09/64] AUTH-98 | Reduce requestValidityPeriod from 10s to 1s --- js/config.js | 2 +- js/config.js.map | 2 +- package-lock.json | 4 +-- package.json | 2 +- ts/config.ts | 2 +- ts/index.ts | 43 ++++++++++++++++++++++++-------- ts/lib/request_response/index.ts | 19 ++++++++------ 7 files changed, 51 insertions(+), 23 deletions(-) diff --git a/js/config.js b/js/config.js index 286d043..0e6b7e8 100644 --- a/js/config.js +++ b/js/config.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.config = { - requestValidityPeriod: 10000 + requestValidityPeriod: 1 * 1000 }; //# sourceMappingURL=config.js.map \ No newline at end of file diff --git a/js/config.js.map b/js/config.js.map index 6843f87..0b90ddc 100644 --- a/js/config.js.map +++ b/js/config.js.map @@ -1 +1 @@ -{"version":3,"file":"config.js","sourceRoot":"","sources":["../ts/config.ts"],"names":[],"mappings":";;AAAa,QAAA,MAAM,GAAG;IACpB,qBAAqB,EAAE,KAAK;CAC7B,CAAA"} \ No newline at end of file +{"version":3,"file":"config.js","sourceRoot":"","sources":["../ts/config.ts"],"names":[],"mappings":";;AAAa,QAAA,MAAM,GAAG;IACpB,qBAAqB,EAAE,CAAC,GAAG,IAAI;CAChC,CAAA"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 4f511f9..977106c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { - "name": "epicurus-node", - "version": "0.3.0", + "name": "@contentstack/epicurus-node", + "version": "0.3.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index e2e95ed..ec8f2e5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/epicurus-node", - "version": "0.3.2", + "version": "0.3.4", "description": "Redis request/response and PubSub sugar", "main": "js/index.js", "types": "js/index.d.ts", diff --git a/ts/config.ts b/ts/config.ts index 20c6e17..6001dea 100644 --- a/ts/config.ts +++ b/ts/config.ts @@ -1,3 +1,3 @@ export const config = { - requestValidityPeriod: 10000 // milliseconds + requestValidityPeriod: 1 * 1000 // milliseconds } diff --git a/ts/index.ts b/ts/index.ts index cd74104..c8609c8 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,21 +1,44 @@ -import { subscribe, publish, setupSubscriptionListener, removeCallbacks, shutdownSubscribers } from './lib/pub_sub' -import { request, server, closeAllClients, enableServers, disableServers } from './lib/request_response' -import { EpicurusRedisConfig, serverCallback, subscribeCallback } from './interface' -import * as redis from 'redis' import * as bluebird from 'bluebird' +import * as redis from 'redis' import { RedisClient } from 'redis' + +import { config } from './config' +import { + EpicurusRedisConfig, + serverCallback, + subscribeCallback, +} from './interface' +import { + publish, + removeCallbacks, + setupSubscriptionListener, + shutdownSubscribers, + subscribe, +} from './lib/pub_sub' +import { + closeAllClients, + disableServers, + enableServers, + request, + server, +} from './lib/request_response' + bluebird.promisifyAll(redis.RedisClient.prototype) bluebird.promisifyAll(redis.Multi.prototype) -export default function Epicurus (redisConfig: EpicurusRedisConfig = { - host: 'localhost', - port: 6379 -}): EpicurusPublicInterface { +export default function Epicurus ( + redisConfig: EpicurusRedisConfig = { + host: 'localhost', + port: 6379 + }, + requestTimeout?: number +): EpicurusPublicInterface { // A separate subscription Redis client is required as once a client has // called SUBSCRIBE, it is put into a slave mode the does not allow any other // kind of action const redisClient = redis.createClient(redisConfig) const redisSub = redis.createClient(redisConfig) + const requestValidityPeriod = requestTimeout || config.requestValidityPeriod setupSubscriptionListener(redisSub) enableServers() @@ -25,8 +48,8 @@ export default function Epicurus (redisConfig: EpicurusRedisConfig = { getRedisSubClient: () => redisSub, subscribe: (channel: string, callback: subscribeCallback) => subscribe(redisSub, channel, callback), publish: (channel: string, body: any) => publish(redisClient, channel, body), - server: (channel: string, callback: serverCallback) => server(redisClient, channel, callback), - request: (channel: string, body: any) => request(redisClient, channel, body), + server: (channel: string, callback: serverCallback) => server(redisClient, channel, callback, requestValidityPeriod), + request: (channel: string, body: any) => request(redisClient, channel, body, requestValidityPeriod), shutdown: () => { shutdownSubscribers() disableServers() diff --git a/ts/lib/request_response/index.ts b/ts/lib/request_response/index.ts index 2ad5b10..874cb84 100644 --- a/ts/lib/request_response/index.ts +++ b/ts/lib/request_response/index.ts @@ -1,11 +1,16 @@ import * as v4 from 'uuid/v4' -import { config } from '../../config' + +import { + EpicurusRequest, + EpicurusResponse, + serverCallback, +} from '../../interface' import { EpicurusError } from '../error' -import { EpicurusRequest, EpicurusResponse, serverCallback } from '../../interface' + let clients = [] let serversEnabled -export function request(redisClient, channel: string, body: any): Promise { +export function request(redisClient, channel: string, body: any, requestValidityPeriod: number): Promise { return new Promise(async (res, rej) => { let responseValid = true const reqId = v4() @@ -28,7 +33,7 @@ export function request(redisClient, channel: string, body: any): Promise responseValid = false clientClone.quit() - }, config.requestValidityPeriod) + }, requestValidityPeriod) } else { rej(new EpicurusError('Server not found', { context: { originalRequest: body, channel: channel }, @@ -38,7 +43,7 @@ export function request(redisClient, channel: string, body: any): Promise responseValid = false clientClone.quit() } - }, config.requestValidityPeriod + 100) + }, requestValidityPeriod + 100) clientClone.brpop(reqId, 0, function (_null, popInfo) { clearTimeout(timeout) @@ -72,7 +77,7 @@ export function request(redisClient, channel: string, body: any): Promise }) } -export async function server(redisClient, channel: string, callback: serverCallback): Promise { +export async function server(redisClient, channel: string, callback: serverCallback, serverValidityPeriod: number): Promise { const clientClone = redisClient.duplicate() clients.push(clientClone) @@ -95,7 +100,7 @@ export async function server(redisClient, channel: string, callback: serve const req: EpicurusRequest = JSON.parse(rawRequest) req.body.channel = channel - if (req.ttl > Date.now() - config.requestValidityPeriod) { + if (req.ttl > Date.now() - serverValidityPeriod) { callback(req.body, async function (error, result) { const errorRef = error ? { name: error.name, message: error.message, stack: error.stack, severity: error.severity || 1, status: error.status } From a96a2fc53d035d9cb38de466c7d449c3db952894 Mon Sep 17 00:00:00 2001 From: anujcontentstack Date: Tue, 3 Aug 2021 19:33:05 +0530 Subject: [PATCH 10/64] AUTH-98 | Run compile for epicurus package --- js/index.d.ts | 4 ++-- js/index.js | 12 +++++++----- js/index.js.map | 2 +- js/lib/request_response/index.d.ts | 4 ++-- js/lib/request_response/index.js | 11 +++++------ js/lib/request_response/index.js.map | 2 +- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/js/index.d.ts b/js/index.d.ts index 8a1ee98..7b3c27f 100644 --- a/js/index.d.ts +++ b/js/index.d.ts @@ -1,6 +1,6 @@ -import { EpicurusRedisConfig, serverCallback, subscribeCallback } from './interface'; import { RedisClient } from 'redis'; -export default function Epicurus(redisConfig?: EpicurusRedisConfig): EpicurusPublicInterface; +import { EpicurusRedisConfig, serverCallback, subscribeCallback } from './interface'; +export default function Epicurus(redisConfig?: EpicurusRedisConfig, requestTimeout?: number): EpicurusPublicInterface; export declare type EpicurusPublicInterface = { getRedisClient: () => RedisClient; getRedisSubClient: () => RedisClient; diff --git a/js/index.js b/js/index.js index ffa000d..4bd422d 100644 --- a/js/index.js +++ b/js/index.js @@ -1,17 +1,19 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +const bluebird = require("bluebird"); +const redis = require("redis"); +const config_1 = require("./config"); const pub_sub_1 = require("./lib/pub_sub"); const request_response_1 = require("./lib/request_response"); -const redis = require("redis"); -const bluebird = require("bluebird"); bluebird.promisifyAll(redis.RedisClient.prototype); bluebird.promisifyAll(redis.Multi.prototype); function Epicurus(redisConfig = { host: 'localhost', port: 6379 -}) { +}, requestTimeout) { const redisClient = redis.createClient(redisConfig); const redisSub = redis.createClient(redisConfig); + const requestValidityPeriod = requestTimeout || config_1.config.requestValidityPeriod; pub_sub_1.setupSubscriptionListener(redisSub); request_response_1.enableServers(); return { @@ -19,8 +21,8 @@ function Epicurus(redisConfig = { getRedisSubClient: () => redisSub, subscribe: (channel, callback) => pub_sub_1.subscribe(redisSub, channel, callback), publish: (channel, body) => pub_sub_1.publish(redisClient, channel, body), - server: (channel, callback) => request_response_1.server(redisClient, channel, callback), - request: (channel, body) => request_response_1.request(redisClient, channel, body), + server: (channel, callback) => request_response_1.server(redisClient, channel, callback, requestValidityPeriod), + request: (channel, body) => request_response_1.request(redisClient, channel, body, requestValidityPeriod), shutdown: () => { pub_sub_1.shutdownSubscribers(); request_response_1.disableServers(); diff --git a/js/index.js.map b/js/index.js.map index 1f6e184..238c27a 100644 --- a/js/index.js.map +++ b/js/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;AAAA,2CAAmH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AAU,OAAe,EAAE,IAAS,EAAE,EAAE,CAAC,0BAAO,CAAI,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,qBAAqB,CAAC;QAC/G,QAAQ,EAAE,GAAG,EAAE;YACb,6BAAmB,EAAE,CAAA;YACrB,iCAAc,EAAE,CAAA;QAClB,CAAC;QACD,KAAK,EAAE,GAAG,EAAE;YACV,QAAQ,CAAC,WAAW,EAAE,CAAA;YACtB,QAAQ,CAAC,IAAI,EAAE,CAAA;YACf,WAAW,CAAC,IAAI,EAAE,CAAA;YAClB,yBAAe,EAAE,CAAA;YACjB,kCAAe,EAAE,CAAA;QACnB,CAAC;KACF,CAAA;AACH,CAAC;AApCD,2BAoCC"} \ No newline at end of file diff --git a/js/lib/request_response/index.d.ts b/js/lib/request_response/index.d.ts index 6fe6e23..da9eda2 100644 --- a/js/lib/request_response/index.d.ts +++ b/js/lib/request_response/index.d.ts @@ -1,6 +1,6 @@ import { serverCallback } from '../../interface'; -export declare function request(redisClient: any, channel: string, body: any): Promise; -export declare function server(redisClient: any, channel: string, callback: serverCallback): Promise; +export declare function request(redisClient: any, channel: string, body: any, requestValidityPeriod: number): Promise; +export declare function server(redisClient: any, channel: string, callback: serverCallback, serverValidityPeriod: number): Promise; export declare function disableServers(): void; export declare function enableServers(): void; export declare function closeAllClients(): void; diff --git a/js/lib/request_response/index.js b/js/lib/request_response/index.js index 4d86dc7..ab06695 100644 --- a/js/lib/request_response/index.js +++ b/js/lib/request_response/index.js @@ -9,11 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }; Object.defineProperty(exports, "__esModule", { value: true }); const v4 = require("uuid/v4"); -const config_1 = require("../../config"); const error_1 = require("../error"); let clients = []; let serversEnabled; -function request(redisClient, channel, body) { +function request(redisClient, channel, body, requestValidityPeriod) { return new Promise((res, rej) => __awaiter(this, void 0, void 0, function* () { let responseValid = true; const reqId = v4(); @@ -35,7 +34,7 @@ function request(redisClient, channel, body) { responseValid = false; clientClone.quit(); }); - }, config_1.config.requestValidityPeriod); + }, requestValidityPeriod); } else { rej(new error_1.EpicurusError('Server not found', { @@ -46,7 +45,7 @@ function request(redisClient, channel, body) { clientClone.quit(); } }); - }, config_1.config.requestValidityPeriod + 100); + }, requestValidityPeriod + 100); clientClone.brpop(reqId, 0, function (_null, popInfo) { clearTimeout(timeout); clearTimeout(timeoutFallback); @@ -76,7 +75,7 @@ function request(redisClient, channel, body) { })); } exports.request = request; -function server(redisClient, channel, callback) { +function server(redisClient, channel, callback, serverValidityPeriod) { return __awaiter(this, void 0, void 0, function* () { const clientClone = redisClient.duplicate(); clients.push(clientClone); @@ -97,7 +96,7 @@ function server(redisClient, channel, callback) { yield redisClient.delAsync(`${reqId}-ref`); const req = JSON.parse(rawRequest); req.body.channel = channel; - if (req.ttl > Date.now() - config_1.config.requestValidityPeriod) { + if (req.ttl > Date.now() - serverValidityPeriod) { callback(req.body, function (error, result) { return __awaiter(this, void 0, void 0, function* () { const errorRef = error diff --git a/js/lib/request_response/index.js.map b/js/lib/request_response/index.js.map index 248121e..0afb236 100644 --- a/js/lib/request_response/index.js.map +++ b/js/lib/request_response/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/lib/request_response/index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,8BAA6B;AAC7B,yCAAqC;AACrC,oCAAwC;AAExC,IAAI,OAAO,GAAG,EAAE,CAAA;AAChB,IAAI,cAAc,CAAA;AAElB,iBAA2B,WAAW,EAAE,OAAe,EAAE,IAAS;IAChE,OAAO,IAAI,OAAO,CAAC,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;QACpC,IAAI,aAAa,GAAG,IAAI,CAAA;QACxB,MAAM,KAAK,GAAG,EAAE,EAAE,CAAA;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACtB,MAAM,SAAS,GAAoB,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;QACv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cAAc,GAAG,IAAI,CAAA;AACvB,CAAC;AAFD,sCAEC;AAED;IACE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;AACpC,CAAC;AAFD,0CAEC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/lib/request_response/index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,8BAA6B;AAO7B,oCAAwC;AAExC,IAAI,OAAO,GAAG,EAAE,CAAA;AAChB,IAAI,cAAc,CAAA;AAElB,iBAA2B,WAAW,EAAE,OAAe,EAAE,IAAS,EAAE,qBAA6B;IAC/F,OAAO,IAAI,OAAO,CAAC,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;QACpC,IAAI,aAAa,GAAG,IAAI,CAAA;QACxB,MAAM,KAAK,GAAG,EAAE,EAAE,CAAA;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACtB,MAAM,SAAS,GAAoB,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;QACvD,IAAI,OAAO,CAAA;QACX,IAAI,eAAe,CAAA;QACnB,MAAM,WAAW,GAAG,WAAW,CAAC,SAAS,EAAE,CAAA;QAE3C,OAAO,GAAG,UAAU,CAAC;;gBACnB,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,QAAQ,CAAC,GAAG,KAAK,MAAM,CAAC,CAAA;gBAG3D,IAAI,CAAC,QAAQ,EAAE;oBACb,eAAe,GAAG,UAAU,CAAC;;4BAC3B,GAAG,CAAC,IAAI,qBAAa,CAAC,yBAAyB,EAAE;gCAC/C,OAAO,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE;gCACpD,QAAQ,EAAE,CAAC;6BACZ,CAAC,CAAC,CAAA;4BAEH,aAAa,GAAG,KAAK,CAAA;4BACrB,WAAW,CAAC,IAAI,EAAE,CAAA;w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G,KAAK;oCACpB,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE;oCACvH,CAAC,CAAC,IAAI,CAAA;gCAER,IAAI,aAAa,GAAqB;oCACpC,KAAK,EAAE,QAAQ;oCACf,MAAM,EAAE,MAAM;iCACf,CAAA;gCAED,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAA;4BAC7D,CAAC;yBAAA,CAAC,CAAA;qBACH;gBACH,CAAC;aAAA,CAAC,CAAA;QACJ,CAAC;QAED,KAAK,EAAE,CAAA;IACT,CAAC;CAAA;AAzCD,wBAyCC;AAED;IACE,cAAc,GAAG,KAAK,CAAA;IACtB,eAAe,EAAE,CAAA;AACnB,CAAC;AAHD,wCAGC;AAED;IACE,cAAc,GAAG,IAAI,CAAA;AACvB,CAAC;AAFD,sCAEC;AAED;IACE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;AACpC,CAAC;AAFD,0CAEC"} \ No newline at end of file From 002b6ecf6a868d502d9da27767be5fa6e7e150b2 Mon Sep 17 00:00:00 2001 From: nandeesh-gajula <69522367+nandeesh-gajula@users.noreply.github.com> Date: Wed, 13 Oct 2021 13:10:43 +0530 Subject: [PATCH 11/64] Create CODEOWNERS --- CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 CODEOWNERS diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..da6db11 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @contentstack/security-admin @contentstack/ecosystem-admin From 4a4d76ffc3f212378a61bb24bb0ce0813642b856 Mon Sep 17 00:00:00 2001 From: anujcontentstack Date: Fri, 10 Dec 2021 12:51:14 +0530 Subject: [PATCH 12/64] AUTH-165 | Remove serverValidityPeriod check and add a ttl on redis response lpush --- js/lib/request_response/index.js | 26 +++++++++++----------- js/lib/request_response/index.js.map | 2 +- ts/lib/request_response/index.ts | 33 ++++++++++++++-------------- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/js/lib/request_response/index.js b/js/lib/request_response/index.js index ab06695..7bafe92 100644 --- a/js/lib/request_response/index.js +++ b/js/lib/request_response/index.js @@ -77,6 +77,7 @@ function request(redisClient, channel, body, requestValidityPeriod) { exports.request = request; function server(redisClient, channel, callback, serverValidityPeriod) { return __awaiter(this, void 0, void 0, function* () { + const REDIS_RESPONSE_TTL_IN_SECONDS = 1; const clientClone = redisClient.duplicate(); clients.push(clientClone); function brpop() { @@ -96,20 +97,19 @@ function server(redisClient, channel, callback, serverValidityPeriod) { yield redisClient.delAsync(`${reqId}-ref`); const req = JSON.parse(rawRequest); req.body.channel = channel; - if (req.ttl > Date.now() - serverValidityPeriod) { - callback(req.body, function (error, result) { - return __awaiter(this, void 0, void 0, function* () { - const errorRef = error - ? { name: error.name, message: error.message, stack: error.stack, severity: error.severity || 1, status: error.status } - : null; - let redisResponse = { - error: errorRef, - result: result - }; - redisClient.lpush(req.reqId, JSON.stringify(redisResponse)); - }); + callback(req.body, function (error, result) { + return __awaiter(this, void 0, void 0, function* () { + const errorRef = error + ? { name: error.name, message: error.message, stack: error.stack, severity: error.severity || 1, status: error.status } + : null; + let redisResponse = { + error: errorRef, + result: result + }; + redisClient.lpush(req.reqId, JSON.stringify(redisResponse)); + redisClient.expire(req.reqId, REDIS_RESPONSE_TTL_IN_SECONDS); }); - } + }); }); }); } diff --git a/js/lib/request_response/index.js.map b/js/lib/request_response/index.js.map index 0afb236..e95a768 100644 --- a/js/lib/request_response/index.js.map +++ b/js/lib/request_response/index.js.map @@ -1 +1 @@ -{"version":3,"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E,KAAK,CAAC,MAAM,EAAE;oCACvH,CAAC,CAAC,IAAI,CAAA;gCAER,IAAI,aAAa,GAAqB;oCACpC,KAAK,EAAE,QAAQ;oCACf,MAAM,EAAE,MAAM;iCACf,CAAA;gCAED,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAA;4BAC7D,CAAC;yBAAA,CAAC,CAAA;qBACH;gBACH,CAAC;aAAA,CAAC,CAAA;QACJ,CAAC;QAED,KAAK,EAAE,CAAA;IACT,CAAC;CAAA;AAzCD,wBAyCC;AAED;IACE,cAAc,GAAG,KAAK,CAAA;IACtB,eAAe,EAAE,CAAA;AACnB,CAAC;AAHD,wCAGC;AAED;IACE,cAAc,GAAG,IAAI,CAAA;AACvB,CAAC;AAFD,sCAEC;AAED;IACE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;AACpC,CAAC;AAFD,0CAEC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../ts/lib/request_response/index.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,8BAA6B;AAO7B,oCAAwC;AAExC,IAAI,OAAO,GAAG,EAAE,CAAA;AAChB,IAAI,cAAc,CAAA;AAElB,iBAA2B,WAAW,EAAE,OAAe,EAAE,IAAS,EAAE,qBAA6B;IAC/F,OAAO,IAAI,OAAO,CAAC,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;QACpC,IAAI,aAAa,GAAG,IAAI,CAAA;QACxB,MAAM,KAAK,GAAG,EAAE,EAAE,CAAA;QAClB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QACtB,MAAM,SAAS,GAAoB,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,CAAA;QACvD,IAAI,OAAO,CAAA;QACX,IAAI,eAAe,CAAA;QACnB,MAAM,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EC;AAED;IACE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;AACpC,CAAC;AAFD,0CAEC"} \ No newline at end of file diff --git a/ts/lib/request_response/index.ts b/ts/lib/request_response/index.ts index 874cb84..f9cd874 100644 --- a/ts/lib/request_response/index.ts +++ b/ts/lib/request_response/index.ts @@ -78,10 +78,11 @@ export function request(redisClient, channel: string, body: any, requestValid } export async function server(redisClient, channel: string, callback: serverCallback, serverValidityPeriod: number): Promise { + const REDIS_RESPONSE_TTL_IN_SECONDS = 1 const clientClone = redisClient.duplicate() clients.push(clientClone) - function brpop () { + function brpop() { clientClone.brpop(channel, 0, async function (_null, popInfo) { if (_null) { console.error('BRPOP ERROR', _null) @@ -100,35 +101,35 @@ export async function server(redisClient, channel: string, callback: serve const req: EpicurusRequest = JSON.parse(rawRequest) req.body.channel = channel - if (req.ttl > Date.now() - serverValidityPeriod) { - callback(req.body, async function (error, result) { - const errorRef = error - ? { name: error.name, message: error.message, stack: error.stack, severity: error.severity || 1, status: error.status } - : null + callback(req.body, async function (error, result) { + const errorRef = error + ? { name: error.name, message: error.message, stack: error.stack, severity: error.severity || 1, status: error.status } + : null - let redisResponse: EpicurusResponse = { - error: errorRef, - result: result - } + let redisResponse: EpicurusResponse = { + error: errorRef, + result: result + } + + redisClient.lpush(req.reqId, JSON.stringify(redisResponse)) + redisClient.expire(req.reqId, REDIS_RESPONSE_TTL_IN_SECONDS) + }) - redisClient.lpush(req.reqId, JSON.stringify(redisResponse)) - }) - } }) } brpop() } -export function disableServers () { +export function disableServers() { serversEnabled = false closeAllClients() } -export function enableServers () { +export function enableServers() { serversEnabled = true } -export function closeAllClients () { +export function closeAllClients() { clients.forEach(c => c.end(false)) } From 4bfcedf18efcb5c5e43ce4dcf03c04eaa866d54c Mon Sep 17 00:00:00 2001 From: anujcontentstack Date: Fri, 10 Dec 2021 12:56:36 +0530 Subject: [PATCH 13/64] AUTH-156 | Update package version to publish a new package --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ec8f2e5..3ec1aca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/epicurus-node", - "version": "0.3.4", + "version": "0.3.7", "description": "Redis request/response and PubSub sugar", "main": "js/index.js", "types": "js/index.d.ts", @@ -46,4 +46,4 @@ "tslint": "5.5.0", "mocha": "3.5.0" } -} +} \ No newline at end of file From de325dca27571326cccad50d507e57facef7f59c Mon Sep 17 00:00:00 2001 From: contentstack-admin <52040860+contentstack-admin@users.noreply.github.com> Date: Tue, 14 Jun 2022 20:19:27 +0530 Subject: [PATCH 14/64] Create codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 70 +++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/codeql-analysis.yml diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..61cd42c --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,70 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: '*' + pull_request: + # The branches below must be a subset of the branches above + branches: '*' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'javascript' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # â„šī¸ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 From 974569756952190b26b6db4990aa311e4f97bc16 Mon Sep 17 00:00:00 2001 From: contentstack-admin <52040860+contentstack-admin@users.noreply.github.com> Date: Tue, 14 Jun 2022 20:20:17 +0530 Subject: [PATCH 15/64] Add files via upload --- .github/workflows/sast-scan.yml | 14 ++++++++++++++ .github/workflows/sca-monitor.yml | 13 +++++++++++++ .github/workflows/sca-scan.yml | 16 ++++++++++++++++ .github/workflows/secrets-scan.yml | 14 ++++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 .github/workflows/sast-scan.yml create mode 100644 .github/workflows/sca-monitor.yml create mode 100644 .github/workflows/sca-scan.yml create mode 100644 .github/workflows/secrets-scan.yml diff --git a/.github/workflows/sast-scan.yml b/.github/workflows/sast-scan.yml new file mode 100644 index 0000000..21f1485 --- /dev/null +++ b/.github/workflows/sast-scan.yml @@ -0,0 +1,14 @@ +name: SAST Scan +on: + push: + branches: + - '*' + pull_request: + types: [opened, synchronize, reopened] +jobs: + security: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Horusec Scan + run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/src horuszup/horusec-cli:latest horusec start -p /src -P $(pwd) diff --git a/.github/workflows/sca-monitor.yml b/.github/workflows/sca-monitor.yml new file mode 100644 index 0000000..294eab3 --- /dev/null +++ b/.github/workflows/sca-monitor.yml @@ -0,0 +1,13 @@ +name: Source Composition Analysis Monitor +on: push +jobs: + security: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Run Snyk to check for vulnerabilities + uses: snyk/actions/node@master + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + with: + command: monitor diff --git a/.github/workflows/sca-scan.yml b/.github/workflows/sca-scan.yml new file mode 100644 index 0000000..525e286 --- /dev/null +++ b/.github/workflows/sca-scan.yml @@ -0,0 +1,16 @@ +name: Source Composition Analysis Scan +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] +jobs: + security: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Run Snyk to check for vulnerabilities + uses: snyk/actions/node@master + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} diff --git a/.github/workflows/secrets-scan.yml b/.github/workflows/secrets-scan.yml new file mode 100644 index 0000000..71d6503 --- /dev/null +++ b/.github/workflows/secrets-scan.yml @@ -0,0 +1,14 @@ +name: Secrets Scan +on: + push: + branches: + - '*' + pull_request: + types: [opened, synchronize, reopened] +jobs: + security: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Gittyleaks + uses: gupy-io/gittyleaks-action@v0.1 From dbae073a2f1e1ab969b79b02f300420017f065f5 Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Thu, 15 Sep 2022 11:56:28 +0530 Subject: [PATCH 16/64] Delete sca-monitor.yml --- .github/workflows/sca-monitor.yml | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 .github/workflows/sca-monitor.yml diff --git a/.github/workflows/sca-monitor.yml b/.github/workflows/sca-monitor.yml deleted file mode 100644 index 294eab3..0000000 --- a/.github/workflows/sca-monitor.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Source Composition Analysis Monitor -on: push -jobs: - security: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: Run Snyk to check for vulnerabilities - uses: snyk/actions/node@master - env: - SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} - with: - command: monitor From d9e40854778a11c96397c4334a6dcd42cdabc641 Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Thu, 15 Sep 2022 11:56:30 +0530 Subject: [PATCH 17/64] codeql-analysis.yml --- .github/workflows/codeql-analysis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 61cd42c..3566f96 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -12,8 +12,6 @@ name: "CodeQL" on: - push: - branches: '*' pull_request: # The branches below must be a subset of the branches above branches: '*' From c12861883f9221a92f155765061cdaadcbee5a51 Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Thu, 15 Sep 2022 11:56:30 +0530 Subject: [PATCH 18/64] sast-scan.yml --- .github/workflows/sast-scan.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/sast-scan.yml b/.github/workflows/sast-scan.yml index 21f1485..f931630 100644 --- a/.github/workflows/sast-scan.yml +++ b/.github/workflows/sast-scan.yml @@ -1,8 +1,5 @@ name: SAST Scan on: - push: - branches: - - '*' pull_request: types: [opened, synchronize, reopened] jobs: @@ -11,4 +8,4 @@ jobs: steps: - uses: actions/checkout@v2 - name: Horusec Scan - run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/src horuszup/horusec-cli:latest horusec start -p /src -P $(pwd) + run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/src horuszup/horusec-cli:latest horusec start -p /src -P $(pwd) \ No newline at end of file From 6d66e24c47ecf8c7ae98462319b771d52b9d8904 Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Thu, 15 Sep 2022 11:56:31 +0530 Subject: [PATCH 19/64] sca-scan.yml --- .github/workflows/sca-scan.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/sca-scan.yml b/.github/workflows/sca-scan.yml index 525e286..7275b41 100644 --- a/.github/workflows/sca-scan.yml +++ b/.github/workflows/sca-scan.yml @@ -1,8 +1,5 @@ name: Source Composition Analysis Scan on: - push: - branches: - - master pull_request: types: [opened, synchronize, reopened] jobs: @@ -13,4 +10,4 @@ jobs: - name: Run Snyk to check for vulnerabilities uses: snyk/actions/node@master env: - SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} \ No newline at end of file From 7f7f50762d30f56381c2501267110d12382f02de Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Thu, 15 Sep 2022 11:56:32 +0530 Subject: [PATCH 20/64] secrets-scan.yml --- .github/workflows/secrets-scan.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/secrets-scan.yml b/.github/workflows/secrets-scan.yml index 71d6503..1e8f176 100644 --- a/.github/workflows/secrets-scan.yml +++ b/.github/workflows/secrets-scan.yml @@ -1,8 +1,5 @@ name: Secrets Scan on: - push: - branches: - - '*' pull_request: types: [opened, synchronize, reopened] jobs: @@ -11,4 +8,4 @@ jobs: steps: - uses: actions/checkout@v2 - name: Gittyleaks - uses: gupy-io/gittyleaks-action@v0.1 + uses: gupy-io/gittyleaks-action@v0.1 \ No newline at end of file From 95a9456f34281717f581b11606f4fddf5b724218 Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Wed, 21 Sep 2022 10:05:05 +0530 Subject: [PATCH 21/64] codeql-analysis.yml From 38f9e263694331b9f48ff38a96c4f6159f206eaa Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Wed, 21 Sep 2022 10:05:06 +0530 Subject: [PATCH 22/64] sast-scan.yml From 7fbc645bc2ad1f410cad09c562ab8c9a3bd29d46 Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Wed, 21 Sep 2022 10:05:07 +0530 Subject: [PATCH 23/64] sca-scan.yml --- .github/workflows/sca-scan.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sca-scan.yml b/.github/workflows/sca-scan.yml index 7275b41..fadb3ee 100644 --- a/.github/workflows/sca-scan.yml +++ b/.github/workflows/sca-scan.yml @@ -10,4 +10,6 @@ jobs: - name: Run Snyk to check for vulnerabilities uses: snyk/actions/node@master env: - SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} \ No newline at end of file + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + with: + args: --all-projects From 0721c60a09079ae4a3c0183ec8c4c32ef19640af Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Wed, 21 Sep 2022 10:05:08 +0530 Subject: [PATCH 24/64] secrets-scan.yml From 39df9773ae0958c7681c6a87aadc170f82fe0d34 Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Mon, 3 Oct 2022 19:25:19 +0530 Subject: [PATCH 25/64] jira.yml --- .github/workflows/jira.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/jira.yml diff --git a/.github/workflows/jira.yml b/.github/workflows/jira.yml new file mode 100644 index 0000000..a608b07 --- /dev/null +++ b/.github/workflows/jira.yml @@ -0,0 +1,28 @@ +name: Create JIRA ISSUE +on: + pull_request: + types: [opened] +jobs: + security: + if: ${{ github.actor == 'dependabot[bot]' || github.actor == 'snyk-bot' || contains(github.event.pull_request.head.ref, 'snyk-fix-') || contains(github.event.pull_request.head.ref, 'snyk-upgrade-')}} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Login into JIRA + uses: atlassian/gajira-login@master + env: + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} + - name: Create a JIRA Issue + id: create + uses: atlassian/gajira-create@master + with: + project: ${{ secrets.JIRA_PROJECT }} + issuetype: ${{ secrets.JIRA_ISSUE_TYPE }} + summary: | + ${{ github.event.pull_request.title }} + description: | + PR: ${{ github.event.pull_request.html_url }} + + ${{ github.event.pull_request.body }} From e361cb9106517e88b4703e7efa7f778320e5d865 Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Tue, 4 Oct 2022 10:01:23 +0530 Subject: [PATCH 26/64] jira.yml --- .github/workflows/jira.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/jira.yml b/.github/workflows/jira.yml index a608b07..744a15f 100644 --- a/.github/workflows/jira.yml +++ b/.github/workflows/jira.yml @@ -25,4 +25,3 @@ jobs: description: | PR: ${{ github.event.pull_request.html_url }} - ${{ github.event.pull_request.body }} From e7fe2b17e53c1c653975e4be8bff195a8636cd8b Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Fri, 4 Nov 2022 16:48:13 +0530 Subject: [PATCH 27/64] jira.yml --- .github/workflows/jira.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/jira.yml b/.github/workflows/jira.yml index 744a15f..5ddf87a 100644 --- a/.github/workflows/jira.yml +++ b/.github/workflows/jira.yml @@ -25,3 +25,4 @@ jobs: description: | PR: ${{ github.event.pull_request.html_url }} + fields: "${{ secrets.JIRA_FIELDS }}" From 1c4b5e4f086e677acca643bf9d03b3157a954120 Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Tue, 24 Jan 2023 14:23:00 +0530 Subject: [PATCH 28/64] sca-scan.yml --- .github/workflows/sca-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sca-scan.yml b/.github/workflows/sca-scan.yml index fadb3ee..bf9c1eb 100644 --- a/.github/workflows/sca-scan.yml +++ b/.github/workflows/sca-scan.yml @@ -12,4 +12,4 @@ jobs: env: SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} with: - args: --all-projects + args: --all-projects --fail-on=all From d2802988b02c42284be38879eb5fdc76eee3a2d3 Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Tue, 24 Jan 2023 14:23:38 +0530 Subject: [PATCH 29/64] jira.yml From 7f1940564d9c186e7eec050b13d9418b2e4847e5 Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Tue, 24 Jan 2023 14:23:44 +0530 Subject: [PATCH 30/64] codeql-analysis.yml From 9e91d2fa44953cda2bab0dee57f6af3c0f9599e9 Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Tue, 24 Jan 2023 14:23:45 +0530 Subject: [PATCH 31/64] sast-scan.yml From 10ac33a6fa19f4cd2382691b4a01ddc20fa0b56b Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Tue, 24 Jan 2023 14:23:46 +0530 Subject: [PATCH 32/64] secrets-scan.yml From faff4816ad501f8f12cd07c384b50b13240c4b1d Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Sat, 6 May 2023 15:29:36 +0530 Subject: [PATCH 33/64] CODEOWNERS update --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index da6db11..0773923 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @contentstack/security-admin @contentstack/ecosystem-admin +* @contentstack/security-admin \ No newline at end of file From 5326c02eec733b471c534138b59ba481c636ec4c Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Tue, 5 Sep 2023 13:59:47 +0530 Subject: [PATCH 34/64] sca-scan.yml From d2784723e451eef13a23e9c419197a535b4ad159 Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Tue, 5 Sep 2023 14:00:03 +0530 Subject: [PATCH 35/64] jira.yml --- .github/workflows/jira.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/jira.yml b/.github/workflows/jira.yml index 5ddf87a..63960ea 100644 --- a/.github/workflows/jira.yml +++ b/.github/workflows/jira.yml @@ -26,3 +26,8 @@ jobs: PR: ${{ github.event.pull_request.html_url }} fields: "${{ secrets.JIRA_FIELDS }}" + - name: Transition issue + uses: atlassian/gajira-transition@v3 + with: + issue: ${{ steps.create.outputs.issue }} + transition: ${{ secrets.JIRA_TRANSITION }} From 7d8250cfd94f6108814ab2edff597380e2da51e0 Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Tue, 5 Sep 2023 14:00:04 +0530 Subject: [PATCH 36/64] Delete sast-scan.yml --- .github/workflows/sast-scan.yml | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .github/workflows/sast-scan.yml diff --git a/.github/workflows/sast-scan.yml b/.github/workflows/sast-scan.yml deleted file mode 100644 index f931630..0000000 --- a/.github/workflows/sast-scan.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: SAST Scan -on: - pull_request: - types: [opened, synchronize, reopened] -jobs: - security: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Horusec Scan - run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/src horuszup/horusec-cli:latest horusec start -p /src -P $(pwd) \ No newline at end of file From ceae630baafd6670734665ee11016939173630c8 Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Tue, 5 Sep 2023 14:00:05 +0530 Subject: [PATCH 37/64] Delete secrets-scan.yml --- .github/workflows/secrets-scan.yml | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .github/workflows/secrets-scan.yml diff --git a/.github/workflows/secrets-scan.yml b/.github/workflows/secrets-scan.yml deleted file mode 100644 index 1e8f176..0000000 --- a/.github/workflows/secrets-scan.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: Secrets Scan -on: - pull_request: - types: [opened, synchronize, reopened] -jobs: - security: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Gittyleaks - uses: gupy-io/gittyleaks-action@v0.1 \ No newline at end of file From cb7e83bfadd6acb97e963754a979ef348878a1bd Mon Sep 17 00:00:00 2001 From: aravindbuilt Date: Tue, 5 Sep 2023 14:00:06 +0530 Subject: [PATCH 38/64] codeql-analysis.yml From 362601eaf4511880a33c93c9caa1d92926ffcc17 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 18 Jun 2024 15:00:30 +0530 Subject: [PATCH 39/64] sca-scan.yml --- .github/workflows/sca-scan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sca-scan.yml b/.github/workflows/sca-scan.yml index bf9c1eb..f09161f 100644 --- a/.github/workflows/sca-scan.yml +++ b/.github/workflows/sca-scan.yml @@ -3,7 +3,7 @@ on: pull_request: types: [opened, synchronize, reopened] jobs: - security: + security-sca: runs-on: ubuntu-latest steps: - uses: actions/checkout@master From f66b11e9d4bbd4b4ec029f70ae890cbc0cf4e00c Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 18 Jun 2024 15:00:45 +0530 Subject: [PATCH 40/64] jira.yml --- .github/workflows/jira.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jira.yml b/.github/workflows/jira.yml index 63960ea..caa4bbd 100644 --- a/.github/workflows/jira.yml +++ b/.github/workflows/jira.yml @@ -3,7 +3,7 @@ on: pull_request: types: [opened] jobs: - security: + security-jira: if: ${{ github.actor == 'dependabot[bot]' || github.actor == 'snyk-bot' || contains(github.event.pull_request.head.ref, 'snyk-fix-') || contains(github.event.pull_request.head.ref, 'snyk-upgrade-')}} runs-on: ubuntu-latest steps: From 2e3a956a7ee75685050e91a8ae774703932d7f16 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 18 Jun 2024 15:00:46 +0530 Subject: [PATCH 41/64] sast-scan.yml --- .github/workflows/sast-scan.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/workflows/sast-scan.yml diff --git a/.github/workflows/sast-scan.yml b/.github/workflows/sast-scan.yml new file mode 100644 index 0000000..3b9521a --- /dev/null +++ b/.github/workflows/sast-scan.yml @@ -0,0 +1,11 @@ +name: SAST Scan +on: + pull_request: + types: [opened, synchronize, reopened] +jobs: + security-sast: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Semgrep Scan + run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v "${PWD}:/src" returntocorp/semgrep semgrep scan --config auto \ No newline at end of file From 669497a9665f938ba40383a44244af05099c705a Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 18 Jun 2024 15:00:48 +0530 Subject: [PATCH 42/64] codeql-analysis.yml From a0193bdf72b21aa07f197ac948194e9d07e9afa2 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 22 Oct 2024 16:15:52 +0530 Subject: [PATCH 43/64] sca-scan.yml From 0cb6d6813bb88f56b26bf2f14ff6a91b4004847e Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 22 Oct 2024 16:16:05 +0530 Subject: [PATCH 44/64] jira.yml From 2fc01cf20a38e3febec3ae4ee948fbf0663a9891 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 22 Oct 2024 16:16:06 +0530 Subject: [PATCH 45/64] sast-scan.yml From 4d18a42392aee482df13f8641adcfb0a8f74e6ce Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 22 Oct 2024 16:16:08 +0530 Subject: [PATCH 46/64] codeql-analysis.yml From 89f9cda8d0d38b84387601dc522aafbefb7fb06f Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 22 Oct 2024 16:16:11 +0530 Subject: [PATCH 47/64] Updated codeowners --- CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODEOWNERS b/CODEOWNERS index 0773923..1be7e0d 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @contentstack/security-admin \ No newline at end of file +* @contentstack/security-admin From 54db5eb175f43673e40984fda2561e7cd30a8231 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Sun, 19 Jan 2025 21:19:04 +0530 Subject: [PATCH 48/64] sca-scan.yml From b22189e13e01054d58481c15dd621200f51c3195 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Sun, 19 Jan 2025 21:19:17 +0530 Subject: [PATCH 49/64] jira.yml --- .github/workflows/jira.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jira.yml b/.github/workflows/jira.yml index caa4bbd..250abc7 100644 --- a/.github/workflows/jira.yml +++ b/.github/workflows/jira.yml @@ -21,7 +21,7 @@ jobs: project: ${{ secrets.JIRA_PROJECT }} issuetype: ${{ secrets.JIRA_ISSUE_TYPE }} summary: | - ${{ github.event.pull_request.title }} + Snyk | Vulnerability | ${{ github.event.repository.name }} | ${{ github.event.pull_request.title }} description: | PR: ${{ github.event.pull_request.html_url }} From 4d2f6930f9a0821bc35097b1da6193f0e883b86b Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Sun, 19 Jan 2025 21:19:18 +0530 Subject: [PATCH 50/64] sast-scan.yml From 21da6bd4d845b53715354cf91092600c441e47e6 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Sun, 19 Jan 2025 21:19:19 +0530 Subject: [PATCH 51/64] codeql-analysis.yml From 3263deeab92aea173c067807080ad1dbfc4915b6 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Sun, 19 Jan 2025 21:19:23 +0530 Subject: [PATCH 52/64] Updated codeowners From 50a010c65a9210d816b2621d806024ba02570d80 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Wed, 16 Apr 2025 15:16:24 +0530 Subject: [PATCH 53/64] policy-scan.yml --- .github/workflows/policy-scan.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/policy-scan.yml diff --git a/.github/workflows/policy-scan.yml b/.github/workflows/policy-scan.yml new file mode 100644 index 0000000..fe9c6f7 --- /dev/null +++ b/.github/workflows/policy-scan.yml @@ -0,0 +1,27 @@ +name: Checks the security policy and configurations +on: + pull_request: + types: [opened, synchronize, reopened] +jobs: + security-policy: + if: github.event.repository.visibility == 'public' + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@master + - name: Checks for SECURITY.md policy file + run: | + if ! [[ -f "SECURITY.md" || -f ".github/SECURITY.md" ]]; then exit 1; fi + security-license: + if: github.event.repository.visibility == 'public' + runs-on: ubuntu-latest + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@master + - name: Checks for License file + run: | + if ! [[ -f "LICENSE" || -f "License.txt" || -f "LICENSE.md" || -f "LICENSE.txt" ]]; then exit 1; fi \ No newline at end of file From a93863f8a27c01ca542026b7742b579c39d4bce6 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Wed, 16 Apr 2025 15:16:34 +0530 Subject: [PATCH 54/64] issues-jira.yml --- .github/workflows/issues-jira.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/issues-jira.yml diff --git a/.github/workflows/issues-jira.yml b/.github/workflows/issues-jira.yml new file mode 100644 index 0000000..7bf0469 --- /dev/null +++ b/.github/workflows/issues-jira.yml @@ -0,0 +1,31 @@ +name: Create Jira Ticket for Github Issue + +on: + issues: + types: [opened] + +jobs: + issue-jira: + runs-on: ubuntu-latest + steps: + + - name: Login to Jira + uses: atlassian/gajira-login@master + env: + JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} + JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} + + - name: Create Jira Issue + id: create_jira + uses: atlassian/gajira-create@master + with: + project: ${{ secrets.JIRA_PROJECT }} + issuetype: ${{ secrets.JIRA_ISSUE_TYPE }} + summary: Github | Issue | ${{ github.event.repository.name }} | ${{ github.event.issue.title }} + description: | + *GitHub Issue:* ${{ github.event.issue.html_url }} + + *Description:* + ${{ github.event.issue.body }} + fields: "${{ secrets.ISSUES_JIRA_FIELDS }}" \ No newline at end of file From 762331c0889feff47ff5a1d6a332f28b04d43622 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Wed, 16 Apr 2025 15:16:35 +0530 Subject: [PATCH 55/64] Delete jira.yml --- .github/workflows/jira.yml | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 .github/workflows/jira.yml diff --git a/.github/workflows/jira.yml b/.github/workflows/jira.yml deleted file mode 100644 index 250abc7..0000000 --- a/.github/workflows/jira.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Create JIRA ISSUE -on: - pull_request: - types: [opened] -jobs: - security-jira: - if: ${{ github.actor == 'dependabot[bot]' || github.actor == 'snyk-bot' || contains(github.event.pull_request.head.ref, 'snyk-fix-') || contains(github.event.pull_request.head.ref, 'snyk-upgrade-')}} - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Login into JIRA - uses: atlassian/gajira-login@master - env: - JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }} - JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }} - JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }} - - name: Create a JIRA Issue - id: create - uses: atlassian/gajira-create@master - with: - project: ${{ secrets.JIRA_PROJECT }} - issuetype: ${{ secrets.JIRA_ISSUE_TYPE }} - summary: | - Snyk | Vulnerability | ${{ github.event.repository.name }} | ${{ github.event.pull_request.title }} - description: | - PR: ${{ github.event.pull_request.html_url }} - - fields: "${{ secrets.JIRA_FIELDS }}" - - name: Transition issue - uses: atlassian/gajira-transition@v3 - with: - issue: ${{ steps.create.outputs.issue }} - transition: ${{ secrets.JIRA_TRANSITION }} From 01a7c8b26daa9367bdd01bb21e8f573e27331444 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Wed, 16 Apr 2025 15:16:35 +0530 Subject: [PATCH 56/64] Delete sast-scan.yml --- .github/workflows/sast-scan.yml | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 .github/workflows/sast-scan.yml diff --git a/.github/workflows/sast-scan.yml b/.github/workflows/sast-scan.yml deleted file mode 100644 index 3b9521a..0000000 --- a/.github/workflows/sast-scan.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: SAST Scan -on: - pull_request: - types: [opened, synchronize, reopened] -jobs: - security-sast: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Semgrep Scan - run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v "${PWD}:/src" returntocorp/semgrep semgrep scan --config auto \ No newline at end of file From c65e206804635d29b6132f6d6409b390759b997a Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Wed, 16 Apr 2025 15:16:37 +0530 Subject: [PATCH 57/64] codeql-analysis.yml From a3d52331a33fd363e4431f0d1863c8017d4106f2 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Wed, 16 Apr 2025 15:16:41 +0530 Subject: [PATCH 58/64] Updated codeowners From d648c928f76d0cf24a51874355fc522fcc7e4854 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Wed, 23 Apr 2025 21:44:59 +0530 Subject: [PATCH 59/64] policy-scan.yml --- .github/workflows/policy-scan.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/policy-scan.yml b/.github/workflows/policy-scan.yml index fe9c6f7..ff25923 100644 --- a/.github/workflows/policy-scan.yml +++ b/.github/workflows/policy-scan.yml @@ -24,4 +24,23 @@ jobs: - uses: actions/checkout@master - name: Checks for License file run: | - if ! [[ -f "LICENSE" || -f "License.txt" || -f "LICENSE.md" || -f "LICENSE.txt" ]]; then exit 1; fi \ No newline at end of file + expected_license_files=("LICENSE" "LICENSE.txt" "LICENSE.md" "License.txt") + license_file_found=false + current_year=$(date +"%Y") + + for license_file in "${expected_license_files[@]}"; do + if [ -f "$license_file" ]; then + license_file_found=true + # check the license file for the current year, if not exists, exit with error + if ! grep -q "$current_year" "$license_file"; then + echo "License file $license_file does not contain the current year." + exit 2 + fi + break + fi + done + + if [ "$license_file_found" = false ]; then + echo "No license file found. Please add a license file to the repository." + exit 1 + fi \ No newline at end of file From c04246cdd70f1c468f8c927a46a9108f756cea08 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 6 May 2025 14:15:31 +0530 Subject: [PATCH 60/64] policy-scan.yml From fe3863dfcf39f074f4637b06a42c3d925f69e43c Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 6 May 2025 14:15:38 +0530 Subject: [PATCH 61/64] issues-jira.yml From fe2967c88e0084b9e686ca983a62ea757e2716dc Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 6 May 2025 14:15:39 +0530 Subject: [PATCH 62/64] secrets-scan.yml --- .github/workflows/secrets-scan.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/secrets-scan.yml diff --git a/.github/workflows/secrets-scan.yml b/.github/workflows/secrets-scan.yml new file mode 100644 index 0000000..049c02f --- /dev/null +++ b/.github/workflows/secrets-scan.yml @@ -0,0 +1,29 @@ +name: Secrets Scan +on: + pull_request: + types: [opened, synchronize, reopened] +jobs: + security-secrets: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: '2' + ref: '${{ github.event.pull_request.head.ref }}' + - run: | + git reset --soft HEAD~1 + - name: Install Talisman + run: | + # Download Talisman + wget https://github.com/thoughtworks/talisman/releases/download/v1.37.0/talisman_linux_amd64 -O talisman + + # Checksum verification + checksum=$(sha256sum ./talisman | awk '{print $1}') + if [ "$checksum" != "8e0ae8bb7b160bf10c4fa1448beb04a32a35e63505b3dddff74a092bccaaa7e4" ]; then exit 1; fi + + # Make it executable + chmod +x talisman + - name: Run talisman + run: | + # Run Talisman with the pre-commit hook + ./talisman --githook pre-commit \ No newline at end of file From 9bd9188268147bd26d39ea7ebf2f063d8b619605 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 6 May 2025 14:15:41 +0530 Subject: [PATCH 63/64] talismanrc file updated --- .talismanrc | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .talismanrc diff --git a/.talismanrc b/.talismanrc new file mode 100644 index 0000000..345ca2f --- /dev/null +++ b/.talismanrc @@ -0,0 +1,5 @@ +fileignoreconfig: +- filename: .github/workflows/secrets-scan.yml + ignore_detectors: + - filecontent +version: "1.0" \ No newline at end of file From f4333b23454b41e3cbf1e3b601fb1e76f0a6ae12 Mon Sep 17 00:00:00 2001 From: Aravind Kumar Date: Tue, 6 May 2025 14:15:44 +0530 Subject: [PATCH 64/64] Updated codeowners