Skip to content

Commit 78e1cf9

Browse files
committed
Escaper html for innkommen eventid etter alert fra CodeQL
1 parent 721d43a commit 78e1cf9

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

package-lock.json

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"@reduxjs/toolkit": "2.2.7",
4848
"csp-header": "5.2.1",
4949
"dayjs": "1.11.13",
50+
"escape-html": "^1.0.3",
5051
"fuse.js": "6.6.2",
5152
"html-react-parser": "5.1.16",
5253
"js-cookie": "3.0.5",
@@ -83,6 +84,7 @@
8384
"@storybook/test": "8.3.3",
8485
"@testing-library/jest-dom": "6.5.0",
8586
"@testing-library/react": "16.0.1",
87+
"@types/escape-html": "^1.0.4",
8688
"@types/jest": "29.5.13",
8789
"@types/js-cookie": "3.0.6",
8890
"@types/lodash.debounce": "4.0.9",

server/src/req-handlers/invalidate-paths.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { RequestHandler } from 'express';
22
import PageCacheHandler from 'cache/page-cache-handler';
33
import { logger } from 'srcCommon/logger';
4+
import escapeHtml from 'escape-html';
5+
import { escape } from 'querystring';
46

57
export const handleInvalidatePathsReq: RequestHandler = (req, res) => {
6-
const { eventid } = req.headers;
8+
const { eventid = '' } = req.headers;
79
const { paths } = req.body;
810

911
if (!Array.isArray(paths)) {
10-
const msg = `Invalid path array for event ${eventid}`;
12+
const msg = `Invalid path array for event ${escapeHtml(eventid.toString())}`;
1113
logger.error(msg);
1214
res.status(400).send(msg);
1315
return;
@@ -17,7 +19,7 @@ export const handleInvalidatePathsReq: RequestHandler = (req, res) => {
1719

1820
paths.forEach((path) => cacheHandler.delete(path));
1921

20-
const msg = `Received cache invalidation event for ${paths.length} paths - event id ${eventid}`;
22+
const msg = `Received cache invalidation event for ${paths.length} paths - event id ${escapeHtml(eventid.toString())}`;
2123
logger.info(msg);
2224

2325
res.status(200).send(msg);

0 commit comments

Comments
 (0)