Skip to content
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

Merged
merged 16 commits into from
Feb 17, 2023
Merged

Conversation

andreyatx
Copy link
Contributor

@andreyatx andreyatx commented Feb 11, 2023

Настройка CSP.

@andreyatx andreyatx self-assigned this Feb 11, 2023
@andreyatx andreyatx requested a review from a team February 11, 2023 14:08
@andreyatx andreyatx added the enhancement New feature or request label Feb 11, 2023
Copy link
Contributor

@DmitriiNazimov DmitriiNazimov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Есть небольшие замечания. В основном они касаются того, что я туповат, и мне нужны пояснения в виде комментариев в коде. Ну и @ts-ignore желательно убрать.

@sdelfi sdelfi requested a review from a team February 14, 2023 11:01
@sdelfi sdelfi requested a review from a team February 14, 2023 11:05
@sdelfi sdelfi requested a review from Olegas February 14, 2023 20:13
@@ -104,7 +104,9 @@ export const SSRRoute = ({ vite, srcPath, distPath }: SSRRouteParams): RequestHa
${helmet.meta.toString()}
${helmet.link.toString()}
`
);
)
.replace(`{csp.nonce}`, req.nonce)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А кто и куда вставляет такую строку?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Изначально эта строка должна была заменять плейсхолдер в html на реальное значение nonce. Но я видимо не сохранил изменения в html 🤷.
Поменял метод на replaceAll.


function applyNonce(req: Request, cspString: string): string {
if (cspString.includes(NONCE)) {
req.nonce = crypto.randomBytes(16).toString('base64');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Синхронная версия randomBytes может заблокироваться в ожидании случайных данных. На веб-сервере лучше использовать асинхронную версию.
nodejs/help#457

Не призываю сейчас чинить, скорее на будущее

@andreyatx andreyatx merged commit d7c7b08 into develop Feb 17, 2023
@andreyatx andreyatx deleted the task/119-content-security-policy branch February 17, 2023 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants