adobe / aem-boilerplate

Use this repository template for new AEM projects.
https://main--aem-boilerplate--adobe.aem.page
Apache License 2.0
126 stars 349 forks source link

feat: Configure Mozilla's Eslint Plugin eslint-plugin-no-unsanitized + DOMPurify.sanitize + escapeHtml #416

Open andreituicu opened 1 month ago

andreituicu commented 1 month ago

Building on top of https://github.com/adobe/aem-boilerplate/pull/415

Test urls:

fkakatie commented 1 month ago

results of aem-psi-check would be necessary here.

andreituicu commented 1 month ago

@fkakatie completely agree. It looks like there's a problem with my fork, because when I access https://xss-lint-dompurify--helix-project-boilerplate--andreituicu.aem.live the head doesn't have any scripts/css... Could I possibly get write permissions to the boilerplate? That way I can create the branches directly in the project and recreate the PRs including PSI values.

andreituicu commented 1 month ago

@rofe I agree with your suggestions of moving different changes into aem-lib and aem-block-collection. I created this PR mostly as a consolidated view to collect feedback and discuss whether this is a direction we'd like to go in, or not.

I'm not 100% convinced it is simple enough for developers (which I might be wrong) when they should escape, when they should sanitize and when are both needed.

Using any of them will make the linter happy, but depending on context they aren't both secure, or said differently, each offers protection in specific cases.

I'm not sure if it would be a better approach to just keeping it simple by saying that any use of unsafe API is unsafe. The problem then becomes creating big structures with just document.createElement, document.appendChild and document.setAttribute and fragments always need to disable the linter rules, like: https://github.com/adobe/aem-boilerplate/pull/415/files#diff-7fdbc35e8d9d1b49261e0470a1900621a5eb2508a2818a9ee18e2e60514fae4eR26

aem-code-sync[bot] commented 1 month ago
Page Scores Audits Google
:iphone: / PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
:desktop_computer: / PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
andreituicu commented 1 month ago

Interesting results 1.6 LCP, that's really at the edge. I got 0.9 LCP on pagespeed: https://pagespeed.web.dev/analysis/https-xss-lint-dompurify--helix-project-boilerplate--andreituicu-aem-live/f2hqca9aqv?form_factor=mobile

andreituicu commented 1 month ago

Deep PSI said: 929 (1010 ± 139.8) for LCP.

https://labs.aem.live/tools/deep-psi/deep-psi.html?url1=https%3A%2F%2Fxss-lint-dompurify--helix-project-boilerplate--andreituicu.aem.live%2F&url2=