-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content Security Policy #89
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Есть небольшие замечания. В основном они касаются того, что я туповат, и мне нужны пояснения в виде комментариев в коде. Ну и @ts-ignore желательно убрать.
packages/server/routes/SSR.ts
Outdated
@@ -104,7 +104,9 @@ export const SSRRoute = ({ vite, srcPath, distPath }: SSRRouteParams): RequestHa | |||
${helmet.meta.toString()} | |||
${helmet.link.toString()} | |||
` | |||
); | |||
) | |||
.replace(`{csp.nonce}`, req.nonce) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А кто и куда вставляет такую строку?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Изначально эта строка должна была заменять плейсхолдер в html на реальное значение nonce. Но я видимо не сохранил изменения в html 🤷.
Поменял метод на replaceAll.
* change lib option for es2021
…/FrontHeads/tanchiki into task/119-content-security-policy
|
||
function applyNonce(req: Request, cspString: string): string { | ||
if (cspString.includes(NONCE)) { | ||
req.nonce = crypto.randomBytes(16).toString('base64'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Синхронная версия randomBytes может заблокироваться в ожидании случайных данных. На веб-сервере лучше использовать асинхронную версию.
nodejs/help#457
Не призываю сейчас чинить, скорее на будущее
Настройка CSP.