serverless-openapi-documenter 0.0.107 → 0.0.109
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/README.md +3 -2
- package/json/owasp.json +52 -56
- package/package.json +3 -2
- package/src/definitionGenerator.js +22 -2
- package/src/logger.js +74 -0
- package/src/openAPIGenerator.js +33 -60
- package/src/owasp.js +37 -11
- package/test/json/newOWASP.json +52 -56
- package/test/unit/definitionGenerator.spec.js +201 -44
- package/test/unit/logger.spec.js +160 -0
- package/test/unit/owasp.spec.js +106 -99
package/README.md
CHANGED
|
@@ -928,7 +928,7 @@ The generator will interpret your settings for CORS and automatically add the re
|
|
|
928
928
|
|
|
929
929
|
You can make use of the [OWASP Secure Headers](https://owasp.org/www-project-secure-headers/#x-permitted-cross-domain-policies) to generate response headers. These are a selection of response headers with default values that OWASP recommends returning with your response to help secure your application.
|
|
930
930
|
|
|
931
|
-
The OWASP Secure Headers Project contains a set of recommended headers to return with recommended values, when generating the documentation, the generator will attempt to get the latest version of this document and apply the latest recommendations. If you do not allow outside connections, it will default to a version of recommendations from **
|
|
931
|
+
The OWASP Secure Headers Project contains a set of recommended headers to return with recommended values, when generating the documentation, the generator will attempt to get the latest version of this document and apply the latest recommendations. If you do not allow outside connections, it will default to a version of recommendations from **2024-09-19 21:29:28 UTC**.
|
|
932
932
|
|
|
933
933
|
Like CORS, if you have already set any of the OWASP Secure headers via `responseHeaders`, it will not overwrite them.
|
|
934
934
|
|
|
@@ -973,13 +973,14 @@ The full list of OWASP Secure Headers you can set are:
|
|
|
973
973
|
- crossOriginOpenerPolicy - Cross-Origin-Opener-Policy,
|
|
974
974
|
- crossOriginResourcePolicy - Cross-Origin-Resource-Policy,
|
|
975
975
|
- permissionsPolicy - Permissions-Policy,
|
|
976
|
-
- pragma - Pragma,
|
|
977
976
|
- referrerPolicy - Referrer-Policy,
|
|
978
977
|
- strictTransportSecurity - Strict-Transport-Security,
|
|
979
978
|
- xContentTypeOptions - X-Content-Type-Options,
|
|
980
979
|
- xFrameOptions - X-Frame-Options,
|
|
981
980
|
- xPermittedCrossDomainPolicies - X-Permitted-Cross-Domain-Policies
|
|
982
981
|
|
|
982
|
+
You should note that `Pragma` has been [deprecated by owasp](https://owasp.org/www-project-secure-headers/#pragma), this plugin will issue a warning when you are still using Pragma and might drop support.
|
|
983
|
+
|
|
983
984
|
###### Subset of OWASP Secure Headers with user defined values
|
|
984
985
|
|
|
985
986
|
If you wish to override the OWASP Secure Headers, you can write your `methodResponse` like:
|
package/json/owasp.json
CHANGED
|
@@ -1,57 +1,53 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"value": "none"
|
|
55
|
-
}
|
|
56
|
-
]
|
|
57
|
-
}
|
|
2
|
+
"last_update_utc": "2024-09-19 21:29:28",
|
|
3
|
+
"headers": [
|
|
4
|
+
{
|
|
5
|
+
"name": "Cache-Control",
|
|
6
|
+
"value": "no-store, max-age=0"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"name": "Clear-Site-Data",
|
|
10
|
+
"value": "\"cache\",\"cookies\",\"storage\""
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "Content-Security-Policy",
|
|
14
|
+
"value": "default-src 'self'; form-action 'self'; object-src 'none'; frame-ancestors 'none'; upgrade-insecure-requests; block-all-mixed-content"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "Cross-Origin-Embedder-Policy",
|
|
18
|
+
"value": "require-corp"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "Cross-Origin-Opener-Policy",
|
|
22
|
+
"value": "same-origin"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "Cross-Origin-Resource-Policy",
|
|
26
|
+
"value": "same-origin"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "Permissions-Policy",
|
|
30
|
+
"value": "accelerometer=(), autoplay=(), camera=(), cross-origin-isolated=(), display-capture=(), encrypted-media=(), fullscreen=(), geolocation=(), gyroscope=(), keyboard-map=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(self), usb=(), web-share=(), xr-spatial-tracking=(), clipboard-read=(), clipboard-write=(), gamepad=(), hid=(), idle-detection=(), interest-cohort=(), serial=(), unload=()"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "Referrer-Policy",
|
|
34
|
+
"value": "no-referrer"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "Strict-Transport-Security",
|
|
38
|
+
"value": "max-age=31536000; includeSubDomains"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "X-Content-Type-Options",
|
|
42
|
+
"value": "nosniff"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "X-Frame-Options",
|
|
46
|
+
"value": "deny"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "X-Permitted-Cross-Domain-Policies",
|
|
50
|
+
"value": "none"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "serverless-openapi-documenter",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.109",
|
|
4
4
|
"description": "Generate OpenAPI v3 documentation and Postman Collections from your Serverless Config",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"Api Gateway",
|
|
28
28
|
"APIGateway",
|
|
29
29
|
"AWSAPIGateway",
|
|
30
|
-
"Serverless OpenAPI"
|
|
30
|
+
"Serverless OpenAPI",
|
|
31
|
+
"serverless openapi"
|
|
31
32
|
],
|
|
32
33
|
"scripts": {
|
|
33
34
|
"test": "mocha --config './test/.mocharc.js'"
|
|
@@ -15,7 +15,9 @@ const SchemaHandler = require("./schemaHandler");
|
|
|
15
15
|
const oWASP = require("./owasp");
|
|
16
16
|
|
|
17
17
|
class DefinitionGenerator {
|
|
18
|
-
constructor(serverless,
|
|
18
|
+
constructor(serverless, logger) {
|
|
19
|
+
this.logger = logger;
|
|
20
|
+
|
|
19
21
|
this.version =
|
|
20
22
|
serverless?.processedInput?.options?.openApiVersion || "3.0.0";
|
|
21
23
|
|
|
@@ -70,6 +72,12 @@ class DefinitionGenerator {
|
|
|
70
72
|
};
|
|
71
73
|
|
|
72
74
|
try {
|
|
75
|
+
this.logger.verbose(
|
|
76
|
+
`Trying to resolve Redocly rules from: ${path.resolve(
|
|
77
|
+
"options",
|
|
78
|
+
"redocly.json"
|
|
79
|
+
)}`
|
|
80
|
+
);
|
|
73
81
|
this.REDOCLY_RULES = require(path.resolve("options", "redocly.json"));
|
|
74
82
|
} catch (err) {
|
|
75
83
|
this.REDOCLY_RULES = {
|
|
@@ -83,6 +91,12 @@ class DefinitionGenerator {
|
|
|
83
91
|
}
|
|
84
92
|
|
|
85
93
|
try {
|
|
94
|
+
this.logger.verbose(
|
|
95
|
+
`Trying to resolve Ref-Parser options from: ${path.resolve(
|
|
96
|
+
"options",
|
|
97
|
+
"ref-parser.js"
|
|
98
|
+
)}`
|
|
99
|
+
);
|
|
86
100
|
this.refParserOptions = require(path.resolve("options", "ref-parser.js"));
|
|
87
101
|
} catch (err) {
|
|
88
102
|
this.refParserOptions = {};
|
|
@@ -539,6 +553,12 @@ class DefinitionGenerator {
|
|
|
539
553
|
throw err;
|
|
540
554
|
});
|
|
541
555
|
} else {
|
|
556
|
+
if (Object.keys(response.owasp).includes("pragma")) {
|
|
557
|
+
this.logger.warn(
|
|
558
|
+
"Pragma has been deprecated by owasp (https://owasp.org/www-project-secure-headers/#pragma) and support for defaults will be dropped by this plugin."
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
|
|
542
562
|
owaspHeaders = await this.createResponseHeaders(
|
|
543
563
|
oWASP.getHeaders(response.owasp)
|
|
544
564
|
).catch((err) => {
|
|
@@ -589,7 +609,7 @@ class DefinitionGenerator {
|
|
|
589
609
|
).catch((err) => {
|
|
590
610
|
throw err;
|
|
591
611
|
});
|
|
592
|
-
} else if (this.currentEvent
|
|
612
|
+
} else if (this.currentEvent?.cors) {
|
|
593
613
|
const newHeaders = {};
|
|
594
614
|
for (const key of Object.keys(this.DEFAULT_CORS_HEADERS)) {
|
|
595
615
|
if (
|
package/src/logger.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class Logger {
|
|
4
|
+
constructor(serverless, log) {
|
|
5
|
+
this.serverless = serverless;
|
|
6
|
+
this.logOutput = log;
|
|
7
|
+
|
|
8
|
+
this.logTypes = {
|
|
9
|
+
NOTICE: "notice",
|
|
10
|
+
DEBUG: "debug",
|
|
11
|
+
ERROR: "error",
|
|
12
|
+
WARNING: "warning",
|
|
13
|
+
INFO: "info",
|
|
14
|
+
VERBOSE: "verbose",
|
|
15
|
+
SUCCESS: "success",
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
this.defaultLog = this.logTypes.NOTICE;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
log(str, type = this.defaultLog) {
|
|
22
|
+
switch (this.serverless.version[0]) {
|
|
23
|
+
case "2":
|
|
24
|
+
let colouredString = str;
|
|
25
|
+
if (type === "error") {
|
|
26
|
+
colouredString = chalk.bold.red(`✖ ${str}`);
|
|
27
|
+
} else if (type === "success") {
|
|
28
|
+
colouredString = chalk.bold.green(`✓ ${str}`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
this.serverless.cli.log(colouredString);
|
|
32
|
+
break;
|
|
33
|
+
|
|
34
|
+
case "4":
|
|
35
|
+
case "3":
|
|
36
|
+
this.logOutput[type](str);
|
|
37
|
+
break;
|
|
38
|
+
|
|
39
|
+
default:
|
|
40
|
+
process.stdout.write(str.join(" "));
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
debug(str) {
|
|
46
|
+
this.log(str, this.logTypes.DEBUG);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
error(str) {
|
|
50
|
+
this.log(str, this.logTypes.ERROR);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
info(str) {
|
|
54
|
+
this.log(str, this.logTypes.INFO);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
notice(str) {
|
|
58
|
+
this.log(str, this.logTypes.NOTICE);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
success(str) {
|
|
62
|
+
this.log(str, this.logTypes.SUCCESS);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
verbose(str) {
|
|
66
|
+
this.log(str, this.logTypes.VERBOSE);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
warning(str) {
|
|
70
|
+
this.log(str, this.logTypes.WARNING);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
module.exports = Logger;
|
package/src/openAPIGenerator.js
CHANGED
|
@@ -5,6 +5,7 @@ const yaml = require("js-yaml");
|
|
|
5
5
|
const chalk = require("chalk");
|
|
6
6
|
|
|
7
7
|
const DefinitionGenerator = require("./definitionGenerator");
|
|
8
|
+
const Logger = require("./logger");
|
|
8
9
|
const PostmanGenerator = require("openapi-to-postmanv2");
|
|
9
10
|
|
|
10
11
|
class OpenAPIGenerator {
|
|
@@ -12,18 +13,7 @@ class OpenAPIGenerator {
|
|
|
12
13
|
this.logOutput = log;
|
|
13
14
|
this.serverless = serverless;
|
|
14
15
|
this.options = options;
|
|
15
|
-
|
|
16
|
-
this.logTypes = {
|
|
17
|
-
NOTICE: "notice",
|
|
18
|
-
DEBUG: "debug",
|
|
19
|
-
ERROR: "error",
|
|
20
|
-
WARNING: "warning",
|
|
21
|
-
INFO: "info",
|
|
22
|
-
VERBOSE: "verbose",
|
|
23
|
-
SUCCESS: "success",
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
this.defaultLog = this.logTypes.NOTICE;
|
|
16
|
+
this.logger = new Logger(this.serverless, this.logOutput);
|
|
27
17
|
|
|
28
18
|
this.commands = {
|
|
29
19
|
openapi: {
|
|
@@ -145,7 +135,9 @@ class OpenAPIGenerator {
|
|
|
145
135
|
}
|
|
146
136
|
|
|
147
137
|
async generate() {
|
|
148
|
-
this.
|
|
138
|
+
this.logger.notice(
|
|
139
|
+
chalk.bold.underline("OpenAPI v3 Description Generation")
|
|
140
|
+
);
|
|
149
141
|
this.processCliInput();
|
|
150
142
|
|
|
151
143
|
const validOpenAPI = await this.generationAndValidation().catch((err) => {
|
|
@@ -168,37 +160,31 @@ class OpenAPIGenerator {
|
|
|
168
160
|
}
|
|
169
161
|
try {
|
|
170
162
|
fs.writeFileSync(this.config.file, output);
|
|
171
|
-
this.
|
|
172
|
-
"OpenAPI v3 Description Successfully Written",
|
|
173
|
-
this.logTypes.SUCCESS
|
|
174
|
-
);
|
|
163
|
+
this.logger.success("OpenAPI v3 Description Successfully Written");
|
|
175
164
|
} catch (err) {
|
|
176
|
-
this.
|
|
177
|
-
`ERROR: An error was thrown whilst writing the OpenAPI Description
|
|
178
|
-
this.logTypes.ERROR
|
|
165
|
+
this.logger.error(
|
|
166
|
+
`ERROR: An error was thrown whilst writing the OpenAPI Description`
|
|
179
167
|
);
|
|
180
168
|
throw new this.serverless.classes.Error(err);
|
|
181
169
|
}
|
|
182
170
|
}
|
|
183
171
|
|
|
184
172
|
async generationAndValidation() {
|
|
185
|
-
const generator = new DefinitionGenerator(this.serverless);
|
|
173
|
+
const generator = new DefinitionGenerator(this.serverless, this.logger);
|
|
186
174
|
|
|
187
|
-
this.
|
|
175
|
+
this.logger.notice(`Generating OpenAPI Description`);
|
|
188
176
|
await generator.parse().catch((err) => {
|
|
189
|
-
this.
|
|
190
|
-
`ERROR: An error was thrown generating the OpenAPI v3 Description
|
|
191
|
-
this.logTypes.ERROR
|
|
177
|
+
this.logger.error(
|
|
178
|
+
`ERROR: An error was thrown generating the OpenAPI v3 Description`
|
|
192
179
|
);
|
|
193
180
|
throw new this.serverless.classes.Error(err);
|
|
194
181
|
});
|
|
195
182
|
|
|
196
|
-
this.
|
|
183
|
+
this.logger.notice(`Validating generated OpenAPI Description`);
|
|
197
184
|
|
|
198
185
|
const validationResults = await generator.validate().catch((err) => {
|
|
199
|
-
this.
|
|
200
|
-
`ERROR: An error was thrown validating the OpenAPI v3 Description
|
|
201
|
-
this.logTypes.ERROR
|
|
186
|
+
this.logger.error(
|
|
187
|
+
`ERROR: An error was thrown validating the OpenAPI v3 Description`
|
|
202
188
|
);
|
|
203
189
|
|
|
204
190
|
throw new this.serverless.classes.Error(err);
|
|
@@ -219,10 +205,7 @@ class OpenAPIGenerator {
|
|
|
219
205
|
if (shouldThrow) throw new this.serverless.classes.Error(message);
|
|
220
206
|
}
|
|
221
207
|
|
|
222
|
-
this.
|
|
223
|
-
"OpenAPI v3 Description Successfully Generated",
|
|
224
|
-
this.logTypes.SUCCESS
|
|
225
|
-
);
|
|
208
|
+
this.logger.success("OpenAPI v3 Description Successfully Generated");
|
|
226
209
|
|
|
227
210
|
return generator.openAPI;
|
|
228
211
|
}
|
|
@@ -230,31 +213,29 @@ class OpenAPIGenerator {
|
|
|
230
213
|
createPostman(openAPI) {
|
|
231
214
|
const postmanGeneration = (err, result) => {
|
|
232
215
|
if (err) {
|
|
233
|
-
this.
|
|
234
|
-
`ERROR: An error was thrown when generating the postman collection
|
|
235
|
-
this.logTypes.ERROR
|
|
216
|
+
this.logger.error(
|
|
217
|
+
`ERROR: An error was thrown when generating the postman collection`
|
|
236
218
|
);
|
|
237
219
|
throw new this.serverless.classes.Error(err);
|
|
238
220
|
}
|
|
239
221
|
|
|
240
|
-
this.
|
|
241
|
-
"postman collection v2 Documentation Successfully Generated"
|
|
242
|
-
this.logTypes.SUCCESS
|
|
222
|
+
this.logger.success(
|
|
223
|
+
"postman collection v2 Documentation Successfully Generated"
|
|
243
224
|
);
|
|
225
|
+
|
|
244
226
|
try {
|
|
245
227
|
fs.writeFileSync(
|
|
246
228
|
this.config.postmanCollection,
|
|
247
229
|
JSON.stringify(result.output[0].data)
|
|
248
230
|
);
|
|
249
|
-
this.
|
|
250
|
-
"postman collection v2 Documentation Successfully Written"
|
|
251
|
-
this.logTypes.SUCCESS
|
|
231
|
+
this.logger.success(
|
|
232
|
+
"postman collection v2 Documentation Successfully Written"
|
|
252
233
|
);
|
|
253
234
|
} catch (err) {
|
|
254
|
-
this.
|
|
255
|
-
`ERROR: An error was thrown whilst writing the postman collection
|
|
256
|
-
this.logTypes.ERROR
|
|
235
|
+
this.logger.error(
|
|
236
|
+
`ERROR: An error was thrown whilst writing the postman collection`
|
|
257
237
|
);
|
|
238
|
+
|
|
258
239
|
throw new this.serverless.classes.Error(err);
|
|
259
240
|
}
|
|
260
241
|
};
|
|
@@ -295,7 +276,7 @@ class OpenAPIGenerator {
|
|
|
295
276
|
this.serverless.processedInput.options.output ||
|
|
296
277
|
(config.format === "yaml" ? "openapi.yml" : "openapi.json");
|
|
297
278
|
|
|
298
|
-
this.
|
|
279
|
+
this.logger.notice(
|
|
299
280
|
`${chalk.bold.green("[OPTIONS]")}
|
|
300
281
|
openApiVersion: "${chalk.bold.green(String(config.openApiVersion))}"
|
|
301
282
|
format: "${chalk.bold.green(config.format)}"
|
|
@@ -314,26 +295,18 @@ class OpenAPIGenerator {
|
|
|
314
295
|
|
|
315
296
|
validationErrorDetails(validationErrors) {
|
|
316
297
|
if (validationErrors.length) {
|
|
317
|
-
this.
|
|
298
|
+
this.logger.error(
|
|
318
299
|
`${chalk.bold.yellow(
|
|
319
300
|
"[VALIDATION]"
|
|
320
|
-
)} Validation errors found in OpenAPI Description: \n
|
|
321
|
-
this.logTypes.ERROR
|
|
301
|
+
)} Validation errors found in OpenAPI Description: \n`
|
|
322
302
|
);
|
|
323
303
|
|
|
324
304
|
for (const error of validationErrors) {
|
|
325
|
-
this.
|
|
326
|
-
|
|
327
|
-
this.logTypes.ERROR
|
|
328
|
-
);
|
|
329
|
-
this.log(
|
|
330
|
-
`${chalk.bold.yellow("Message:")} ${error.message}`,
|
|
331
|
-
this.logTypes.ERROR
|
|
332
|
-
);
|
|
305
|
+
this.logger.error(`${chalk.bold.red("Severity:")} ${error.severity}`);
|
|
306
|
+
this.logger.error(`${chalk.bold.yellow("Message:")} ${error.message}`);
|
|
333
307
|
for (const location of error.location) {
|
|
334
|
-
this.
|
|
335
|
-
`${chalk.bold.yellow("found at location:")} ${location.pointer}
|
|
336
|
-
this.logTypes.ERROR
|
|
308
|
+
this.logger.error(
|
|
309
|
+
`${chalk.bold.yellow("found at location:")} ${location.pointer}`
|
|
337
310
|
);
|
|
338
311
|
}
|
|
339
312
|
}
|
package/src/owasp.js
CHANGED
|
@@ -47,11 +47,6 @@ class OWASP {
|
|
|
47
47
|
description:
|
|
48
48
|
"The HTTP Permissions-Policy header provides a mechanism to allow and deny the use of browser features in a document or within any [<iframe>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe) elements in the document. - [MDN Link](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Permissions-Policy)",
|
|
49
49
|
},
|
|
50
|
-
Pragma: {
|
|
51
|
-
description:
|
|
52
|
-
"The Pragma HTTP/1.0 general header is an implementation-specific header that may have various effects along the request-response chain. This header serves for backwards compatibility with the HTTP/1.0 caches that do not have a [Cache-Control](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control) HTTP/1.1 header. - [MDN Link](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Pragma)",
|
|
53
|
-
deprecated: true,
|
|
54
|
-
},
|
|
55
50
|
"Referrer-Policy": {
|
|
56
51
|
description:
|
|
57
52
|
"The Referrer-Policy [HTTP header](https://developer.mozilla.org/en-US/docs/Glossary/HTTP_header) controls how much [referrer information](https://developer.mozilla.org/en-US/docs/Web/Security/Referer_header:_privacy_and_security_concerns) (sent with the [Referer](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer) header) should be included with requests. Aside from the HTTP header, you can [set this policy in HTML](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy#integration_with_html). - [MDN Link](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy)",
|
|
@@ -153,13 +148,44 @@ class OWASP {
|
|
|
153
148
|
getHeaders(headerList) {
|
|
154
149
|
const obj = {};
|
|
155
150
|
for (const headerName of Object.keys(headerList)) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
151
|
+
if (headerName === "pragma") {
|
|
152
|
+
const pragma = {
|
|
153
|
+
Pragma: {
|
|
154
|
+
description:
|
|
155
|
+
"The Pragma HTTP/1.0 general header is an implementation-specific header that may have various effects along the request-response chain. This header serves for backwards compatibility with the HTTP/1.0 caches that do not have a [Cache-Control](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control) HTTP/1.1 header. - [MDN Link](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Pragma)",
|
|
156
|
+
deprecated: true,
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
if (typeof headerList["pragma"] !== "boolean") {
|
|
161
|
+
Object.assign(pragma["Pragma"], {
|
|
162
|
+
schema: {
|
|
163
|
+
type: "string",
|
|
164
|
+
default: headerList["pragma"].value,
|
|
165
|
+
example: headerList["pragma"].value,
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
} else {
|
|
169
|
+
Object.assign(pragma["Pragma"], {
|
|
170
|
+
schema: {
|
|
171
|
+
default: "no-cache",
|
|
172
|
+
type: "string",
|
|
173
|
+
example: "no-cache",
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
Object.assign(obj, pragma);
|
|
179
|
+
} else {
|
|
180
|
+
const defaultHeader =
|
|
181
|
+
this.DEFAULT_OWASP_HEADERS[this.headerMap[headerName]];
|
|
182
|
+
|
|
183
|
+
Object.assign(obj, { [this.headerMap[headerName]]: defaultHeader });
|
|
159
184
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
185
|
+
if (typeof headerList[headerName] !== "boolean") {
|
|
186
|
+
obj[this.headerMap[headerName]].schema.default =
|
|
187
|
+
headerList[headerName].value;
|
|
188
|
+
}
|
|
163
189
|
}
|
|
164
190
|
}
|
|
165
191
|
|
package/test/json/newOWASP.json
CHANGED
|
@@ -1,57 +1,53 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"value": "none"
|
|
55
|
-
}
|
|
56
|
-
]
|
|
57
|
-
}
|
|
2
|
+
"last_update_utc": "2024-09-19 21:29:28",
|
|
3
|
+
"headers": [
|
|
4
|
+
{
|
|
5
|
+
"name": "Cache-Control",
|
|
6
|
+
"value": "no-store, max-age=0"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"name": "Clear-Site-Data",
|
|
10
|
+
"value": "\"cache\",\"cookies\",\"storage\""
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"name": "Content-Security-Policy",
|
|
14
|
+
"value": "default-src 'self'; form-action 'self'; object-src 'none'; frame-ancestors 'none'; upgrade-insecure-requests; block-all-mixed-content"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"name": "Cross-Origin-Embedder-Policy",
|
|
18
|
+
"value": "require-corp"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"name": "Cross-Origin-Opener-Policy",
|
|
22
|
+
"value": "same-origin"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "Cross-Origin-Resource-Policy",
|
|
26
|
+
"value": "same-origin"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"name": "Permissions-Policy",
|
|
30
|
+
"value": "accelerometer=(), autoplay=(), camera=(), cross-origin-isolated=(), display-capture=(), encrypted-media=(), fullscreen=(), geolocation=(), gyroscope=(), keyboard-map=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), publickey-credentials-get=(), screen-wake-lock=(), sync-xhr=(self), usb=(), web-share=(), xr-spatial-tracking=(), clipboard-read=(), clipboard-write=(), gamepad=(), hid=(), idle-detection=(), interest-cohort=(), serial=(), unload=()"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "Referrer-Policy",
|
|
34
|
+
"value": "no-referrer"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "Strict-Transport-Security",
|
|
38
|
+
"value": "max-age=31536000; includeSubDomains"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"name": "X-Content-Type-Options",
|
|
42
|
+
"value": "nosniff"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "X-Frame-Options",
|
|
46
|
+
"value": "deny"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"name": "X-Permitted-Cross-Domain-Policies",
|
|
50
|
+
"value": "none"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|