Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
if (!willBeTreatedAsHTML(response)) {
let headersToValidate = unneededHeaders;
if (exceptionMediaTypes.includes(response.mediaType)) {
headersToValidate = mergeIgnoreIncludeArrays(headersToValidate, exceptionHeaders, []);
}
const headers = includedHeaders(response.headers, headersToValidate);
const numberOfHeaders = headers.length;
if (numberOfHeaders > 0) {
let message: string;
if (numberOfHeaders === 1) {
message = getMessage('unneededHeader', context.language, prettyPrintArray(headers));
} else {
message = getMessage('unneededHeaders', context.language, prettyPrintArray(headers));
}
context.report(resource, message, { element, severity: Severity.warning });
}
}
};
resource,
message,
{
codeLanguage,
codeSnippet: `Server: ${serverHeaderValue}`,
severity: Severity.warning
});
}
if (numberOfHeaders > 0) {
let message: string;
if (numberOfHeaders === 1) {
message = getMessage('disallowedHeader', context.language, prettyPrintArray(headers));
} else {
message = getMessage('disallowedHeaders', context.language, prettyPrintArray(headers));
}
const codeSnippet = headers.reduce((total, header) => {
return `${total}${total ? '\n' : ''}${header}: ${normalizeHeaderValue(response.headers, header)}`;
}, '');
context.report(
resource,
message,
{
codeLanguage, codeSnippet,
severity: Severity.warning
});
}
};