@digitraffic/common 2024.8.14-1 → 2024.8.27-1
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/dist/{test/asserter.mjs → __test__/asserter.js} +3 -3
- package/dist/{test/db-testutils.d.mts → __test__/db-testutils.d.ts} +1 -1
- package/dist/{test/db-testutils.mjs → __test__/db-testutils.js} +4 -3
- package/dist/__test__/{dependencies.test.mjs → dependencies.test.js} +1 -1
- package/dist/__test__/{imports.test.mjs → imports.test.js} +79 -79
- package/dist/__test__/infra/{acl-builder.test.mjs → acl-builder.test.js} +4 -4
- package/dist/__test__/infra/api/{handler-factory.test.mjs → handler-factory.test.js} +3 -4
- package/dist/__test__/infra/api/{response.test.mjs → response.test.js} +3 -11
- package/dist/__test__/infra/api/{static-integration.test.mjs → static-integration.test.js} +3 -3
- package/dist/__test__/infra/{documentation.test.mjs → documentation.test.js} +2 -2
- package/dist/__test__/infra/{scheduler.test.mjs → scheduler.test.js} +2 -2
- package/dist/__test__/infra/{security-rule.test.mjs → security-rule.test.js} +2 -2
- package/dist/__test__/marine/{id_utils.test.mjs → id_utils.test.js} +3 -3
- package/dist/{test/mock-ky.mjs → __test__/mock-ky.js} +1 -1
- package/dist/__test__/promise/{promise.test.mjs → promise.test.js} +9 -13
- package/dist/__test__/runtime/{dt-logger.test.mjs → dt-logger.test.js} +7 -7
- package/dist/__test__/secrets/{secret-holder.test.mjs → secret-holder.test.js} +6 -4
- package/dist/__test__/secrets/{secret.test.mjs → secret.test.js} +4 -2
- package/dist/__test__/stack/{rest-apis.test.mjs → rest-apis.test.js} +4 -4
- package/dist/__test__/test/{mock-ky.test.mjs → mock-ky.test.js} +3 -3
- package/dist/{test/testutils.mjs → __test__/testutils.js} +1 -2
- package/dist/__test__/types/{lambda-response.test.mjs → lambda-response.test.js} +2 -2
- package/dist/__test__/utils/{date-utils.test.mjs → date-utils.test.js} +3 -3
- package/dist/__test__/utils/{geometry.test.mjs → geometry.test.js} +3 -3
- package/dist/__test__/utils/{logging.test.mjs → logging.test.js} +4 -4
- package/dist/__test__/utils/{utils.test.mjs → utils.test.js} +2 -3
- package/dist/aws/infra/acl-builder.d.ts +41 -0
- package/dist/aws/infra/{acl-builder.mjs → acl-builder.js} +82 -57
- package/dist/aws/infra/api/{handler-factory.d.mts → handler-factory.d.ts} +4 -4
- package/dist/aws/infra/api/{handler-factory.mjs → handler-factory.js} +7 -5
- package/dist/aws/infra/api/{integration.d.mts → integration.d.ts} +3 -1
- package/dist/aws/infra/api/{integration.mjs → integration.js} +34 -13
- package/dist/aws/infra/api/{response.d.mts → response.d.ts} +2 -2
- package/dist/aws/infra/api/{response.mjs → response.js} +4 -4
- package/dist/aws/infra/api/{responses.d.mts → responses.d.ts} +3 -3
- package/dist/aws/infra/api/{responses.mjs → responses.js} +4 -6
- package/dist/aws/infra/api/{static-integration.d.mts → static-integration.d.ts} +2 -2
- package/dist/aws/infra/api/{static-integration.mjs → static-integration.js} +3 -3
- package/dist/aws/infra/canaries/canary-alarm.d.ts +6 -0
- package/dist/aws/infra/canaries/{canary-alarm.mjs → canary-alarm.js} +1 -3
- package/dist/aws/infra/canaries/{canary-keys.mjs → canary-keys.js} +1 -1
- package/dist/aws/infra/canaries/{canary-parameters.d.mts → canary-parameters.d.ts} +1 -1
- package/dist/aws/infra/canaries/canary-parameters.js +2 -0
- package/dist/aws/infra/canaries/{canary-role.d.mts → canary-role.d.ts} +1 -1
- package/dist/aws/infra/canaries/{canary-role.mjs → canary-role.js} +2 -5
- package/dist/aws/infra/canaries/{canary.d.mts → canary.d.ts} +4 -4
- package/dist/aws/infra/canaries/{canary.mjs → canary.js} +3 -4
- package/dist/aws/infra/canaries/{database-canary.d.mts → database-canary.d.ts} +4 -5
- package/dist/aws/infra/canaries/{database-canary.mjs → database-canary.js} +4 -11
- package/dist/aws/infra/canaries/{database-checker.d.mts → database-checker.d.ts} +5 -5
- package/dist/aws/infra/canaries/{database-checker.mjs → database-checker.js} +15 -12
- package/dist/aws/infra/canaries/{url-canary.d.mts → url-canary.d.ts} +5 -5
- package/dist/aws/infra/canaries/{url-canary.mjs → url-canary.js} +7 -12
- package/dist/aws/infra/canaries/{url-checker.d.mts → url-checker.d.ts} +2 -2
- package/dist/aws/infra/canaries/{url-checker.mjs → url-checker.js} +12 -21
- package/dist/aws/infra/{documentation.d.mts → documentation.d.ts} +2 -2
- package/dist/aws/infra/{documentation.mjs → documentation.js} +4 -3
- package/dist/aws/infra/{import-util.d.mts → import-util.d.ts} +2 -2
- package/dist/aws/infra/{import-util.mjs → import-util.js} +3 -3
- package/dist/aws/infra/{scheduler.d.mts → scheduler.d.ts} +2 -2
- package/dist/aws/infra/{scheduler.mjs → scheduler.js} +1 -3
- package/dist/aws/infra/{security-rule.d.mts → security-rule.d.ts} +1 -1
- package/dist/aws/infra/{security-rule.mjs → security-rule.js} +1 -2
- package/dist/aws/infra/{sqs-integration.d.mts → sqs-integration.d.ts} +3 -3
- package/dist/aws/infra/{sqs-integration.mjs → sqs-integration.js} +3 -7
- package/dist/aws/infra/{sqs-queue.d.mts → sqs-queue.d.ts} +1 -1
- package/dist/aws/infra/{sqs-queue.mjs → sqs-queue.js} +19 -19
- package/dist/aws/infra/stack/{lambda-configs.d.mts → lambda-configs.d.ts} +4 -4
- package/dist/aws/infra/stack/{lambda-configs.mjs → lambda-configs.js} +3 -7
- package/dist/aws/infra/stack/{monitoredfunction.d.mts → monitoredfunction.d.ts} +15 -15
- package/dist/aws/infra/stack/{monitoredfunction.mjs → monitoredfunction.js} +42 -43
- package/dist/aws/infra/stack/{parameters.mjs → parameters.js} +1 -1
- package/dist/aws/infra/stack/{rest_apis.d.mts → rest_apis.d.ts} +12 -6
- package/dist/aws/infra/stack/{rest_apis.mjs → rest_apis.js} +26 -24
- package/dist/aws/infra/stack/{stack-checking-aspect.mjs → stack-checking-aspect.js} +7 -2
- package/dist/aws/infra/stack/{stack.d.mts → stack.d.ts} +4 -4
- package/dist/aws/infra/stack/{stack.mjs → stack.js} +2 -5
- package/dist/aws/infra/stack/{subscription.d.mts → subscription.d.ts} +4 -4
- package/dist/aws/infra/stack/{subscription.mjs → subscription.js} +2 -6
- package/dist/aws/infra/stacks/{db-dns-stack.d.mts → db-dns-stack.d.ts} +1 -1
- package/dist/aws/infra/stacks/{db-dns-stack.mjs → db-dns-stack.js} +4 -4
- package/dist/aws/infra/stacks/{db-proxy-stack.d.mts → db-proxy-stack.d.ts} +2 -2
- package/dist/aws/infra/stacks/{db-proxy-stack.mjs → db-proxy-stack.js} +5 -6
- package/dist/aws/infra/stacks/{db-stack.d.mts → db-stack.d.ts} +4 -4
- package/dist/aws/infra/stacks/{db-stack.mjs → db-stack.js} +7 -10
- package/dist/aws/infra/stacks/intra-stack-configuration.js +2 -0
- package/dist/aws/infra/stacks/{network-stack.d.mts → network-stack.d.ts} +2 -2
- package/dist/aws/infra/stacks/{network-stack.mjs → network-stack.js} +4 -7
- package/dist/aws/infra/{usage-plans.d.mts → usage-plans.d.ts} +1 -1
- package/dist/aws/infra/{usage-plans.mjs → usage-plans.js} +1 -2
- package/dist/aws/runtime/{apikey.mjs → apikey.js} +1 -1
- package/dist/aws/runtime/{digitraffic-integration-response.d.mts → digitraffic-integration-response.d.ts} +1 -1
- package/dist/aws/runtime/{digitraffic-integration-response.mjs → digitraffic-integration-response.js} +4 -6
- package/dist/aws/runtime/{dt-logger-default.d.mts → dt-logger-default.d.ts} +2 -2
- package/dist/aws/runtime/{dt-logger-default.mjs → dt-logger-default.js} +2 -2
- package/dist/aws/runtime/{dt-logger.mjs → dt-logger.js} +9 -4
- package/dist/aws/runtime/{environment.mjs → environment.js} +2 -2
- package/dist/aws/runtime/{s3.d.mts → s3.d.ts} +1 -1
- package/dist/aws/runtime/{s3.mjs → s3.js} +3 -3
- package/dist/aws/runtime/secrets/{dbsecret.d.mts → dbsecret.d.ts} +1 -1
- package/dist/aws/runtime/secrets/{dbsecret.mjs → dbsecret.js} +6 -2
- package/dist/aws/runtime/secrets/proxy-holder.js +25 -0
- package/dist/aws/runtime/secrets/rds-holder.js +25 -0
- package/dist/aws/runtime/secrets/{secret-holder.d.mts → secret-holder.d.ts} +6 -5
- package/dist/aws/runtime/secrets/{secret-holder.mjs → secret-holder.js} +11 -12
- package/dist/aws/runtime/secrets/{secret.mjs → secret.js} +7 -3
- package/dist/aws/types/{errors.mjs → errors.js} +1 -1
- package/dist/aws/types/{lambda-response.mjs → lambda-response.js} +1 -1
- package/dist/aws/types/{mediatypes.mjs → mediatypes.js} +1 -1
- package/dist/aws/types/{model-with-reference.d.mts → model-with-reference.d.ts} +1 -1
- package/dist/aws/types/model-with-reference.js +2 -0
- package/dist/aws/types/proxytypes.js +2 -0
- package/dist/aws/types/tags.js +4 -0
- package/dist/database/{cached.d.mts → cached.d.ts} +1 -1
- package/dist/database/{cached.mjs → cached.js} +2 -4
- package/dist/database/{database.mjs → database.js} +4 -8
- package/dist/database/{last-updated.d.mts → last-updated.d.ts} +1 -1
- package/dist/database/{last-updated.mjs → last-updated.js} +3 -1
- package/dist/database/models.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/marine/{id_utils.mjs → id_utils.js} +2 -2
- package/dist/marine/rtz.js +2 -0
- package/dist/types/{async-timeout-error.mjs → async-timeout-error.js} +1 -1
- package/dist/types/aws-env.js +2 -0
- package/dist/types/either.js +2 -0
- package/dist/types/{http-error.mjs → http-error.js} +1 -1
- package/dist/types/{input-error.mjs → input-error.js} +1 -1
- package/dist/types/{language.mjs → language.js} +1 -1
- package/dist/types/{nullable.d.mts → nullable.d.ts} +1 -1
- package/dist/types/nullable.js +2 -0
- package/dist/types/{traffictype.mjs → traffictype.js} +1 -1
- package/dist/types/urn.js +2 -0
- package/dist/types/util-types.js +2 -0
- package/dist/types/{validator.mjs → validator.js} +1 -1
- package/dist/utils/{api-model.d.mts → api-model.d.ts} +6 -5
- package/dist/utils/{api-model.mjs → api-model.js} +14 -15
- package/dist/utils/{base64.mjs → base64.js} +3 -3
- package/dist/utils/{date-utils.mjs → date-utils.js} +1 -1
- package/dist/utils/{geojson-types.d.mts → geojson-types.d.ts} +2 -2
- package/dist/utils/{geojson-types.mjs → geojson-types.js} +1 -1
- package/dist/utils/{geometry.d.mts → geometry.d.ts} +4 -3
- package/dist/utils/{geometry.mjs → geometry.js} +7 -4
- package/dist/utils/{logging.d.mts → logging.d.ts} +1 -1
- package/dist/utils/{logging.mjs → logging.js} +5 -8
- package/dist/utils/{retry.mjs → retry.js} +6 -8
- package/dist/utils/{slack.mjs → slack.js} +3 -3
- package/dist/utils/{utils.d.mts → utils.d.ts} +2 -3
- package/dist/utils/{utils.mjs → utils.js} +9 -5
- package/package.json +132 -129
- package/dist/aws/infra/acl-builder.d.mts +0 -31
- package/dist/aws/infra/canaries/canary-alarm.d.mts +0 -6
- package/dist/aws/infra/canaries/canary-parameters.mjs +0 -2
- package/dist/aws/infra/stacks/intra-stack-configuration.mjs +0 -2
- package/dist/aws/runtime/secrets/proxy-holder.mjs +0 -25
- package/dist/aws/runtime/secrets/rds-holder.mjs +0 -25
- package/dist/aws/types/model-with-reference.mjs +0 -2
- package/dist/aws/types/proxytypes.mjs +0 -2
- package/dist/aws/types/tags.mjs +0 -4
- package/dist/database/models.mjs +0 -2
- package/dist/index.d.mts +0 -1
- package/dist/index.mjs +0 -2
- package/dist/marine/rtz.mjs +0 -2
- package/dist/types/aws-env.mjs +0 -2
- package/dist/types/either.mjs +0 -2
- package/dist/types/nullable.mjs +0 -2
- package/dist/types/urn.mjs +0 -2
- package/dist/types/util-types.mjs +0 -2
- /package/dist/{test/asserter.d.mts → __test__/asserter.d.ts} +0 -0
- /package/dist/__test__/{dependencies.test.d.mts → dependencies.test.d.ts} +0 -0
- /package/dist/__test__/{imports.test.d.mts → imports.test.d.ts} +0 -0
- /package/dist/__test__/infra/{acl-builder.test.d.mts → acl-builder.test.d.ts} +0 -0
- /package/dist/__test__/infra/api/{handler-factory.test.d.mts → handler-factory.test.d.ts} +0 -0
- /package/dist/__test__/infra/api/{response.test.d.mts → response.test.d.ts} +0 -0
- /package/dist/__test__/infra/api/{static-integration.test.d.mts → static-integration.test.d.ts} +0 -0
- /package/dist/__test__/infra/{documentation.test.d.mts → documentation.test.d.ts} +0 -0
- /package/dist/__test__/infra/{scheduler.test.d.mts → scheduler.test.d.ts} +0 -0
- /package/dist/__test__/infra/{security-rule.test.d.mts → security-rule.test.d.ts} +0 -0
- /package/dist/__test__/marine/{id_utils.test.d.mts → id_utils.test.d.ts} +0 -0
- /package/dist/{test/mock-ky.d.mts → __test__/mock-ky.d.ts} +0 -0
- /package/dist/__test__/promise/{promise.test.d.mts → promise.test.d.ts} +0 -0
- /package/dist/__test__/runtime/{dt-logger.test.d.mts → dt-logger.test.d.ts} +0 -0
- /package/dist/__test__/secrets/{secret-holder.test.d.mts → secret-holder.test.d.ts} +0 -0
- /package/dist/__test__/secrets/{secret.test.d.mts → secret.test.d.ts} +0 -0
- /package/dist/__test__/stack/{rest-apis.test.d.mts → rest-apis.test.d.ts} +0 -0
- /package/dist/__test__/test/{mock-ky.test.d.mts → mock-ky.test.d.ts} +0 -0
- /package/dist/{test/testutils.d.mts → __test__/testutils.d.ts} +0 -0
- /package/dist/__test__/types/{lambda-response.test.d.mts → lambda-response.test.d.ts} +0 -0
- /package/dist/__test__/utils/{date-utils.test.d.mts → date-utils.test.d.ts} +0 -0
- /package/dist/__test__/utils/{geometry.test.d.mts → geometry.test.d.ts} +0 -0
- /package/dist/__test__/utils/{logging.test.d.mts → logging.test.d.ts} +0 -0
- /package/dist/__test__/utils/{utils.test.d.mts → utils.test.d.ts} +0 -0
- /package/dist/aws/infra/canaries/{canary-keys.d.mts → canary-keys.d.ts} +0 -0
- /package/dist/aws/infra/stack/{parameters.d.mts → parameters.d.ts} +0 -0
- /package/dist/aws/infra/stack/{stack-checking-aspect.d.mts → stack-checking-aspect.d.ts} +0 -0
- /package/dist/aws/infra/stacks/{intra-stack-configuration.d.mts → intra-stack-configuration.d.ts} +0 -0
- /package/dist/aws/runtime/{apikey.d.mts → apikey.d.ts} +0 -0
- /package/dist/aws/runtime/{dt-logger.d.mts → dt-logger.d.ts} +0 -0
- /package/dist/aws/runtime/{environment.d.mts → environment.d.ts} +0 -0
- /package/dist/aws/runtime/secrets/{proxy-holder.d.mts → proxy-holder.d.ts} +0 -0
- /package/dist/aws/runtime/secrets/{rds-holder.d.mts → rds-holder.d.ts} +0 -0
- /package/dist/aws/runtime/secrets/{secret.d.mts → secret.d.ts} +0 -0
- /package/dist/aws/types/{errors.d.mts → errors.d.ts} +0 -0
- /package/dist/aws/types/{lambda-response.d.mts → lambda-response.d.ts} +0 -0
- /package/dist/aws/types/{mediatypes.d.mts → mediatypes.d.ts} +0 -0
- /package/dist/aws/types/{proxytypes.d.mts → proxytypes.d.ts} +0 -0
- /package/dist/aws/types/{tags.d.mts → tags.d.ts} +0 -0
- /package/dist/database/{database.d.mts → database.d.ts} +0 -0
- /package/dist/database/{models.d.mts → models.d.ts} +0 -0
- /package/dist/marine/{id_utils.d.mts → id_utils.d.ts} +0 -0
- /package/dist/marine/{rtz.d.mts → rtz.d.ts} +0 -0
- /package/dist/types/{async-timeout-error.d.mts → async-timeout-error.d.ts} +0 -0
- /package/dist/types/{aws-env.d.mts → aws-env.d.ts} +0 -0
- /package/dist/types/{either.d.mts → either.d.ts} +0 -0
- /package/dist/types/{http-error.d.mts → http-error.d.ts} +0 -0
- /package/dist/types/{input-error.d.mts → input-error.d.ts} +0 -0
- /package/dist/types/{language.d.mts → language.d.ts} +0 -0
- /package/dist/types/{traffictype.d.mts → traffictype.d.ts} +0 -0
- /package/dist/types/{urn.d.mts → urn.d.ts} +0 -0
- /package/dist/types/{util-types.d.mts → util-types.d.ts} +0 -0
- /package/dist/types/{validator.d.mts → validator.d.ts} +0 -0
- /package/dist/utils/{base64.d.mts → base64.d.ts} +0 -0
- /package/dist/utils/{date-utils.d.mts → date-utils.d.ts} +0 -0
- /package/dist/utils/{retry.d.mts → retry.d.ts} +0 -0
- /package/dist/utils/{slack.d.mts → slack.d.ts} +0 -0
@@ -1,7 +1,7 @@
|
|
1
|
-
import { getRandomInteger } from "../../
|
2
|
-
import { retry, RetryLogError } from "../../utils/retry.
|
3
|
-
import { logger } from "../../aws/runtime/dt-logger-default.
|
4
|
-
import { jest } from
|
1
|
+
import { getRandomInteger } from "../../__test__/testutils.js";
|
2
|
+
import { retry, RetryLogError } from "../../utils/retry.js";
|
3
|
+
import { logger } from "../../aws/runtime/dt-logger-default.js";
|
4
|
+
import { jest } from "@jest/globals";
|
5
5
|
jest.useFakeTimers();
|
6
6
|
describe("Promise utils tests", () => {
|
7
7
|
test("retry - no retries", async () => {
|
@@ -32,8 +32,7 @@ describe("Promise utils tests", () => {
|
|
32
32
|
});
|
33
33
|
test("retry - errors with no error logging", async () => {
|
34
34
|
const fn = jest.fn(() => Promise.reject("error"));
|
35
|
-
const consoleErrorSpy = jest
|
36
|
-
.spyOn(logger, "error");
|
35
|
+
const consoleErrorSpy = jest.spyOn(logger, "error");
|
37
36
|
try {
|
38
37
|
await retry(fn, getRandomInteger(0, 10), RetryLogError.NO_LOGGING);
|
39
38
|
}
|
@@ -47,8 +46,7 @@ describe("Promise utils tests", () => {
|
|
47
46
|
});
|
48
47
|
test("retry - no retries with error logging", async () => {
|
49
48
|
const fn = jest.fn(() => Promise.reject("error"));
|
50
|
-
const consoleErrorSpy = jest
|
51
|
-
.spyOn(logger, "error");
|
49
|
+
const consoleErrorSpy = jest.spyOn(logger, "error");
|
52
50
|
try {
|
53
51
|
await retry(fn, 0, RetryLogError.LOG_ALL_AS_ERRORS);
|
54
52
|
}
|
@@ -63,8 +61,7 @@ describe("Promise utils tests", () => {
|
|
63
61
|
test("retry - retries with error logging", async () => {
|
64
62
|
const fn = jest.fn(() => Promise.reject("error"));
|
65
63
|
const retries = getRandomInteger(1, 10);
|
66
|
-
const consoleErrorSpy = jest
|
67
|
-
.spyOn(logger, "error");
|
64
|
+
const consoleErrorSpy = jest.spyOn(logger, "error");
|
68
65
|
try {
|
69
66
|
await retry(fn, retries, RetryLogError.LOG_ALL_AS_ERRORS);
|
70
67
|
}
|
@@ -82,8 +79,7 @@ describe("Promise utils tests", () => {
|
|
82
79
|
});
|
83
80
|
test("retry - defaults", async () => {
|
84
81
|
const fn = jest.fn(() => Promise.reject("error"));
|
85
|
-
const consoleErrorSpy = jest
|
86
|
-
.spyOn(logger, "error");
|
82
|
+
const consoleErrorSpy = jest.spyOn(logger, "error");
|
87
83
|
try {
|
88
84
|
await retry(fn);
|
89
85
|
}
|
@@ -127,4 +123,4 @@ describe("Promise utils tests", () => {
|
|
127
123
|
expect(ret).toBe(val);
|
128
124
|
});
|
129
125
|
});
|
130
|
-
//# sourceMappingURL=promise.test.
|
126
|
+
//# sourceMappingURL=promise.test.js.map
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Writable } from "stream";
|
2
|
-
import { DtLogger } from "../../aws/runtime/dt-logger.
|
2
|
+
import { DtLogger } from "../../aws/runtime/dt-logger.js";
|
3
3
|
const LOG_LINE = {
|
4
4
|
method: "dt-logger.test",
|
5
5
|
message: "FOO",
|
@@ -30,11 +30,11 @@ describe("dt-logger", () => {
|
|
30
30
|
expect(logged.length).toBe(1);
|
31
31
|
const loggedLine = JSON.parse(logged[0]);
|
32
32
|
console.info(loggedLine);
|
33
|
-
if (typeof expected === "object" &&
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
delete loggedLine[
|
33
|
+
if (typeof expected === "object" && "stack" in expected && expected.stack) {
|
34
|
+
// eslint-disable-next-line dot-notation
|
35
|
+
const stack = loggedLine["stack"];
|
36
|
+
// eslint-disable-next-line dot-notation
|
37
|
+
delete loggedLine["stack"];
|
38
38
|
delete expected.stack;
|
39
39
|
expect(stack).toBeDefined();
|
40
40
|
}
|
@@ -105,4 +105,4 @@ describe("dt-logger", () => {
|
|
105
105
|
});
|
106
106
|
});
|
107
107
|
});
|
108
|
-
//# sourceMappingURL=dt-logger.test.
|
108
|
+
//# sourceMappingURL=dt-logger.test.js.map
|
@@ -10,8 +10,9 @@ const emptySecret = { $metadata: {} };
|
|
10
10
|
const getSecretValueMock = jest.fn();
|
11
11
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
12
12
|
jest.spyOn(SecretsManager.prototype, "getSecretValue").mockImplementation(getSecretValueMock);
|
13
|
-
const { SecretHolder } = await import("../../aws/runtime/secrets/secret-holder.
|
14
|
-
const { DatabaseEnvironmentKeys } = await import("../../database/database.
|
13
|
+
const { SecretHolder } = await import("../../aws/runtime/secrets/secret-holder.js");
|
14
|
+
const { DatabaseEnvironmentKeys } = await import("../../database/database.js");
|
15
|
+
// eslint-disable-next-line @rushstack/no-new-null
|
15
16
|
function mockSecret(secret) {
|
16
17
|
if (!secret) {
|
17
18
|
getSecretValueMock.mockImplementation(() => Promise.resolve(emptySecret));
|
@@ -22,11 +23,12 @@ function mockSecret(secret) {
|
|
22
23
|
}
|
23
24
|
describe("SecretHolder - tests", () => {
|
24
25
|
beforeEach(() => {
|
26
|
+
// eslint-disable-next-line dot-notation
|
25
27
|
process.env["SECRET_ID"] = "test-id";
|
28
|
+
// eslint-disable-next-line dot-notation
|
26
29
|
process.env["AWS_REGION"] = "eu-west-1";
|
27
30
|
});
|
28
31
|
afterEach(() => {
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
30
32
|
delete process.env[DatabaseEnvironmentKeys.DB_USER];
|
31
33
|
});
|
32
34
|
test("get - no secret", () => {
|
@@ -93,4 +95,4 @@ describe("SecretHolder - tests", () => {
|
|
93
95
|
expect(getSecretValueMock).toHaveBeenCalledTimes(callCount + 2);
|
94
96
|
});
|
95
97
|
});
|
96
|
-
//# sourceMappingURL=secret-holder.test.
|
98
|
+
//# sourceMappingURL=secret-holder.test.js.map
|
@@ -10,6 +10,7 @@ const emptySecret = { $metadata: {} };
|
|
10
10
|
const getSecretValueMock = jest.fn();
|
11
11
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
12
12
|
jest.spyOn(SecretsManager.prototype, "getSecretValue").mockImplementation(getSecretValueMock);
|
13
|
+
// eslint-disable-next-line @rushstack/no-new-null
|
13
14
|
function mockSecret(secret) {
|
14
15
|
if (!secret) {
|
15
16
|
getSecretValueMock.mockImplementation(() => Promise.resolve(emptySecret));
|
@@ -18,8 +19,9 @@ function mockSecret(secret) {
|
|
18
19
|
getSecretValueMock.mockImplementation(() => Promise.resolve({ ...emptySecret, ...{ SecretString: JSON.stringify(secret) } }));
|
19
20
|
}
|
20
21
|
}
|
22
|
+
// eslint-disable-next-line dot-notation
|
21
23
|
process.env["AWS_REGION"] = "eu-west-1";
|
22
|
-
const secret = await import("../../aws/runtime/secrets/secret.
|
24
|
+
const secret = await import("../../aws/runtime/secrets/secret.js");
|
23
25
|
const { getSecret } = secret;
|
24
26
|
describe("secret - test", () => {
|
25
27
|
test("getSecret - no secret", async () => {
|
@@ -47,4 +49,4 @@ describe("secret - test", () => {
|
|
47
49
|
});
|
48
50
|
});
|
49
51
|
});
|
50
|
-
//# sourceMappingURL=secret.test.
|
52
|
+
//# sourceMappingURL=secret.test.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { App } from "aws-cdk-lib";
|
2
|
-
import { DigitrafficRestApi } from "../../aws/infra/stack/rest_apis.
|
3
|
-
import { DigitrafficStack } from "../../aws/infra/stack/stack.
|
4
|
-
import { TrafficType } from "../../types/traffictype.
|
2
|
+
import { DigitrafficRestApi } from "../../aws/infra/stack/rest_apis.js";
|
3
|
+
import { DigitrafficStack } from "../../aws/infra/stack/stack.js";
|
4
|
+
import { TrafficType } from "../../types/traffictype.js";
|
5
5
|
import { Match, Template } from "aws-cdk-lib/assertions";
|
6
6
|
describe("Rest api test", () => {
|
7
7
|
test("OPTIONS method is added to API-gateway", () => {
|
@@ -39,4 +39,4 @@ describe("Rest api test", () => {
|
|
39
39
|
});
|
40
40
|
});
|
41
41
|
});
|
42
|
-
//# sourceMappingURL=rest-apis.test.
|
42
|
+
//# sourceMappingURL=rest-apis.test.js.map
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { mockKyResponse } from "../../
|
2
|
-
import { describe,
|
1
|
+
import { mockKyResponse } from "../../__test__/mock-ky.js";
|
2
|
+
import { describe, jest, test } from "@jest/globals";
|
3
3
|
const ky = (await import("ky")).default;
|
4
4
|
describe("mockKyResponse", () => {
|
5
5
|
const testObj = { test: "data" };
|
@@ -43,4 +43,4 @@ describe("mockKyResponse", () => {
|
|
43
43
|
expect(await (await ky.get(url)).json()).toEqual(testObj);
|
44
44
|
});
|
45
45
|
});
|
46
|
-
//# sourceMappingURL=mock-ky.test.
|
46
|
+
//# sourceMappingURL=mock-ky.test.js.map
|
@@ -26,8 +26,7 @@ export function randomBoolean() {
|
|
26
26
|
export function shuffle(array) {
|
27
27
|
// pretty fast way to copy an array, not necessarily the fastest
|
28
28
|
const newArray = array.slice(0);
|
29
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
30
29
|
newArray.sort((_) => 0.5 - Math.random());
|
31
30
|
return newArray;
|
32
31
|
}
|
33
|
-
//# sourceMappingURL=testutils.
|
32
|
+
//# sourceMappingURL=testutils.js.map
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { LambdaResponse } from "../../aws/types/lambda-response.
|
1
|
+
import { LambdaResponse } from "../../aws/types/lambda-response.js";
|
2
2
|
describe("lambda-response", () => {
|
3
3
|
const TEST_MESSAGE = "HELLO";
|
4
4
|
const TEST_COUNT = 12;
|
@@ -55,4 +55,4 @@ describe("lambda-response", () => {
|
|
55
55
|
assertBinary(response, "Not implemented", 501);
|
56
56
|
});
|
57
57
|
});
|
58
|
-
//# sourceMappingURL=lambda-response.test.
|
58
|
+
//# sourceMappingURL=lambda-response.test.js.map
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { parseISO } from "date-fns";
|
2
|
-
import * as CommonDateUtils from "../../utils/date-utils.
|
2
|
+
import * as CommonDateUtils from "../../utils/date-utils.js";
|
3
3
|
const ISO = "2022-01-02T01:02:03.004Z";
|
4
4
|
describe("CommonDateUtilsTest", () => {
|
5
5
|
test("dateFromIsoString", () => {
|
@@ -7,7 +7,7 @@ describe("CommonDateUtilsTest", () => {
|
|
7
7
|
expect(parsed.toISOString()).toEqual(ISO);
|
8
8
|
});
|
9
9
|
test("dateFromIsoString fails", () => {
|
10
|
-
expect(() => CommonDateUtils.dateFromIsoString(ISO + "foobar")).
|
10
|
+
expect(() => CommonDateUtils.dateFromIsoString(ISO + "foobar")).toThrow();
|
11
11
|
});
|
12
12
|
test("countDiffMs", () => {
|
13
13
|
const start = new Date();
|
@@ -24,4 +24,4 @@ describe("CommonDateUtilsTest", () => {
|
|
24
24
|
expect(CommonDateUtils.dateToUTCString(date, CommonDateUtils.MYSQL_DATETIME_FORMAT)).toEqual("2023-01-01 00:00");
|
25
25
|
});
|
26
26
|
});
|
27
|
-
//# sourceMappingURL=date-utils.test.
|
27
|
+
//# sourceMappingURL=date-utils.test.js.map
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { Asserter } from "
|
2
|
-
import * as Geometry from "../../utils/geometry.
|
1
|
+
import { Asserter } from "../asserter.js";
|
2
|
+
import * as Geometry from "../../utils/geometry.js";
|
3
3
|
const TAMPERE_WGS84_X = 23.761290078;
|
4
4
|
const TAMPERE_WGS84_Y = 61.49774257;
|
5
5
|
const KUOPIO_WGS84_X = 27.688935;
|
@@ -21,4 +21,4 @@ describe("CommonGeometryTest", () => {
|
|
21
21
|
expect(Geometry.areDistinctPositions([1, 2], [1, 2.000000000000001])).toBe(true);
|
22
22
|
});
|
23
23
|
});
|
24
|
-
//# sourceMappingURL=geometry.test.
|
24
|
+
//# sourceMappingURL=geometry.test.js.map
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Writable } from "stream";
|
2
|
-
import { DtLogger } from "../../aws/runtime/dt-logger.
|
3
|
-
import { logException } from "../../utils/logging.
|
2
|
+
import { DtLogger } from "../../aws/runtime/dt-logger.js";
|
3
|
+
import { logException } from "../../utils/logging.js";
|
4
4
|
const TEST_METHODNAME = "test.logException";
|
5
5
|
describe("dt-logger", () => {
|
6
6
|
function assertLogError(error, expected, includeStack = false) {
|
@@ -33,7 +33,7 @@ describe("dt-logger", () => {
|
|
33
33
|
delete expected.stack;
|
34
34
|
expect(stack).toBeDefined();
|
35
35
|
}
|
36
|
-
expect(loggedLine).
|
36
|
+
expect(loggedLine).toMatchObject(expected);
|
37
37
|
}
|
38
38
|
test("log error - string", () => {
|
39
39
|
const STRING_ERROR = "string error";
|
@@ -75,4 +75,4 @@ describe("dt-logger", () => {
|
|
75
75
|
});
|
76
76
|
});
|
77
77
|
});
|
78
|
-
//# sourceMappingURL=logging.test.
|
78
|
+
//# sourceMappingURL=logging.test.js.map
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import * as ArrayUtils from "../../utils/utils.
|
1
|
+
import * as ArrayUtils from "../../utils/utils.js";
|
2
2
|
describe("ArrayUtils", () => {
|
3
3
|
test("bothArraysHasSameValues", () => {
|
4
4
|
expect(ArrayUtils.bothArraysHasSameValues([], [])).toEqual(true);
|
@@ -10,7 +10,6 @@ describe("ArrayUtils", () => {
|
|
10
10
|
expect(ArrayUtils.bothArraysHasSameValues(null, undefined)).toEqual(true);
|
11
11
|
expect(ArrayUtils.bothArraysHasSameValues(["a"], undefined)).toEqual(false);
|
12
12
|
expect(ArrayUtils.bothArraysHasSameValues(["a"], null)).toEqual(false);
|
13
|
-
/* eslint-enable */
|
14
13
|
expect(ArrayUtils.bothArraysHasSameValues(["a", "b"], ["a", "a"])).toEqual(false);
|
15
14
|
expect(ArrayUtils.bothArraysHasSameValues(["a", "a", "a"], ["a", "b", "c"])).toEqual(false);
|
16
15
|
const o1 = { a: 1, b: 2 };
|
@@ -43,4 +42,4 @@ describe("ArrayUtils", () => {
|
|
43
42
|
expect([1, 2, undefined, null, 3].filter(ArrayUtils.isDefined)).toEqual([1, 2, 3]);
|
44
43
|
});
|
45
44
|
});
|
46
|
-
//# sourceMappingURL=utils.test.
|
45
|
+
//# sourceMappingURL=utils.test.js.map
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { CfnWebACL } from "aws-cdk-lib/aws-wafv2";
|
2
|
+
import type { Construct } from "constructs";
|
3
|
+
export type AWSManagedWafRule = "CommonRuleSet" | "AmazonIpReputationList" | "KnownBadInputsRuleSet" | "SQLiRuleSet";
|
4
|
+
export type ExcludedAWSRules = {
|
5
|
+
[key in AWSManagedWafRule]?: string[];
|
6
|
+
};
|
7
|
+
export type CfnWebAclRuleProperty = {
|
8
|
+
[P in keyof CfnWebACL.RuleProperty as Exclude<P, "priority">]: (CfnWebACL.RuleProperty)[P];
|
9
|
+
};
|
10
|
+
/**
|
11
|
+
* Builder class for building CfnWebACL.
|
12
|
+
*
|
13
|
+
* Currently supports:
|
14
|
+
* * Some AWS managed WAF rules
|
15
|
+
* * IP blacklisting
|
16
|
+
*/
|
17
|
+
export declare class AclBuilder {
|
18
|
+
readonly _construct: Construct;
|
19
|
+
readonly _countRules: CfnWebAclRuleProperty[];
|
20
|
+
readonly _blockRules: CfnWebAclRuleProperty[];
|
21
|
+
readonly _name: string;
|
22
|
+
_scope: string;
|
23
|
+
_customResponseBodies: Record<string, CfnWebACL.CustomResponseBodyProperty>;
|
24
|
+
constructor(construct: Construct, name?: string);
|
25
|
+
isRuleDefined(rules: AWSManagedWafRule[] | "all", rule: AWSManagedWafRule): boolean;
|
26
|
+
withAWSManagedRules(rules?: AWSManagedWafRule[] | "all", excludedRules?: ExcludedAWSRules): AclBuilder;
|
27
|
+
withIpRestrictionRule(addresses: string[]): AclBuilder;
|
28
|
+
withThrottleRule(name: string, limit: number, isHeaderRequired: boolean, isBasedOnIpAndUriPath: boolean, customResponseBodyKey?: string): AclBuilder;
|
29
|
+
withCustomResponseBody(key: string, customResponseBody: CfnWebACL.CustomResponseBodyProperty): AclBuilder;
|
30
|
+
withThrottleDigitrafficUserIp(limit: number | undefined): AclBuilder;
|
31
|
+
withThrottleDigitrafficUserIpAndUriPath(limit: number | undefined): AclBuilder;
|
32
|
+
withThrottleAnonymousUserIp(limit: number | undefined): AclBuilder;
|
33
|
+
withThrottleAnonymousUserIpAndUriPath(limit: number | undefined): AclBuilder;
|
34
|
+
withCountDigitrafficUserIp(limit: number | undefined): AclBuilder;
|
35
|
+
withCountDigitrafficUserIpAndUriPath(limit: number | undefined): AclBuilder;
|
36
|
+
withCountAnonymousUserIp(limit: number | undefined): AclBuilder;
|
37
|
+
withCountAnonymousUserIpAndUriPath(limit: number | undefined): AclBuilder;
|
38
|
+
_isCustomResponseBodyKeySet(key: string): boolean;
|
39
|
+
_addThrottleResponseBody(customResponseBodyKey: string, limit: number): void;
|
40
|
+
build(): CfnWebACL;
|
41
|
+
}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { CfnIPSet, CfnWebACL } from "aws-cdk-lib/aws-wafv2";
|
2
|
-
import { logger } from "../runtime/dt-logger-default.
|
2
|
+
import { logger } from "../runtime/dt-logger-default.js";
|
3
|
+
import { zipWith, range, concat } from "lodash-es";
|
3
4
|
/**
|
4
5
|
* Builder class for building CfnWebACL.
|
5
6
|
*
|
@@ -9,8 +10,9 @@ import { logger } from "../runtime/dt-logger-default.mjs";
|
|
9
10
|
*/
|
10
11
|
export class AclBuilder {
|
11
12
|
_construct;
|
12
|
-
|
13
|
-
|
13
|
+
_countRules = [];
|
14
|
+
_blockRules = [];
|
15
|
+
_name = "WebACL";
|
14
16
|
_scope = "CLOUDFRONT";
|
15
17
|
_customResponseBodies = {};
|
16
18
|
constructor(construct, name = "WebACL") {
|
@@ -20,18 +22,18 @@ export class AclBuilder {
|
|
20
22
|
isRuleDefined(rules, rule) {
|
21
23
|
return rules === "all" || rules.includes(rule);
|
22
24
|
}
|
23
|
-
withAWSManagedRules(rules = "all") {
|
25
|
+
withAWSManagedRules(rules = "all", excludedRules = {}) {
|
24
26
|
if (this.isRuleDefined(rules, "CommonRuleSet")) {
|
25
|
-
this.
|
27
|
+
this._blockRules.push(createAWSCommonRuleSet(excludedRules?.CommonRuleSet));
|
26
28
|
}
|
27
29
|
if (this.isRuleDefined(rules, "AmazonIpReputationList")) {
|
28
|
-
this.
|
30
|
+
this._blockRules.push(createAWSReputationList(excludedRules?.AmazonIpReputationList));
|
29
31
|
}
|
30
32
|
if (this.isRuleDefined(rules, "KnownBadInputsRuleSet")) {
|
31
|
-
this.
|
33
|
+
this._blockRules.push(createAWSKnownBadInput(excludedRules?.KnownBadInputsRuleSet));
|
32
34
|
}
|
33
35
|
if (this.isRuleDefined(rules, "SQLiRuleSet")) {
|
34
|
-
this.
|
36
|
+
this._blockRules.push(createAWSAntiSQLInjection(excludedRules?.SQLiRuleSet));
|
35
37
|
}
|
36
38
|
return this;
|
37
39
|
}
|
@@ -41,9 +43,8 @@ export class AclBuilder {
|
|
41
43
|
scope: this._scope,
|
42
44
|
addresses,
|
43
45
|
});
|
44
|
-
this.
|
46
|
+
this._blockRules.push({
|
45
47
|
name: "IpBlocklist",
|
46
|
-
priority: 10,
|
47
48
|
action: { block: {} },
|
48
49
|
statement: {
|
49
50
|
ipSetReferenceStatement: {
|
@@ -58,23 +59,27 @@ export class AclBuilder {
|
|
58
59
|
});
|
59
60
|
return this;
|
60
61
|
}
|
61
|
-
withThrottleRule(name,
|
62
|
-
|
62
|
+
withThrottleRule(name, limit, isHeaderRequired, isBasedOnIpAndUriPath, customResponseBodyKey) {
|
63
|
+
const isBlockRule = !!customResponseBodyKey;
|
64
|
+
const rules = isBlockRule ? this._blockRules : this._countRules;
|
65
|
+
const action = isBlockRule ? {
|
66
|
+
block: {
|
67
|
+
customResponse: {
|
68
|
+
responseCode: 429,
|
69
|
+
customResponseBodyKey,
|
70
|
+
},
|
71
|
+
},
|
72
|
+
} : {
|
73
|
+
count: {}
|
74
|
+
};
|
75
|
+
rules.push({
|
63
76
|
name,
|
64
|
-
priority,
|
65
77
|
visibilityConfig: {
|
66
78
|
sampledRequestsEnabled: true,
|
67
79
|
cloudWatchMetricsEnabled: true,
|
68
80
|
metricName: name,
|
69
81
|
},
|
70
|
-
action
|
71
|
-
block: {
|
72
|
-
customResponse: {
|
73
|
-
responseCode: 429,
|
74
|
-
customResponseBodyKey,
|
75
|
-
},
|
76
|
-
},
|
77
|
-
},
|
82
|
+
action,
|
78
83
|
statement: createThrottleStatement(limit, isHeaderRequired, isBasedOnIpAndUriPath),
|
79
84
|
});
|
80
85
|
return this;
|
@@ -90,40 +95,60 @@ export class AclBuilder {
|
|
90
95
|
return this;
|
91
96
|
}
|
92
97
|
withThrottleDigitrafficUserIp(limit) {
|
93
|
-
if (limit
|
94
|
-
this._logMissingLimit("withThrottleDigitrafficUserIp");
|
98
|
+
if (limit === undefined) {
|
95
99
|
return this;
|
96
100
|
}
|
97
101
|
const customResponseBodyKey = `IP_THROTTLE_DIGITRAFFIC_USER_${limit}`;
|
98
102
|
this._addThrottleResponseBody(customResponseBodyKey, limit);
|
99
|
-
return this.withThrottleRule("ThrottleRuleWithDigitrafficUser",
|
103
|
+
return this.withThrottleRule("ThrottleRuleWithDigitrafficUser", limit, true, false, customResponseBodyKey);
|
100
104
|
}
|
101
105
|
withThrottleDigitrafficUserIpAndUriPath(limit) {
|
102
|
-
if (limit
|
103
|
-
this._logMissingLimit("withThrottleDigitrafficUserIpAndUriPath");
|
106
|
+
if (limit === undefined) {
|
104
107
|
return this;
|
105
108
|
}
|
106
109
|
const customResponseBodyKey = `IP_PATH_THROTTLE_DIGITRAFFIC_USER_${limit}`;
|
107
110
|
this._addThrottleResponseBody(customResponseBodyKey, limit);
|
108
|
-
return this.withThrottleRule("ThrottleRuleIPQueryWithDigitrafficUser",
|
111
|
+
return this.withThrottleRule("ThrottleRuleIPQueryWithDigitrafficUser", limit, true, true, customResponseBodyKey);
|
109
112
|
}
|
110
113
|
withThrottleAnonymousUserIp(limit) {
|
111
|
-
if (limit
|
112
|
-
this._logMissingLimit("withThrottleAnonymousUserIp");
|
114
|
+
if (limit === undefined) {
|
113
115
|
return this;
|
114
116
|
}
|
115
117
|
const customResponseBodyKey = `IP_THROTTLE_ANONYMOUS_USER_${limit}`;
|
116
118
|
this._addThrottleResponseBody(customResponseBodyKey, limit);
|
117
|
-
return this.withThrottleRule("ThrottleRuleWithAnonymousUser",
|
119
|
+
return this.withThrottleRule("ThrottleRuleWithAnonymousUser", limit, false, false, customResponseBodyKey);
|
118
120
|
}
|
119
121
|
withThrottleAnonymousUserIpAndUriPath(limit) {
|
120
|
-
if (limit
|
121
|
-
this._logMissingLimit("withThrottleAnonymousUserIpAndUriPath");
|
122
|
+
if (limit === undefined) {
|
122
123
|
return this;
|
123
124
|
}
|
124
125
|
const customResponseBodyKey = `IP_PATH_THROTTLE_ANONYMOUS_USER_${limit}`;
|
125
126
|
this._addThrottleResponseBody(customResponseBodyKey, limit);
|
126
|
-
return this.withThrottleRule("ThrottleRuleIPQueryWithAnonymousUser",
|
127
|
+
return this.withThrottleRule("ThrottleRuleIPQueryWithAnonymousUser", limit, false, true, customResponseBodyKey);
|
128
|
+
}
|
129
|
+
withCountDigitrafficUserIp(limit) {
|
130
|
+
if (limit === undefined) {
|
131
|
+
return this;
|
132
|
+
}
|
133
|
+
return this.withThrottleRule(`CountRuleWithDigitrafficUser${limit}`, limit, true, false);
|
134
|
+
}
|
135
|
+
withCountDigitrafficUserIpAndUriPath(limit) {
|
136
|
+
if (limit === undefined) {
|
137
|
+
return this;
|
138
|
+
}
|
139
|
+
return this.withThrottleRule(`CountRuleIPQueryWithDigitrafficUser${limit}`, limit, true, true);
|
140
|
+
}
|
141
|
+
withCountAnonymousUserIp(limit) {
|
142
|
+
if (limit === undefined) {
|
143
|
+
return this;
|
144
|
+
}
|
145
|
+
return this.withThrottleRule(`CountRuleWithAnonymousUser${limit}`, limit, false, false);
|
146
|
+
}
|
147
|
+
withCountAnonymousUserIpAndUriPath(limit) {
|
148
|
+
if (limit === undefined) {
|
149
|
+
return this;
|
150
|
+
}
|
151
|
+
return this.withThrottleRule(`CountRuleIPQueryWithAnonymousUser${limit}`, limit, false, true);
|
127
152
|
}
|
128
153
|
_isCustomResponseBodyKeySet(key) {
|
129
154
|
return key in this._customResponseBodies;
|
@@ -136,21 +161,20 @@ export class AclBuilder {
|
|
136
161
|
});
|
137
162
|
}
|
138
163
|
}
|
139
|
-
_logMissingLimit(method) {
|
140
|
-
logger.warn({
|
141
|
-
method: `acl-builder.${method}`,
|
142
|
-
message: `'limit' was not defined. Not setting a throttle rule for ${this._name}`,
|
143
|
-
});
|
144
|
-
}
|
145
164
|
build() {
|
146
|
-
|
165
|
+
const addPriority = (rule, priority) => ({
|
166
|
+
...rule,
|
167
|
+
priority
|
168
|
+
});
|
169
|
+
const rules = concat(zipWith(this._countRules, range(this._countRules.length), addPriority), zipWith(this._blockRules, range(this._blockRules.length).map(n => n + this._countRules.length), addPriority));
|
170
|
+
if (rules.length === 0) {
|
147
171
|
throw new Error("No rules defined for WebACL");
|
148
172
|
}
|
149
|
-
const uniqueRuleNames = new Set(
|
150
|
-
if (uniqueRuleNames.size
|
173
|
+
const uniqueRuleNames = new Set(rules.map((rule) => rule.name));
|
174
|
+
if (uniqueRuleNames.size !== rules.length) {
|
151
175
|
throw new Error("Tried to create an Access Control List with multiple rules having the same name");
|
152
176
|
}
|
153
|
-
|
177
|
+
return new CfnWebACL(this._construct, this._name, {
|
154
178
|
defaultAction: { allow: {} },
|
155
179
|
scope: this._scope,
|
156
180
|
visibilityConfig: {
|
@@ -158,10 +182,9 @@ export class AclBuilder {
|
|
158
182
|
metricName: "WAF-Blocked",
|
159
183
|
sampledRequestsEnabled: false,
|
160
184
|
},
|
161
|
-
rules
|
185
|
+
rules,
|
162
186
|
customResponseBodies: this._customResponseBodies,
|
163
187
|
});
|
164
|
-
return acl;
|
165
188
|
}
|
166
189
|
}
|
167
190
|
const CUSTOM_KEYS_IP_AND_URI_PATH = [
|
@@ -228,8 +251,8 @@ function createThrottleStatement(limit, isHeaderRequired, isBasedOnIpAndUriPath)
|
|
228
251
|
},
|
229
252
|
};
|
230
253
|
}
|
231
|
-
function createAWSCommonRuleSet() {
|
232
|
-
return createRuleProperty("AWS-AWSManagedRulesCommonRuleSet",
|
254
|
+
function createAWSCommonRuleSet(excludedRules = []) {
|
255
|
+
return createRuleProperty("AWS-AWSManagedRulesCommonRuleSet", {
|
233
256
|
statement: {
|
234
257
|
managedRuleGroupStatement: {
|
235
258
|
vendorName: "AWS",
|
@@ -238,46 +261,48 @@ function createAWSCommonRuleSet() {
|
|
238
261
|
{ name: "NoUserAgent_HEADER" },
|
239
262
|
{ name: "SizeRestrictions_BODY" },
|
240
263
|
{ name: "GenericRFI_BODY" },
|
241
|
-
],
|
264
|
+
].concat((excludedRules ?? []).map((rule) => ({ name: rule }))),
|
242
265
|
},
|
243
266
|
},
|
244
267
|
});
|
245
268
|
}
|
246
|
-
function createAWSReputationList() {
|
247
|
-
return createRuleProperty("AWS-AWSManagedRulesAmazonIpReputationList",
|
269
|
+
function createAWSReputationList(excludedRules = []) {
|
270
|
+
return createRuleProperty("AWS-AWSManagedRulesAmazonIpReputationList", {
|
248
271
|
statement: {
|
249
272
|
managedRuleGroupStatement: {
|
250
273
|
vendorName: "AWS",
|
251
274
|
name: "AWSManagedRulesAmazonIpReputationList",
|
275
|
+
excludedRules: (excludedRules ?? []).map((rule) => ({ name: rule })),
|
252
276
|
},
|
253
277
|
},
|
254
278
|
});
|
255
279
|
}
|
256
|
-
function createAWSKnownBadInput() {
|
257
|
-
return createRuleProperty("AWS-AWSManagedRulesKnownBadInputsRuleSet",
|
280
|
+
function createAWSKnownBadInput(excludedRules = []) {
|
281
|
+
return createRuleProperty("AWS-AWSManagedRulesKnownBadInputsRuleSet", {
|
258
282
|
statement: {
|
259
283
|
managedRuleGroupStatement: {
|
260
284
|
vendorName: "AWS",
|
261
285
|
name: "AWSManagedRulesKnownBadInputsRuleSet",
|
286
|
+
excludedRules: (excludedRules ?? []).map((rule) => ({ name: rule })),
|
262
287
|
},
|
263
288
|
},
|
264
289
|
});
|
265
290
|
}
|
266
|
-
function createAWSAntiSQLInjection() {
|
267
|
-
return createRuleProperty("AWS-AWSManagedRulesSQLiRuleSet",
|
291
|
+
function createAWSAntiSQLInjection(excludedRules = []) {
|
292
|
+
return createRuleProperty("AWS-AWSManagedRulesSQLiRuleSet", {
|
268
293
|
statement: {
|
269
294
|
managedRuleGroupStatement: {
|
270
295
|
vendorName: "AWS",
|
271
296
|
name: "AWSManagedRulesSQLiRuleSet",
|
297
|
+
excludedRules: (excludedRules ?? []).map((rule) => ({ name: rule })),
|
272
298
|
},
|
273
299
|
},
|
274
300
|
});
|
275
301
|
}
|
276
|
-
function createRuleProperty(name,
|
302
|
+
function createRuleProperty(name, rule, overrideAction = true) {
|
277
303
|
return {
|
278
304
|
...{
|
279
305
|
name,
|
280
|
-
priority,
|
281
306
|
visibilityConfig: {
|
282
307
|
sampledRequestsEnabled: true,
|
283
308
|
cloudWatchMetricsEnabled: true,
|
@@ -288,4 +313,4 @@ function createRuleProperty(name, priority, rule, overrideAction = true) {
|
|
288
313
|
...(overrideAction ? { overrideAction: { none: {} } } : {}),
|
289
314
|
};
|
290
315
|
}
|
291
|
-
//# sourceMappingURL=acl-builder.
|
316
|
+
//# sourceMappingURL=acl-builder.js.map
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { DtLogger } from "../../runtime/dt-logger.
|
2
|
-
import { LambdaResponse } from "../../types/lambda-response.
|
1
|
+
import type { DtLogger } from "../../runtime/dt-logger.js";
|
2
|
+
import type { LambdaResponse } from "../../types/lambda-response.js";
|
3
3
|
export type LoggingHandler = (method: () => Promise<LambdaResponse>, logger: DtLogger) => Promise<LambdaResponse>;
|
4
4
|
export type ErrorHandler = (error: unknown, logger: DtLogger) => LambdaResponse;
|
5
5
|
/**
|
@@ -15,8 +15,8 @@ export declare class HandlerFactory {
|
|
15
15
|
private loggingHandler;
|
16
16
|
private errorHandler;
|
17
17
|
constructor();
|
18
|
-
withLoggingHandler(loggingHandler: LoggingHandler):
|
19
|
-
withErrorHandler(errorHandler: ErrorHandler):
|
18
|
+
withLoggingHandler(loggingHandler: LoggingHandler): HandlerFactory;
|
19
|
+
withErrorHandler(errorHandler: ErrorHandler): HandlerFactory;
|
20
20
|
createEventHandler(handler: (event: unknown) => Promise<LambdaResponse>, logger: DtLogger): (event: unknown) => Promise<LambdaResponse>;
|
21
21
|
}
|
22
22
|
export declare function createJsonLoggingHandler(): LoggingHandler;
|
@@ -1,6 +1,5 @@
|
|
1
|
-
import { getEnvVariableOrElse } from "../../../utils/utils.
|
2
|
-
import {
|
3
|
-
import { LambdaResponse } from "../../types/lambda-response.mjs";
|
1
|
+
import { getEnvVariableOrElse } from "../../../utils/utils.js";
|
2
|
+
import { logger } from "../../runtime/dt-logger-default.js";
|
4
3
|
const functionName = getEnvVariableOrElse("AWS_LAMBDA_FUNCTION_NAME", "test");
|
5
4
|
/**
|
6
5
|
* Factory class for creating lambda-handler functions. You can set functionality to handle logging and error-handling,
|
@@ -21,7 +20,10 @@ export class HandlerFactory {
|
|
21
20
|
return await method();
|
22
21
|
}
|
23
22
|
finally {
|
24
|
-
|
23
|
+
logger.info({
|
24
|
+
method: `${functionName}.handler`,
|
25
|
+
tookMs: Date.now() - start,
|
26
|
+
});
|
25
27
|
}
|
26
28
|
};
|
27
29
|
this.errorHandler = (error) => {
|
@@ -63,4 +65,4 @@ export function createJsonLoggingHandler() {
|
|
63
65
|
}
|
64
66
|
};
|
65
67
|
}
|
66
|
-
//# sourceMappingURL=handler-factory.
|
68
|
+
//# sourceMappingURL=handler-factory.js.map
|