@friggframework/core 2.0.0--canary.404.e9d4980.0 → 2.0.0--canary.405.b87f8d8.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.
|
@@ -119,6 +119,44 @@ router.get('/health/detailed', async (_req, res) => {
|
|
|
119
119
|
checks.status = 'unhealthy';
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
try {
|
|
123
|
+
const { STAGE, BYPASS_ENCRYPTION_STAGE, KMS_KEY_ARN, AES_KEY_ID } =
|
|
124
|
+
process.env;
|
|
125
|
+
const defaultBypassStages = ['dev', 'test', 'local'];
|
|
126
|
+
const useEnv = BYPASS_ENCRYPTION_STAGE !== undefined;
|
|
127
|
+
const bypassStages = useEnv
|
|
128
|
+
? BYPASS_ENCRYPTION_STAGE.split(',').map((s) => s.trim())
|
|
129
|
+
: defaultBypassStages;
|
|
130
|
+
const bypassed = bypassStages.includes(STAGE);
|
|
131
|
+
const mode = KMS_KEY_ARN ? 'kms' : AES_KEY_ID ? 'aes' : 'none';
|
|
132
|
+
|
|
133
|
+
let status = 'disabled';
|
|
134
|
+
// Having both KMS_KEY_ARN and AES_KEY_ID present is considered unhealthy,
|
|
135
|
+
// as only one encryption method should be configured at a time to avoid ambiguity
|
|
136
|
+
// and potential security misconfiguration.
|
|
137
|
+
if (KMS_KEY_ARN && AES_KEY_ID) {
|
|
138
|
+
status = 'unhealthy';
|
|
139
|
+
} else if (!bypassed && mode !== 'none') {
|
|
140
|
+
status = 'enabled';
|
|
141
|
+
} else {
|
|
142
|
+
status = 'disabled';
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
checks.checks.encryption = {
|
|
146
|
+
status,
|
|
147
|
+
mode,
|
|
148
|
+
bypassed,
|
|
149
|
+
stage: STAGE || null,
|
|
150
|
+
};
|
|
151
|
+
if (status === 'unhealthy') checks.status = 'unhealthy';
|
|
152
|
+
} catch (error) {
|
|
153
|
+
checks.checks.encryption = {
|
|
154
|
+
status: 'unhealthy',
|
|
155
|
+
error: error.message,
|
|
156
|
+
};
|
|
157
|
+
checks.status = 'unhealthy';
|
|
158
|
+
}
|
|
159
|
+
|
|
122
160
|
const externalAPIs = [
|
|
123
161
|
{ name: 'github', url: 'https://api.github.com/status' },
|
|
124
162
|
{ name: 'npm', url: 'https://registry.npmjs.org' }
|
|
@@ -141,19 +179,25 @@ router.get('/health/detailed', async (_req, res) => {
|
|
|
141
179
|
});
|
|
142
180
|
|
|
143
181
|
try {
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
182
|
+
const moduleTypes = Array.isArray(moduleFactory.moduleTypes)
|
|
183
|
+
? moduleFactory.moduleTypes
|
|
184
|
+
: [];
|
|
185
|
+
const integrationTypes = Array.isArray(
|
|
186
|
+
integrationFactory.integrationTypes
|
|
187
|
+
)
|
|
188
|
+
? integrationFactory.integrationTypes
|
|
189
|
+
: [];
|
|
190
|
+
|
|
147
191
|
checks.checks.integrations = {
|
|
148
192
|
status: 'healthy',
|
|
149
193
|
modules: {
|
|
150
|
-
count:
|
|
151
|
-
available:
|
|
194
|
+
count: moduleTypes.length,
|
|
195
|
+
available: moduleTypes,
|
|
152
196
|
},
|
|
153
197
|
integrations: {
|
|
154
|
-
count:
|
|
155
|
-
available:
|
|
156
|
-
}
|
|
198
|
+
count: integrationTypes.length,
|
|
199
|
+
available: integrationTypes,
|
|
200
|
+
},
|
|
157
201
|
};
|
|
158
202
|
} catch (error) {
|
|
159
203
|
checks.checks.integrations = {
|
|
@@ -188,8 +232,10 @@ router.get('/health/ready', async (_req, res) => {
|
|
|
188
232
|
checks.checks.database = dbState === 1;
|
|
189
233
|
|
|
190
234
|
try {
|
|
191
|
-
const
|
|
192
|
-
|
|
235
|
+
const moduleTypes = Array.isArray(moduleFactory.moduleTypes)
|
|
236
|
+
? moduleFactory.moduleTypes
|
|
237
|
+
: [];
|
|
238
|
+
checks.checks.modules = moduleTypes.length > 0;
|
|
193
239
|
} catch (error) {
|
|
194
240
|
checks.checks.modules = false;
|
|
195
241
|
}
|
|
@@ -14,16 +14,10 @@ jest.mock('mongoose', () => ({
|
|
|
14
14
|
|
|
15
15
|
jest.mock('./../backend-utils', () => ({
|
|
16
16
|
moduleFactory: {
|
|
17
|
-
|
|
18
|
-
'test-module': {},
|
|
19
|
-
'another-module': {}
|
|
20
|
-
})
|
|
17
|
+
moduleTypes: ['test-module', 'another-module']
|
|
21
18
|
},
|
|
22
19
|
integrationFactory: {
|
|
23
|
-
|
|
24
|
-
'test-integration': {},
|
|
25
|
-
'another-integration': {}
|
|
26
|
-
})
|
|
20
|
+
integrationTypes: ['test-integration', 'another-integration']
|
|
27
21
|
}
|
|
28
22
|
}));
|
|
29
23
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/core",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.
|
|
4
|
+
"version": "2.0.0--canary.405.b87f8d8.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@hapi/boom": "^10.0.1",
|
|
7
7
|
"aws-sdk": "^2.1200.0",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"uuid": "^9.0.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@friggframework/eslint-config": "2.0.0--canary.
|
|
26
|
-
"@friggframework/prettier-config": "2.0.0--canary.
|
|
27
|
-
"@friggframework/test": "2.0.0--canary.
|
|
25
|
+
"@friggframework/eslint-config": "2.0.0--canary.405.b87f8d8.0",
|
|
26
|
+
"@friggframework/prettier-config": "2.0.0--canary.405.b87f8d8.0",
|
|
27
|
+
"@friggframework/test": "2.0.0--canary.405.b87f8d8.0",
|
|
28
28
|
"@types/lodash": "4.17.15",
|
|
29
29
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
30
30
|
"chai": "^4.3.6",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
},
|
|
54
54
|
"homepage": "https://github.com/friggframework/frigg#readme",
|
|
55
55
|
"description": "",
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "b87f8d874639f6fbb52c8a7efc7841c879a1286f"
|
|
57
57
|
}
|