@abyss-project/monitor 3.0.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +67 -18
- package/dist/types/interface/api/requests/application.request.d.ts +0 -8
- package/dist/types/interface/api/responses/infrastructure.admin.response.d.ts +2 -19
- package/dist/types/interface/api/responses/infrastructure.admin.response.js +1 -8
- package/dist/types/interface/api/responses/infrastructure.admin.response.js.map +1 -1
- package/package.json +2 -2
- package/tsconfig.build.json +4 -0
- package/dist/__tests__/alert-log-url.test.d.ts +0 -1
- package/dist/__tests__/alert-log-url.test.js +0 -21
- package/dist/__tests__/alert-log-url.test.js.map +0 -1
- package/dist/__tests__/application-log-bulk-api.test.d.ts +0 -1
- package/dist/__tests__/application-log-bulk-api.test.js +0 -125
- package/dist/__tests__/application-log-bulk-api.test.js.map +0 -1
- package/dist/__tests__/body-redaction.test.d.ts +0 -1
- package/dist/__tests__/body-redaction.test.js +0 -104
- package/dist/__tests__/body-redaction.test.js.map +0 -1
- package/dist/__tests__/graceful-shutdown-flush.test.d.ts +0 -1
- package/dist/__tests__/graceful-shutdown-flush.test.js +0 -253
- package/dist/__tests__/graceful-shutdown-flush.test.js.map +0 -1
- package/dist/__tests__/graceful-shutdown-logger.test.d.ts +0 -1
- package/dist/__tests__/graceful-shutdown-logger.test.js +0 -124
- package/dist/__tests__/graceful-shutdown-logger.test.js.map +0 -1
- package/dist/__tests__/header-pattern.test.d.ts +0 -1
- package/dist/__tests__/header-pattern.test.js +0 -66
- package/dist/__tests__/header-pattern.test.js.map +0 -1
- package/dist/__tests__/identifier-resolver.test.d.ts +0 -1
- package/dist/__tests__/identifier-resolver.test.js +0 -50
- package/dist/__tests__/identifier-resolver.test.js.map +0 -1
- package/dist/__tests__/latency-bucket.test.d.ts +0 -1
- package/dist/__tests__/latency-bucket.test.js +0 -10
- package/dist/__tests__/latency-bucket.test.js.map +0 -1
- package/dist/__tests__/log-queue.test.d.ts +0 -1
- package/dist/__tests__/log-queue.test.js +0 -97
- package/dist/__tests__/log-queue.test.js.map +0 -1
- package/dist/__tests__/log-shipper-preconfig.test.d.ts +0 -1
- package/dist/__tests__/log-shipper-preconfig.test.js +0 -54
- package/dist/__tests__/log-shipper-preconfig.test.js.map +0 -1
- package/dist/__tests__/log-shipper.test.d.ts +0 -1
- package/dist/__tests__/log-shipper.test.js +0 -1040
- package/dist/__tests__/log-shipper.test.js.map +0 -1
- package/dist/__tests__/log-spool.test.d.ts +0 -1
- package/dist/__tests__/log-spool.test.js +0 -297
- package/dist/__tests__/log-spool.test.js.map +0 -1
- package/dist/__tests__/logger-body-size.test.d.ts +0 -1
- package/dist/__tests__/logger-body-size.test.js +0 -12
- package/dist/__tests__/logger-body-size.test.js.map +0 -1
- package/dist/__tests__/logger-console-min-level.test.d.ts +0 -1
- package/dist/__tests__/logger-console-min-level.test.js +0 -55
- package/dist/__tests__/logger-console-min-level.test.js.map +0 -1
- package/dist/__tests__/logger-debug-critical.test.d.ts +0 -1
- package/dist/__tests__/logger-debug-critical.test.js +0 -77
- package/dist/__tests__/logger-debug-critical.test.js.map +0 -1
- package/dist/__tests__/logger-endpoint-headers.test.d.ts +0 -1
- package/dist/__tests__/logger-endpoint-headers.test.js +0 -23
- package/dist/__tests__/logger-endpoint-headers.test.js.map +0 -1
- package/dist/__tests__/logger-enqueues.test.d.ts +0 -1
- package/dist/__tests__/logger-enqueues.test.js +0 -276
- package/dist/__tests__/logger-enqueues.test.js.map +0 -1
- package/dist/__tests__/logger-returns-promise.test.d.ts +0 -1
- package/dist/__tests__/logger-returns-promise.test.js +0 -27
- package/dist/__tests__/logger-returns-promise.test.js.map +0 -1
- package/dist/__tests__/parse-window.test.d.ts +0 -1
- package/dist/__tests__/parse-window.test.js +0 -19
- package/dist/__tests__/parse-window.test.js.map +0 -1
- package/dist/__tests__/rate-limit.decorator.test.d.ts +0 -1
- package/dist/__tests__/rate-limit.decorator.test.js +0 -47
- package/dist/__tests__/rate-limit.decorator.test.js.map +0 -1
- package/dist/__tests__/rate-limit.middleware.test.d.ts +0 -1
- package/dist/__tests__/rate-limit.middleware.test.js +0 -156
- package/dist/__tests__/rate-limit.middleware.test.js.map +0 -1
- package/dist/__tests__/route-decorator-body-flags.test.d.ts +0 -1
- package/dist/__tests__/route-decorator-body-flags.test.js +0 -117
- package/dist/__tests__/route-decorator-body-flags.test.js.map +0 -1
- package/dist/__tests__/route-flags-loader.test.d.ts +0 -1
- package/dist/__tests__/route-flags-loader.test.js +0 -153
- package/dist/__tests__/route-flags-loader.test.js.map +0 -1
- package/dist/__tests__/sentinel-header-mask.test.d.ts +0 -1
- package/dist/__tests__/sentinel-header-mask.test.js +0 -14
- package/dist/__tests__/sentinel-header-mask.test.js.map +0 -1
- package/dist/__tests__/setconfig-keeps-queued-logs.test.d.ts +0 -1
- package/dist/__tests__/setconfig-keeps-queued-logs.test.js +0 -59
- package/dist/__tests__/setconfig-keeps-queued-logs.test.js.map +0 -1
- package/dist/__tests__/shipper-replay-on-config.test.d.ts +0 -1
- package/dist/__tests__/shipper-replay-on-config.test.js +0 -59
- package/dist/__tests__/shipper-replay-on-config.test.js.map +0 -1
- package/dist/__tests__/token-bucket.store.test.d.ts +0 -1
- package/dist/__tests__/token-bucket.store.test.js +0 -99
- package/dist/__tests__/token-bucket.store.test.js.map +0 -1
- package/dist/__tests__/utils/setup-global.d.ts +0 -1
- package/dist/__tests__/utils/setup-global.js +0 -35
- package/dist/__tests__/utils/setup-global.js.map +0 -1
- package/dist/__tests__/utils/teardown-global.d.ts +0 -1
- package/dist/__tests__/utils/teardown-global.js +0 -36
- package/dist/__tests__/utils/teardown-global.js.map +0 -1
package/.eslintrc.js
CHANGED
|
@@ -1,3 +1,60 @@
|
|
|
1
|
+
// CRITICAL = 0 est falsy : `level || x`, `!level` ou `if (level)` perdent le niveau le plus grave
|
|
2
|
+
// sans erreur de type (carte #538). Garde par nom : une variable renommée hors du motif lui échappe.
|
|
3
|
+
const logLevelRestrictions = [
|
|
4
|
+
{
|
|
5
|
+
selector: "LogicalExpression[operator='||'] > Identifier.left[name=/level$/i]",
|
|
6
|
+
message: "Un niveau de log peut valoir 0 (CRITICAL) : utiliser `??` plutôt que `||` (carte #538).",
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
selector: "UnaryExpression[operator='!'] > Identifier.argument[name=/level$/i]",
|
|
10
|
+
message: "Un niveau de log peut valoir 0 (CRITICAL) : comparer explicitement a undefined (carte #538).",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
selector: ':matches(IfStatement, ConditionalExpression, WhileStatement) > Identifier.test[name=/level$/i]',
|
|
14
|
+
message: "Un niveau de log peut valoir 0 (CRITICAL) : comparer explicitement a undefined (carte #538).",
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
// A test writing process.env by hand restores `undefined` as the string "undefined" (cards #556, #612):
|
|
19
|
+
// tests go through setTestEnv (src/__tests__/utils/test-env.util.ts), which also restores after
|
|
20
|
+
// each test. Jest setup files are not test files and keep their direct writes.
|
|
21
|
+
// Not caught, left to review: an alias (`const env = process.env; env.X = …`), `process['env']`,
|
|
22
|
+
// and `Reflect.deleteProperty(process.env, …)`.
|
|
23
|
+
const testEnvMessage =
|
|
24
|
+
'Tests must not write process.env directly: use setTestEnv or setSuiteEnv from src/__tests__/utils/test-env.util.ts (cards #556, #612).';
|
|
25
|
+
const testEnvRestrictions = [
|
|
26
|
+
{
|
|
27
|
+
selector:
|
|
28
|
+
"AssignmentExpression[left.type='MemberExpression'][left.object.type='MemberExpression'][left.object.object.name='process'][left.object.property.name='env']",
|
|
29
|
+
message: testEnvMessage,
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
selector: "AssignmentExpression[left.type='MemberExpression'][left.object.name='process'][left.property.name='env']",
|
|
33
|
+
message: testEnvMessage,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
selector:
|
|
37
|
+
"UnaryExpression[operator='delete'][argument.type='MemberExpression'][argument.object.type='MemberExpression'][argument.object.object.name='process'][argument.object.property.name='env']",
|
|
38
|
+
message: testEnvMessage,
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
selector:
|
|
42
|
+
"CallExpression[callee.object.name='Object'][callee.property.name='assign'][arguments.0.type='MemberExpression'][arguments.0.object.name='process'][arguments.0.property.name='env']",
|
|
43
|
+
message: testEnvMessage,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
// The same writes through a TypeScript cast: `(process.env as Record<string, string>).X = …`.
|
|
47
|
+
selector:
|
|
48
|
+
"AssignmentExpression[left.type='MemberExpression'][left.object.type='TSAsExpression'][left.object.expression.object.name='process'][left.object.expression.property.name='env']",
|
|
49
|
+
message: testEnvMessage,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
selector:
|
|
53
|
+
"UnaryExpression[operator='delete'][argument.type='MemberExpression'][argument.object.type='TSAsExpression'][argument.object.expression.object.name='process'][argument.object.expression.property.name='env']",
|
|
54
|
+
message: testEnvMessage,
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
|
|
1
58
|
module.exports = {
|
|
2
59
|
parser: '@typescript-eslint/parser',
|
|
3
60
|
parserOptions: {
|
|
@@ -22,23 +79,7 @@ module.exports = {
|
|
|
22
79
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
23
80
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
24
81
|
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
|
|
25
|
-
|
|
26
|
-
// sans erreur de type (carte #538). Garde par nom : une variable renommée hors du motif lui échappe.
|
|
27
|
-
'no-restricted-syntax': [
|
|
28
|
-
'error',
|
|
29
|
-
{
|
|
30
|
-
selector: "LogicalExpression[operator='||'] > Identifier.left[name=/level$/i]",
|
|
31
|
-
message: "Un niveau de log peut valoir 0 (CRITICAL) : utiliser `??` plutôt que `||` (carte #538).",
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
selector: "UnaryExpression[operator='!'] > Identifier.argument[name=/level$/i]",
|
|
35
|
-
message: "Un niveau de log peut valoir 0 (CRITICAL) : comparer explicitement a undefined (carte #538).",
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
selector: ':matches(IfStatement, ConditionalExpression, WhileStatement) > Identifier.test[name=/level$/i]',
|
|
39
|
-
message: "Un niveau de log peut valoir 0 (CRITICAL) : comparer explicitement a undefined (carte #538).",
|
|
40
|
-
},
|
|
41
|
-
],
|
|
82
|
+
'no-restricted-syntax': ['error', ...logLevelRestrictions],
|
|
42
83
|
'filenames-simple/naming-convention': [
|
|
43
84
|
'error',
|
|
44
85
|
{
|
|
@@ -47,5 +88,13 @@ module.exports = {
|
|
|
47
88
|
},
|
|
48
89
|
],
|
|
49
90
|
},
|
|
50
|
-
overrides: [
|
|
91
|
+
overrides: [
|
|
92
|
+
{
|
|
93
|
+
// `no-restricted-syntax` is a single array: an override replaces it, so it repeats the base list.
|
|
94
|
+
files: ['**/*.spec.ts', '**/*.test.ts'],
|
|
95
|
+
rules: {
|
|
96
|
+
'no-restricted-syntax': ['error', ...logLevelRestrictions, ...testEnvRestrictions],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
],
|
|
51
100
|
};
|
|
@@ -95,11 +95,3 @@ export interface IPurgeArchiveApplicationBody {
|
|
|
95
95
|
from: string;
|
|
96
96
|
to: string;
|
|
97
97
|
}
|
|
98
|
-
export interface IEraseArchiveSubjectBody {
|
|
99
|
-
applicationId: string;
|
|
100
|
-
tableName: string;
|
|
101
|
-
from: string;
|
|
102
|
-
to: string;
|
|
103
|
-
field: string;
|
|
104
|
-
value: string;
|
|
105
|
-
}
|
|
@@ -58,7 +58,7 @@ export interface RetentionPassPartition {
|
|
|
58
58
|
planned: RetentionPlannedAction;
|
|
59
59
|
reason: string;
|
|
60
60
|
}
|
|
61
|
-
export interface
|
|
61
|
+
export interface PlanRetentionPassResponse {
|
|
62
62
|
data: {
|
|
63
63
|
runId: string;
|
|
64
64
|
dryRun: boolean;
|
|
@@ -67,26 +67,9 @@ export interface RunRetentionPassResponse {
|
|
|
67
67
|
requestId: string;
|
|
68
68
|
};
|
|
69
69
|
}
|
|
70
|
-
export
|
|
71
|
-
OK = "OK",
|
|
72
|
-
WARN = "WARN",
|
|
73
|
-
CRITICAL = "CRITICAL",
|
|
74
|
-
UNKNOWN = "UNKNOWN"
|
|
75
|
-
}
|
|
76
|
-
export interface GetArchiveVolumeResponse {
|
|
77
|
-
data: {
|
|
78
|
-
status: ArchiveVolumeStatus;
|
|
79
|
-
freeBytes: number | null;
|
|
80
|
-
floorBytes: number;
|
|
81
|
-
detail: string;
|
|
82
|
-
requestId: string;
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
export interface EraseArchiveSubjectResponse {
|
|
70
|
+
export interface RunRetentionPassResponse {
|
|
86
71
|
data: {
|
|
87
72
|
runId: string;
|
|
88
|
-
objectsTouched: number;
|
|
89
|
-
erasedRows: number;
|
|
90
73
|
requestId: string;
|
|
91
74
|
};
|
|
92
75
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.RetentionPlannedAction = exports.StorageCensusRelationKind = void 0;
|
|
4
4
|
var StorageCensusRelationKind;
|
|
5
5
|
(function (StorageCensusRelationKind) {
|
|
6
6
|
StorageCensusRelationKind["PARTITIONED_PARENT"] = "PARTITIONED_PARENT";
|
|
@@ -13,11 +13,4 @@ var RetentionPlannedAction;
|
|
|
13
13
|
RetentionPlannedAction["COMPACT"] = "COMPACT";
|
|
14
14
|
RetentionPlannedAction["NOTHING"] = "NOTHING";
|
|
15
15
|
})(RetentionPlannedAction || (exports.RetentionPlannedAction = RetentionPlannedAction = {}));
|
|
16
|
-
var ArchiveVolumeStatus;
|
|
17
|
-
(function (ArchiveVolumeStatus) {
|
|
18
|
-
ArchiveVolumeStatus["OK"] = "OK";
|
|
19
|
-
ArchiveVolumeStatus["WARN"] = "WARN";
|
|
20
|
-
ArchiveVolumeStatus["CRITICAL"] = "CRITICAL";
|
|
21
|
-
ArchiveVolumeStatus["UNKNOWN"] = "UNKNOWN";
|
|
22
|
-
})(ArchiveVolumeStatus || (exports.ArchiveVolumeStatus = ArchiveVolumeStatus = {}));
|
|
23
16
|
//# sourceMappingURL=infrastructure.admin.response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infrastructure.admin.response.js","sourceRoot":"","sources":["../../../../../src/types/interface/api/responses/infrastructure.admin.response.ts"],"names":[],"mappings":";;;AAoBA,IAAY,yBAOX;AAPD,WAAY,yBAAyB;IAEnC,sEAAyC,CAAA;IAEzC,oDAAuB,CAAA;IAEvB,4CAAe,CAAA;AACjB,CAAC,EAPW,yBAAyB,yCAAzB,yBAAyB,QAOpC;AAoCD,IAAY,sBAIX;AAJD,WAAY,sBAAsB;IAChC,uCAAa,CAAA;IACb,6CAAmB,CAAA;IACnB,6CAAmB,CAAA;AACrB,CAAC,EAJW,sBAAsB,sCAAtB,sBAAsB,QAIjC
|
|
1
|
+
{"version":3,"file":"infrastructure.admin.response.js","sourceRoot":"","sources":["../../../../../src/types/interface/api/responses/infrastructure.admin.response.ts"],"names":[],"mappings":";;;AAoBA,IAAY,yBAOX;AAPD,WAAY,yBAAyB;IAEnC,sEAAyC,CAAA;IAEzC,oDAAuB,CAAA;IAEvB,4CAAe,CAAA;AACjB,CAAC,EAPW,yBAAyB,yCAAzB,yBAAyB,QAOpC;AAoCD,IAAY,sBAIX;AAJD,WAAY,sBAAsB;IAChC,uCAAa,CAAA;IACb,6CAAmB,CAAA;IACnB,6CAAmB,CAAA;AACrB,CAAC,EAJW,sBAAsB,sCAAtB,sBAAsB,QAIjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abyss-project/monitor",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Core package to interact with Abyss-Monitor",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"lint": "eslint \"{src,apps,libs,test,core}/**/*.ts\" --fix",
|
|
66
66
|
"lint:check": "eslint \"{src,apps,libs,test,core}/**/*.ts\" --max-warnings 0",
|
|
67
67
|
"tsc": "tsc",
|
|
68
|
-
"build": "tsc",
|
|
68
|
+
"build": "tsc -p tsconfig.build.json",
|
|
69
69
|
"dev": "tsc --watch",
|
|
70
70
|
"test": "jest",
|
|
71
71
|
"test:watch": "jest --watch"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const alert_utils_1 = require("../utils/alert.utils");
|
|
4
|
-
describe('D2 : lien du tableau de bord sans identifiant serveur', () => {
|
|
5
|
-
it("ne contient pas application_log_id= quand l'identifiant est absent (null)", () => {
|
|
6
|
-
const url = (0, alert_utils_1.buildDashboardLogUrl)(null);
|
|
7
|
-
expect(url).not.toContain('application_log_id=');
|
|
8
|
-
expect(url.endsWith('/monitor/log')).toBe(true);
|
|
9
|
-
});
|
|
10
|
-
it("ne contient pas application_log_id= quand l'identifiant est absent (undefined)", () => {
|
|
11
|
-
const url = (0, alert_utils_1.buildDashboardLogUrl)(undefined);
|
|
12
|
-
expect(url).not.toContain('application_log_id=');
|
|
13
|
-
expect(url.endsWith('/monitor/log')).toBe(true);
|
|
14
|
-
});
|
|
15
|
-
it("ajoute application_log_id= quand l'identifiant est connu", () => {
|
|
16
|
-
const url = (0, alert_utils_1.buildDashboardLogUrl)('log-123');
|
|
17
|
-
expect(url).toContain('application_log_id=log-123');
|
|
18
|
-
expect(url).not.toMatch(/application_log_id=$/);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
//# sourceMappingURL=alert-log-url.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"alert-log-url.test.js","sourceRoot":"","sources":["../../src/__tests__/alert-log-url.test.ts"],"names":[],"mappings":";;AAAA,sDAA4D;AAE5D,QAAQ,CAAC,uDAAuD,EAAE,GAAG,EAAE;IACrE,EAAE,CAAC,2EAA2E,EAAE,GAAG,EAAE;QACnF,MAAM,GAAG,GAAG,IAAA,kCAAoB,EAAC,IAAI,CAAC,CAAC;QACvC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;QACjD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,gFAAgF,EAAE,GAAG,EAAE;QACxF,MAAM,GAAG,GAAG,IAAA,kCAAoB,EAAC,SAAS,CAAC,CAAC;QAC5C,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,qBAAqB,CAAC,CAAC;QACjD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0DAA0D,EAAE,GAAG,EAAE;QAClE,MAAM,GAAG,GAAG,IAAA,kCAAoB,EAAC,SAAS,CAAC,CAAC;QAC5C,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;QACpD,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const net = __importStar(require("net"));
|
|
27
|
-
const axios_1 = require("axios");
|
|
28
|
-
const __1 = require("..");
|
|
29
|
-
const application_log_api_1 = require("../api/application-log.api");
|
|
30
|
-
const log_shipper_model_1 = require("../models/log-shipper.model");
|
|
31
|
-
const types_1 = require("../types");
|
|
32
|
-
describe('createBulkApplicationLog', () => {
|
|
33
|
-
afterEach(() => {
|
|
34
|
-
jest.restoreAllMocks();
|
|
35
|
-
});
|
|
36
|
-
it('POST sur /application-log/:applicationId/bulk avec le token en query', async () => {
|
|
37
|
-
const post = jest
|
|
38
|
-
.spyOn(__1.AbyssMonitorCore.axios, 'post')
|
|
39
|
-
.mockResolvedValue({ data: { data: { created: 2, deduped: 0 } } });
|
|
40
|
-
const body = {
|
|
41
|
-
logs: [
|
|
42
|
-
{ message: 'a', level: types_1.LogLevel.LOG, processId: '1', dateValue: new Date() },
|
|
43
|
-
{ message: 'b', level: types_1.LogLevel.LOG, processId: '1', dateValue: new Date() },
|
|
44
|
-
],
|
|
45
|
-
droppedCount: 3,
|
|
46
|
-
};
|
|
47
|
-
const response = await (0, application_log_api_1.createBulkApplicationLog)({ applicationId: 'app-1' }, { token: 'secret' }, body);
|
|
48
|
-
expect(post).toHaveBeenCalledWith('application-log/app-1/bulk', body, {
|
|
49
|
-
params: { token: 'secret' },
|
|
50
|
-
timeout: application_log_api_1.BULK_REQUEST_TIMEOUT_MS,
|
|
51
|
-
'axios-retry': { retries: 0 },
|
|
52
|
-
});
|
|
53
|
-
expect(response.data.created).toBe(2);
|
|
54
|
-
});
|
|
55
|
-
it("prend le délai de la requête dans timeoutMs quand l'appelant en donne un", async () => {
|
|
56
|
-
const post = jest
|
|
57
|
-
.spyOn(__1.AbyssMonitorCore.axios, 'post')
|
|
58
|
-
.mockResolvedValue({ data: { data: { created: 0, deduped: 0 } } });
|
|
59
|
-
await (0, application_log_api_1.createBulkApplicationLog)({ applicationId: 'app-1' }, { token: 'secret' }, {
|
|
60
|
-
logs: [],
|
|
61
|
-
}, { timeoutMs: 1_234 });
|
|
62
|
-
expect(post.mock.calls[0][2]).toMatchObject({ timeout: 1_234 });
|
|
63
|
-
});
|
|
64
|
-
describe('timeout', () => {
|
|
65
|
-
it('abandonne une requête restée sans réponse, et le shipper la garde pour plus tard', async () => {
|
|
66
|
-
const sockets = [];
|
|
67
|
-
const server = net.createServer((socket) => {
|
|
68
|
-
sockets.push(socket);
|
|
69
|
-
});
|
|
70
|
-
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
|
|
71
|
-
const { port } = server.address();
|
|
72
|
-
const originalBaseURL = __1.AbyssMonitorCore.axios.defaults.baseURL;
|
|
73
|
-
__1.AbyssMonitorCore.axios.defaults.baseURL = `http://127.0.0.1:${port}/`;
|
|
74
|
-
let requestedTimeout;
|
|
75
|
-
const interceptor = __1.AbyssMonitorCore.axios.interceptors.request.use((config) => {
|
|
76
|
-
requestedTimeout = config.timeout;
|
|
77
|
-
config.timeout = 50;
|
|
78
|
-
return config;
|
|
79
|
-
});
|
|
80
|
-
try {
|
|
81
|
-
const startedAt = Date.now();
|
|
82
|
-
const error = await (0, application_log_api_1.createBulkApplicationLog)({ applicationId: 'app-1' }, { token: 'secret' }, { logs: [] }).then(() => null, (rejection) => rejection);
|
|
83
|
-
expect(application_log_api_1.BULK_REQUEST_TIMEOUT_MS).toBe(10_000);
|
|
84
|
-
expect(requestedTimeout).toBe(application_log_api_1.BULK_REQUEST_TIMEOUT_MS);
|
|
85
|
-
expect(Date.now() - startedAt).toBeLessThan(2_000);
|
|
86
|
-
expect(error?.code).toMatch(/^(ECONNABORTED|ETIMEDOUT)$/);
|
|
87
|
-
expect(error?.response).toBeUndefined();
|
|
88
|
-
expect((0, log_shipper_model_1.classifySendError)(error)).toBe(log_shipper_model_1.SendOutcome.RETRY);
|
|
89
|
-
}
|
|
90
|
-
finally {
|
|
91
|
-
__1.AbyssMonitorCore.axios.interceptors.request.eject(interceptor);
|
|
92
|
-
__1.AbyssMonitorCore.axios.defaults.baseURL = originalBaseURL;
|
|
93
|
-
sockets.forEach((socket) => socket.destroy());
|
|
94
|
-
await new Promise((resolve) => server.close(resolve));
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
describe('axios-retry override', () => {
|
|
99
|
-
const originalAdapter = __1.AbyssMonitorCore.axios.defaults.adapter;
|
|
100
|
-
afterEach(() => {
|
|
101
|
-
__1.AbyssMonitorCore.axios.defaults.adapter = originalAdapter;
|
|
102
|
-
});
|
|
103
|
-
const rejectWith503Adapter = (attempts) => (config) => {
|
|
104
|
-
attempts.count += 1;
|
|
105
|
-
const response = {
|
|
106
|
-
status: 503,
|
|
107
|
-
statusText: 'Service Unavailable',
|
|
108
|
-
headers: {},
|
|
109
|
-
config,
|
|
110
|
-
data: {},
|
|
111
|
-
};
|
|
112
|
-
return Promise.reject(new axios_1.AxiosError('Service Unavailable', axios_1.AxiosError.ERR_BAD_RESPONSE, config, null, response));
|
|
113
|
-
};
|
|
114
|
-
it('rejects after exactly one attempt even though the shared axios-retry config is enabled', async () => {
|
|
115
|
-
__1.AbyssMonitorCore.enableAxiosRetry({ retryDelay: () => 0 });
|
|
116
|
-
const attempts = { count: 0 };
|
|
117
|
-
__1.AbyssMonitorCore.axios.defaults.adapter = rejectWith503Adapter(attempts);
|
|
118
|
-
await expect((0, application_log_api_1.createBulkApplicationLog)({ applicationId: 'app-1' }, { token: 'secret' }, {
|
|
119
|
-
logs: [],
|
|
120
|
-
})).rejects.toMatchObject({ response: { status: 503 } });
|
|
121
|
-
expect(attempts.count).toBe(1);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
//# sourceMappingURL=application-log-bulk-api.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"application-log-bulk-api.test.js","sourceRoot":"","sources":["../../src/__tests__/application-log-bulk-api.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA2B;AAC3B,iCAA8E;AAC9E,0BAAsC;AACtC,oEAA+F;AAC/F,mEAA6E;AAC7E,oCAAoC;AAEpC,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IAGxC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sEAAsE,EAAE,KAAK,IAAI,EAAE;QACpF,MAAM,IAAI,GAAG,IAAI;aACd,KAAK,CAAC,oBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC;aACrC,iBAAiB,CAAC,EAAE,IAAI,EAAE,E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AC,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;YAEvD,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const body_redaction_1 = require("../utils/body-redaction");
|
|
4
|
-
describe('redactCapturedBody', () => {
|
|
5
|
-
it('drops credential keys by suffix, whatever the case or separator', () => {
|
|
6
|
-
const body = {
|
|
7
|
-
email: 'a@b.c',
|
|
8
|
-
password: 'p',
|
|
9
|
-
currentPassword: 'p',
|
|
10
|
-
new_password: 'p',
|
|
11
|
-
accessToken: 't',
|
|
12
|
-
refresh_token: 't',
|
|
13
|
-
'x-admin-token': 't',
|
|
14
|
-
adminToken: 't',
|
|
15
|
-
clientSecret: 's',
|
|
16
|
-
webhook_secret: 's',
|
|
17
|
-
apiKey: 'k',
|
|
18
|
-
API_KEY: 'k',
|
|
19
|
-
};
|
|
20
|
-
expect((0, body_redaction_1.redactCapturedBody)(body, body_redaction_1.CapturedBodySide.REQUEST)).toEqual({ email: 'a@b.c' });
|
|
21
|
-
});
|
|
22
|
-
it('drops exact keys sid, authorization and cookie', () => {
|
|
23
|
-
const body = { sid: 's', Authorization: 'Bearer x', cookie: 'c', user: { id: 'u1' } };
|
|
24
|
-
expect((0, body_redaction_1.redactCapturedBody)(body, body_redaction_1.CapturedBodySide.RESPONSE)).toEqual({ user: { id: 'u1' } });
|
|
25
|
-
});
|
|
26
|
-
it('drops code on the request side only', () => {
|
|
27
|
-
expect((0, body_redaction_1.redactCapturedBody)({ code: 'oauth-code', state: 'x' }, body_redaction_1.CapturedBodySide.REQUEST)).toEqual({
|
|
28
|
-
state: 'x',
|
|
29
|
-
});
|
|
30
|
-
expect((0, body_redaction_1.redactCapturedBody)({ code: 'emailNotVerified', type: 'authError' }, body_redaction_1.CapturedBodySide.RESPONSE)).toEqual({ code: 'emailNotVerified', type: 'authError' });
|
|
31
|
-
});
|
|
32
|
-
it('walks nested objects and arrays', () => {
|
|
33
|
-
const body = {
|
|
34
|
-
data: {
|
|
35
|
-
user: { id: 'u1' },
|
|
36
|
-
adminToken: 't',
|
|
37
|
-
items: [
|
|
38
|
-
{ id: 1, token: 'a' },
|
|
39
|
-
{ id: 2, token: 'b' },
|
|
40
|
-
],
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
expect((0, body_redaction_1.redactCapturedBody)(body, body_redaction_1.CapturedBodySide.RESPONSE)).toEqual({
|
|
44
|
-
data: { user: { id: 'u1' }, items: [{ id: 1 }, { id: 2 }] },
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
it('passes primitives, strings and null through unchanged', () => {
|
|
48
|
-
expect((0, body_redaction_1.redactCapturedBody)('Payload Too Large', body_redaction_1.CapturedBodySide.RESPONSE)).toBe('Payload Too Large');
|
|
49
|
-
expect((0, body_redaction_1.redactCapturedBody)(null, body_redaction_1.CapturedBodySide.REQUEST)).toBeNull();
|
|
50
|
-
expect((0, body_redaction_1.redactCapturedBody)(42, body_redaction_1.CapturedBodySide.REQUEST)).toBe(42);
|
|
51
|
-
expect((0, body_redaction_1.redactCapturedBody)(['a', 'b'], body_redaction_1.CapturedBodySide.REQUEST)).toEqual(['a', 'b']);
|
|
52
|
-
});
|
|
53
|
-
it('keeps keys that only contain a credential word without ending with it', () => {
|
|
54
|
-
expect((0, body_redaction_1.redactCapturedBody)({ tokenCount: 3, passwordUpdatedAt: 'd', secretName: 'n' }, body_redaction_1.CapturedBodySide.RESPONSE)).toEqual({ tokenCount: 3, passwordUpdatedAt: 'd', secretName: 'n' });
|
|
55
|
-
});
|
|
56
|
-
it('drops invitationTokenId, the consumption credential of an invitation (card #471 / ADR-0090)', () => {
|
|
57
|
-
const body = { invitationTokenId: 'inv-1', email: 'a@b.c' };
|
|
58
|
-
expect((0, body_redaction_1.redactCapturedBody)(body, body_redaction_1.CapturedBodySide.REQUEST)).toEqual({ email: 'a@b.c' });
|
|
59
|
-
expect((0, body_redaction_1.redactCapturedBody)(body, body_redaction_1.CapturedBodySide.RESPONSE)).toEqual({ email: 'a@b.c' });
|
|
60
|
-
});
|
|
61
|
-
it('keeps tokenHistoryId: it does not end with the tokenid suffix', () => {
|
|
62
|
-
const body = { tokenHistoryId: 'th-1' };
|
|
63
|
-
expect((0, body_redaction_1.redactCapturedBody)(body, body_redaction_1.CapturedBodySide.REQUEST)).toEqual({ tokenHistoryId: 'th-1' });
|
|
64
|
-
expect((0, body_redaction_1.redactCapturedBody)(body, body_redaction_1.CapturedBodySide.RESPONSE)).toEqual({ tokenHistoryId: 'th-1' });
|
|
65
|
-
});
|
|
66
|
-
it('never mutates its input', () => {
|
|
67
|
-
const body = { password: 'p', nested: { token: 't' } };
|
|
68
|
-
(0, body_redaction_1.redactCapturedBody)(body, body_redaction_1.CapturedBodySide.REQUEST);
|
|
69
|
-
expect(body).toEqual({ password: 'p', nested: { token: 't' } });
|
|
70
|
-
});
|
|
71
|
-
it('replaces nesting deeper than 32 levels with null', () => {
|
|
72
|
-
let deep = { token: 'leak' };
|
|
73
|
-
for (let i = 0; i < 40; i += 1)
|
|
74
|
-
deep = { child: deep };
|
|
75
|
-
const out = JSON.stringify((0, body_redaction_1.redactCapturedBody)(deep, body_redaction_1.CapturedBodySide.REQUEST));
|
|
76
|
-
expect(out).not.toContain('leak');
|
|
77
|
-
});
|
|
78
|
-
it('keeps a JSON-parsed __proto__ key as an own property instead of letting it vanish', () => {
|
|
79
|
-
const body = JSON.parse('{"__proto__":{"isAdmin":true},"email":"a@b.c"}');
|
|
80
|
-
const out = (0, body_redaction_1.redactCapturedBody)(body, body_redaction_1.CapturedBodySide.REQUEST);
|
|
81
|
-
expect(Object.keys(out)).toEqual(['__proto__', 'email']);
|
|
82
|
-
expect(JSON.stringify(out)).toContain('"__proto__"');
|
|
83
|
-
expect(Object.getPrototypeOf(out)).toBe(Object.prototype);
|
|
84
|
-
});
|
|
85
|
-
it('still drops a credential key nested under a __proto__ own property', () => {
|
|
86
|
-
const body = JSON.parse('{"__proto__":{"token":"leak","id":1}}');
|
|
87
|
-
const out = (0, body_redaction_1.redactCapturedBody)(body, body_redaction_1.CapturedBodySide.REQUEST);
|
|
88
|
-
expect(JSON.stringify(out)).not.toContain('leak');
|
|
89
|
-
expect(JSON.stringify(out)).toContain('"id":1');
|
|
90
|
-
});
|
|
91
|
-
it('does not pollute the global Object prototype', () => {
|
|
92
|
-
(0, body_redaction_1.redactCapturedBody)(JSON.parse('{"__proto__":{"isAdmin":true},"email":"a@b.c"}'), body_redaction_1.CapturedBodySide.REQUEST);
|
|
93
|
-
(0, body_redaction_1.redactCapturedBody)(JSON.parse('{"__proto__":{"token":"leak","id":1}}'), body_redaction_1.CapturedBodySide.REQUEST);
|
|
94
|
-
expect({}.isAdmin).toBeUndefined();
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
describe('isCredentialBodyKey', () => {
|
|
98
|
-
it('matches suffixes after normalization', () => {
|
|
99
|
-
expect((0, body_redaction_1.isCredentialBodyKey)('secretPublishToken', body_redaction_1.CapturedBodySide.RESPONSE)).toBe(true);
|
|
100
|
-
expect((0, body_redaction_1.isCredentialBodyKey)('personal_api_key', body_redaction_1.CapturedBodySide.RESPONSE)).toBe(true);
|
|
101
|
-
expect((0, body_redaction_1.isCredentialBodyKey)('description', body_redaction_1.CapturedBodySide.RESPONSE)).toBe(false);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
//# sourceMappingURL=body-redaction.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"body-redaction.test.js","sourceRoot":"","sources":["../../src/__tests__/body-redaction.test.ts"],"names":[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