@digitraffic/common 2024.8.13-1 → 2024.8.16-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/aws/infra/acl-builder.d.mts +4 -1
- package/dist/aws/infra/acl-builder.mjs +13 -10
- package/dist/aws/infra/stack/monitoredfunction.mjs +3 -3
- package/dist/aws/infra/stack/rest_apis.mjs +2 -2
- package/dist/aws/infra/stack/stack-checking-aspect.mjs +2 -2
- package/dist/aws/runtime/dt-logger.d.mts +1 -1
- package/dist/aws/runtime/dt-logger.mjs +4 -6
- package/package.json +5 -5
@@ -1,6 +1,9 @@
|
|
1
1
|
import { CfnWebACL } from "aws-cdk-lib/aws-wafv2";
|
2
2
|
import type { Construct } from "constructs";
|
3
3
|
export type AWSManagedWafRule = "CommonRuleSet" | "AmazonIpReputationList" | "KnownBadInputsRuleSet" | "SQLiRuleSet";
|
4
|
+
export type ExcludedAWSRules = {
|
5
|
+
[key in AWSManagedWafRule]?: string[];
|
6
|
+
};
|
4
7
|
/**
|
5
8
|
* Builder class for building CfnWebACL.
|
6
9
|
*
|
@@ -16,7 +19,7 @@ export declare class AclBuilder {
|
|
16
19
|
_customResponseBodies: Record<string, CfnWebACL.CustomResponseBodyProperty>;
|
17
20
|
constructor(construct: Construct, name?: string);
|
18
21
|
isRuleDefined(rules: AWSManagedWafRule[] | "all", rule: AWSManagedWafRule): boolean;
|
19
|
-
withAWSManagedRules(rules?: AWSManagedWafRule[] | "all"): AclBuilder;
|
22
|
+
withAWSManagedRules(rules?: AWSManagedWafRule[] | "all", excludedRules?: ExcludedAWSRules): AclBuilder;
|
20
23
|
withIpRestrictionRule(addresses: string[]): AclBuilder;
|
21
24
|
withThrottleRule(name: string, priority: number, limit: number, customResponseBodyKey: string, isHeaderRequired: boolean, isBasedOnIpAndUriPath: boolean): AclBuilder;
|
22
25
|
withCustomResponseBody(key: string, customResponseBody: CfnWebACL.CustomResponseBodyProperty): this;
|
@@ -20,18 +20,18 @@ export class AclBuilder {
|
|
20
20
|
isRuleDefined(rules, rule) {
|
21
21
|
return rules === "all" || rules.includes(rule);
|
22
22
|
}
|
23
|
-
withAWSManagedRules(rules = "all") {
|
23
|
+
withAWSManagedRules(rules = "all", excludedRules = {}) {
|
24
24
|
if (this.isRuleDefined(rules, "CommonRuleSet")) {
|
25
|
-
this._rules.push(createAWSCommonRuleSet());
|
25
|
+
this._rules.push(createAWSCommonRuleSet(excludedRules?.CommonRuleSet));
|
26
26
|
}
|
27
27
|
if (this.isRuleDefined(rules, "AmazonIpReputationList")) {
|
28
|
-
this._rules.push(createAWSReputationList());
|
28
|
+
this._rules.push(createAWSReputationList(excludedRules?.AmazonIpReputationList));
|
29
29
|
}
|
30
30
|
if (this.isRuleDefined(rules, "KnownBadInputsRuleSet")) {
|
31
|
-
this._rules.push(createAWSKnownBadInput());
|
31
|
+
this._rules.push(createAWSKnownBadInput(excludedRules?.KnownBadInputsRuleSet));
|
32
32
|
}
|
33
33
|
if (this.isRuleDefined(rules, "SQLiRuleSet")) {
|
34
|
-
this._rules.push(createAWSAntiSQLInjection());
|
34
|
+
this._rules.push(createAWSAntiSQLInjection(excludedRules?.SQLiRuleSet));
|
35
35
|
}
|
36
36
|
return this;
|
37
37
|
}
|
@@ -228,7 +228,7 @@ function createThrottleStatement(limit, isHeaderRequired, isBasedOnIpAndUriPath)
|
|
228
228
|
},
|
229
229
|
};
|
230
230
|
}
|
231
|
-
function createAWSCommonRuleSet() {
|
231
|
+
function createAWSCommonRuleSet(excludedRules = []) {
|
232
232
|
return createRuleProperty("AWS-AWSManagedRulesCommonRuleSet", 70, {
|
233
233
|
statement: {
|
234
234
|
managedRuleGroupStatement: {
|
@@ -238,37 +238,40 @@ function createAWSCommonRuleSet() {
|
|
238
238
|
{ name: "NoUserAgent_HEADER" },
|
239
239
|
{ name: "SizeRestrictions_BODY" },
|
240
240
|
{ name: "GenericRFI_BODY" },
|
241
|
-
],
|
241
|
+
].concat((excludedRules ?? []).map(rule => ({ name: rule }))),
|
242
242
|
},
|
243
243
|
},
|
244
244
|
});
|
245
245
|
}
|
246
|
-
function createAWSReputationList() {
|
246
|
+
function createAWSReputationList(excludedRules = []) {
|
247
247
|
return createRuleProperty("AWS-AWSManagedRulesAmazonIpReputationList", 80, {
|
248
248
|
statement: {
|
249
249
|
managedRuleGroupStatement: {
|
250
250
|
vendorName: "AWS",
|
251
251
|
name: "AWSManagedRulesAmazonIpReputationList",
|
252
|
+
excludedRules: (excludedRules ?? []).map(rule => ({ name: rule }))
|
252
253
|
},
|
253
254
|
},
|
254
255
|
});
|
255
256
|
}
|
256
|
-
function createAWSKnownBadInput() {
|
257
|
+
function createAWSKnownBadInput(excludedRules = []) {
|
257
258
|
return createRuleProperty("AWS-AWSManagedRulesKnownBadInputsRuleSet", 90, {
|
258
259
|
statement: {
|
259
260
|
managedRuleGroupStatement: {
|
260
261
|
vendorName: "AWS",
|
261
262
|
name: "AWSManagedRulesKnownBadInputsRuleSet",
|
263
|
+
excludedRules: (excludedRules ?? []).map(rule => ({ name: rule }))
|
262
264
|
},
|
263
265
|
},
|
264
266
|
});
|
265
267
|
}
|
266
|
-
function createAWSAntiSQLInjection() {
|
268
|
+
function createAWSAntiSQLInjection(excludedRules = []) {
|
267
269
|
return createRuleProperty("AWS-AWSManagedRulesSQLiRuleSet", 100, {
|
268
270
|
statement: {
|
269
271
|
managedRuleGroupStatement: {
|
270
272
|
vendorName: "AWS",
|
271
273
|
name: "AWSManagedRulesSQLiRuleSet",
|
274
|
+
excludedRules: (excludedRules ?? []).map(rule => ({ name: rule }))
|
272
275
|
},
|
273
276
|
},
|
274
277
|
});
|
@@ -5,7 +5,7 @@ import { ComparisonOperator, Metric } from "aws-cdk-lib/aws-cloudwatch";
|
|
5
5
|
import { DigitrafficStack } from "./stack.mjs";
|
6
6
|
import { databaseFunctionProps, } from "./lambda-configs.mjs";
|
7
7
|
import { TrafficType } from "../../../types/traffictype.mjs";
|
8
|
-
import
|
8
|
+
import { chain } from "lodash-es";
|
9
9
|
/**
|
10
10
|
* Creates a Lambda function that monitors default CloudWatch Lambda metrics with CloudWatch Alarms.
|
11
11
|
*/
|
@@ -54,7 +54,7 @@ export class MonitoredFunction extends Function {
|
|
54
54
|
*/
|
55
55
|
static createV2(stack, name, environment, functionParameters) {
|
56
56
|
const functionName = functionParameters?.functionName ??
|
57
|
-
`${stack.configuration.shortName}-${
|
57
|
+
`${stack.configuration.shortName}-${chain(name)
|
58
58
|
.camelCase()
|
59
59
|
.startCase()
|
60
60
|
.replace(/\s/g, "")
|
@@ -140,7 +140,7 @@ export class MonitoredDBFunction {
|
|
140
140
|
*/
|
141
141
|
static create(stack, name, environment, functionParameters) {
|
142
142
|
const functionName = functionParameters?.functionName ??
|
143
|
-
`${stack.configuration.shortName}-${
|
143
|
+
`${stack.configuration.shortName}-${chain(name)
|
144
144
|
.camelCase()
|
145
145
|
.startCase()
|
146
146
|
.replace(/\s/g, "")
|
@@ -6,7 +6,7 @@ import { MediaType } from "../../types/mediatypes.mjs";
|
|
6
6
|
import { DocumentationPart } from "../documentation.mjs";
|
7
7
|
import { createDefaultUsagePlan, createUsagePlan } from "../usage-plans.mjs";
|
8
8
|
import { DigitrafficStack } from "./stack.mjs";
|
9
|
-
import
|
9
|
+
import { set } from "lodash-es";
|
10
10
|
export class DigitrafficRestApi extends RestApi {
|
11
11
|
apiKeyIds;
|
12
12
|
enableDocumentation;
|
@@ -59,7 +59,7 @@ export class DigitrafficRestApi extends RestApi {
|
|
59
59
|
}));
|
60
60
|
}
|
61
61
|
getModelWithReference(model) {
|
62
|
-
return
|
62
|
+
return set(model, "modelReference", getModelReference(model.modelId, this.restApiId));
|
63
63
|
}
|
64
64
|
addDocumentationPart(resource, parameterName, resourceName, type, properties) {
|
65
65
|
const location = {
|
@@ -6,7 +6,7 @@ import { CfnMethod, CfnResource } from "aws-cdk-lib/aws-apigateway";
|
|
6
6
|
import { CfnQueue } from "aws-cdk-lib/aws-sqs";
|
7
7
|
import { LogRetention } from "aws-cdk-lib/aws-logs";
|
8
8
|
import { kebabCase } from "change-case";
|
9
|
-
import
|
9
|
+
import { snakeCase } from "lodash-es";
|
10
10
|
const MAX_CONCURRENCY_LIMIT = 100;
|
11
11
|
const NODE_RUNTIMES = [Runtime.NODEJS_20_X.name, Runtime.NODEJS_18_X.name];
|
12
12
|
var ResourceType;
|
@@ -124,7 +124,7 @@ export class StackCheckingAspect {
|
|
124
124
|
return kebabCase(path) === path;
|
125
125
|
}
|
126
126
|
static isValidQueryString(name) {
|
127
|
-
return
|
127
|
+
return snakeCase(name) === name;
|
128
128
|
}
|
129
129
|
checkResourceCasing(node) {
|
130
130
|
if (node instanceof CfnResource) {
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
import _ from "lodash";
|
1
|
+
import { mapKeys, lowerFirst } from "lodash-es";
|
3
2
|
/**
|
4
3
|
* Helper class for json-logging.
|
5
4
|
*
|
@@ -19,9 +18,8 @@ export class DtLogger {
|
|
19
18
|
* @param {LoggerConfiguration?} [config] - Accepts configuration options @see {@link LoggerConfiguration}
|
20
19
|
*/
|
21
20
|
constructor(config) {
|
22
|
-
this.lambdaName =
|
23
|
-
|
24
|
-
this.runtime = config?.runTime ?? process.env['AWS_EXECUTION_ENV'];
|
21
|
+
this.lambdaName = config?.lambdaName ?? process.env["AWS_LAMBDA_FUNCTION_NAME"];
|
22
|
+
this.runtime = config?.runTime ?? process.env["AWS_EXECUTION_ENV"];
|
25
23
|
this.writeStream = config?.writeStream ?? process.stdout;
|
26
24
|
}
|
27
25
|
/**
|
@@ -99,6 +97,6 @@ export class DtLogger {
|
|
99
97
|
}
|
100
98
|
}
|
101
99
|
function removePrefix(prefix, loggable) {
|
102
|
-
return
|
100
|
+
return mapKeys(loggable, (_index, key) => key.startsWith(prefix) ? lowerFirst(key.replace(prefix, "")) : key);
|
103
101
|
}
|
104
102
|
//# sourceMappingURL=dt-logger.mjs.map
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@digitraffic/common",
|
3
|
-
"version": "2024.8.
|
3
|
+
"version": "2024.8.16-1",
|
4
4
|
"description": "",
|
5
5
|
"type": "module",
|
6
6
|
"repository": {
|
@@ -117,7 +117,7 @@
|
|
117
117
|
"etag": "^1.8.1",
|
118
118
|
"geojson-validation": "^1.0.2",
|
119
119
|
"ky": "^1.5.0",
|
120
|
-
"lodash": "^4.17.21",
|
120
|
+
"lodash-es": "^4.17.21",
|
121
121
|
"node-ttl": "^0.2.0",
|
122
122
|
"pg-native": "^3.1.0",
|
123
123
|
"pg-promise": "^11.9.1"
|
@@ -136,7 +136,7 @@
|
|
136
136
|
"etag": "^1.8.1",
|
137
137
|
"geojson-validation": "^1.0.2",
|
138
138
|
"ky": "^1.5.0",
|
139
|
-
"lodash": "^4.17.21",
|
139
|
+
"lodash-es": "^4.17.21",
|
140
140
|
"node-ttl": "^0.2.0",
|
141
141
|
"pg-promise": "^11.9.1",
|
142
142
|
"@jest/globals": "^29.7.0",
|
@@ -151,7 +151,7 @@
|
|
151
151
|
"@types/geojson": "^7946.0.14",
|
152
152
|
"@types/geojson-validation": "^1.0.3",
|
153
153
|
"@types/jest": "^29.5.12",
|
154
|
-
"@types/lodash": "^4.17.7",
|
154
|
+
"@types/lodash-es": "^4.17.7",
|
155
155
|
"@types/madge": "^5.0.3",
|
156
156
|
"@types/node": "^20.14.9",
|
157
157
|
"@typescript-eslint/eslint-plugin": "^7.14.1",
|
@@ -162,7 +162,7 @@
|
|
162
162
|
"eslint-plugin-deprecation": "^3.0.0",
|
163
163
|
"jest": "^29.7.0",
|
164
164
|
"jest-junit": "^16.0.0",
|
165
|
-
"madge": "^
|
165
|
+
"madge": "^8.0.0",
|
166
166
|
"prettier": "^3.3.3",
|
167
167
|
"rimraf": "^6.0.1",
|
168
168
|
"ts-jest": "^29.2.4",
|