Skip to content

Commit 3f7864a

Browse files
committed
remove Pragma from the default list and handle people still using it
1 parent c57deaf commit 3f7864a

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

src/owasp.js

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ class OWASP {
4747
description:
4848
"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)",
4949
},
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-
},
5550
"Referrer-Policy": {
5651
description:
5752
"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 {
153148
getHeaders(headerList) {
154149
const obj = {};
155150
for (const headerName of Object.keys(headerList)) {
156-
const defaultHeader =
157-
this.DEFAULT_OWASP_HEADERS[this.headerMap[headerName]];
158-
Object.assign(obj, { [this.headerMap[headerName]]: defaultHeader });
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 });
159184

160-
if (typeof headerList[headerName] !== "boolean") {
161-
obj[this.headerMap[headerName]].schema.default =
162-
headerList[headerName].value;
185+
if (typeof headerList[headerName] !== "boolean") {
186+
obj[this.headerMap[headerName]].schema.default =
187+
headerList[headerName].value;
188+
}
163189
}
164190
}
165191

0 commit comments

Comments
 (0)