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

MWPW-159191: MAS Freyja support #3209

Open
wants to merge 147 commits into
base: ccd
Choose a base branch
from
Open

MWPW-159191: MAS Freyja support #3209

wants to merge 147 commits into from

Conversation

yesil
Copy link
Contributor

@yesil yesil commented Nov 18, 2024

Resolves: MWPW-159191

In this PR, I also removed the ccd-action variant that was merged for the initial MAS POC.

Depends on: #3135

Test URLs:

Axelcureno and others added 30 commits October 22, 2024 20:11
This reverts commit a3a8824.
…MWPW-157451

# Conflicts:
#	libs/deps/mas/mas.js
#	libs/deps/mas/merch-card.js
#	libs/features/mas/mas/dist/mas.js
to support all cta styles
organise code and code coverage

Update tests
@yesil yesil requested a review from a team as a code owner November 18, 2024 10:39
Copy link
Contributor

aem-code-sync bot commented Nov 18, 2024

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run PSI checks
  • Re-sync branch
Commits

Copy link
Contributor

aem-code-sync bot commented Nov 18, 2024

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

eslint

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

https://github.com/adobecom/milo/blob/c94803ea35ca77a7f961f4eab20f016ddd322e01/libs/features/mas/web-components/src/merch-card.js


⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

https://github.com/adobecom/milo/blob/c94803ea35ca77a7f961f4eab20f016ddd322e01/libs/features/mas/web-components/src/utils.js


⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

https://github.com/adobecom/milo/blob/c94803ea35ca77a7f961f4eab20f016ddd322e01/libs/features/mas/web-components/src/variants/ccd-slice.js


⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

https://github.com/adobecom/milo/blob/c94803ea35ca77a7f961f4eab20f016ddd322e01/libs/features/mas/web-components/src/variants/mini-compare-chart.css.js


⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

https://github.com/adobecom/milo/blob/c94803ea35ca77a7f961f4eab20f016ddd322e01/libs/features/mas/web-components/src/variants/mini-compare-chart.js


⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

https://github.com/adobecom/milo/blob/c94803ea35ca77a7f961f4eab20f016ddd322e01/libs/features/mas/web-components/src/variants/variant-layout.js


⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

https://github.com/adobecom/milo/blob/c94803ea35ca77a7f961f4eab20f016ddd322e01/libs/features/mas/web-components/src/variants/variants.js


⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

https://github.com/adobecom/milo/blob/c94803ea35ca77a7f961f4eab20f016ddd322e01/libs/features/mas/web-components/test/aem-fragment.test.html.js

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] reported by reviewdog 🐶
File ignored because of a matching ignore pattern. Use "--no-ignore" to override.

Copy link

codecov bot commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 97.86585% with 7 lines in your changes missing coverage. Please review.

Project coverage is 96.31%. Comparing base (6f4d98c) to head (c94803e).

Files with missing lines Patch % Lines
...bs/features/mas/web-components/src/aem-fragment.js 95.18% 4 Missing ⚠️
libs/features/mas/web-components/src/hydrate.js 94.23% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              ccd    #3209      +/-   ##
==========================================
- Coverage   96.37%   96.31%   -0.07%     
==========================================
  Files         245      243       -2     
  Lines       56716    56815      +99     
==========================================
+ Hits        54661    54720      +59     
- Misses       2055     2095      +40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

switch (variant) {
case 'ccd-slice':
if (backgroundImageConfig) {
merchCard.append(
createTag(
backgroundImageConfig.tag,
{ slot: backgroundImageConfig.slot },
`<img loading="lazy" src="${fragment.backgroundImage}" />`,
`<img loading="lazy" src="${fields.backgroundImage}" />`,

Check warning

Code scanning / CodeQL

Unsafe HTML constructed from library input Medium

This HTML construction which depends on
library input
might later allow
cross-site scripting
.
This HTML construction which depends on
library input
might later allow
cross-site scripting
.

Copilot Autofix AI about 3 hours ago

To fix the problem, we need to ensure that the fields.backgroundImage value is sanitized before being inserted into the HTML. This can be done by using a library like DOMPurify to sanitize the input or by creating a safe DOM element and setting its attributes directly.

The best way to fix this without changing existing functionality is to use the DOMPurify library to sanitize the fields.backgroundImage value before inserting it into the HTML. This ensures that any potentially malicious content is removed.

Suggested changeset 2
libs/features/mas/web-components/src/hydrate.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/libs/features/mas/web-components/src/hydrate.js b/libs/features/mas/web-components/src/hydrate.js
--- a/libs/features/mas/web-components/src/hydrate.js
+++ b/libs/features/mas/web-components/src/hydrate.js
@@ -1,2 +1,3 @@
 import { createTag } from './utils.js';
+import DOMPurify from 'dompurify';
 
@@ -93,3 +94,3 @@
                             { slot: backgroundImageConfig.slot },
-                            `<img loading="lazy" src="${fields.backgroundImage}" />`,
+                            `<img loading="lazy" src="${DOMPurify.sanitize(fields.backgroundImage)}" />`,
                         ),
EOF
@@ -1,2 +1,3 @@
import { createTag } from './utils.js';
import DOMPurify from 'dompurify';

@@ -93,3 +94,3 @@
{ slot: backgroundImageConfig.slot },
`<img loading="lazy" src="${fields.backgroundImage}" />`,
`<img loading="lazy" src="${DOMPurify.sanitize(fields.backgroundImage)}" />`,
),
libs/features/mas/web-components/package.json
Outside changed files

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/libs/features/mas/web-components/package.json b/libs/features/mas/web-components/package.json
--- a/libs/features/mas/web-components/package.json
+++ b/libs/features/mas/web-components/package.json
@@ -20,2 +20,3 @@
     "dependencies": {
+    "dompurify": "^3.2.0"
     },
EOF
@@ -20,2 +20,3 @@
"dependencies": {
"dompurify": "^3.2.0"
},
This fix introduces these dependencies
Package Version Security advisories
dompurify (npm) 3.2.0 None
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
@yesil yesil added the commerce label Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants