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

sanitized text should have target attribute in links #1463

Merged
merged 4 commits into from
Nov 4, 2024
Merged

sanitized text should have target attribute in links #1463

merged 4 commits into from
Nov 4, 2024

Conversation

im-shiv
Copy link
Contributor

@im-shiv im-shiv commented Oct 24, 2024

No description provided.

@im-shiv im-shiv requested a review from rismehta October 24, 2024 09:24
Copy link
Collaborator

@rismehta rismehta left a comment

Choose a reason for hiding this comment

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

check comments

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.32%. Comparing base (6bbccfc) to head (8129b88).
Report is 2 commits behind head on dev.

Additional details and impacted files
@@             Coverage Diff              @@
##                dev    #1463      +/-   ##
============================================
+ Coverage     82.28%   82.32%   +0.03%     
- Complexity      924      926       +2     
============================================
  Files           103      103              
  Lines          2371     2376       +5     
  Branches        321      323       +2     
============================================
+ Hits           1951     1956       +5     
  Misses          257      257              
  Partials        163      163              

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

@im-shiv im-shiv requested a review from rismehta October 24, 2024 09:35
@@ -66,7 +66,10 @@
updateValue(value) {
// html sets undefined value as undefined string in input value, hence this check is added
let actualValue = typeof value === "undefined" ? "" : value;
const sanitizedValue = window.DOMPurify ? window.DOMPurify.sanitize(actualValue) : actualValue;
let sanitizedValue = window.DOMPurify ? window.DOMPurify.sanitize(actualValue, {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There may be several attributes that could be filtered out by DOMPurify. Please validate all scenarios that are exposed. We are also planning to provide the complete HTML view, so DOMPurify needs to be capable of handling all these situations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for future reference, this should have been done before addition of DOMPurify in the code.
Also, allowing different attributes exposes new risks for vulnerabilities, making use of DOMPurify irrelevant.
IMO, we should let customer come with a use-case and then provide a fix for it, if there is any.

Copy link
Collaborator

@rismehta rismehta Oct 24, 2024

Choose a reason for hiding this comment

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

for future reference, this should have been done before addition of DOMPurify in the code.

Yes, but since it wasn't addressed prior to the addition and is now considered a bug, please verify all the use cases currently exposed in the RTE.

Also, allowing different attributes exposes new risks for vulnerabilities, making use of DOMPurify irrelevant.

No, it's relevant. Someone could modify the JSON and still launch an XSS attack. Therefore, we should selectively sanitize the content based on our specific use cases through the RTE.

IMO, we should let customer come with a use-case and then provide a fix for it, if there is any.

No, in this case, we have already exposed a set of features, so all of them need to be validated as part of this PR to prevent any further regression. In fact, let's add all of the RTE use-cases as part of the test collateral itself.

Copy link
Collaborator

@rismehta rismehta Oct 24, 2024

Choose a reason for hiding this comment

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

What about doing this, let's write a function specifically for cleaning HTML in text component, since we have exposed a lot of RTE use-cases

// Custom configuration for DOMPurify
const cleanHTML = (dirtyHTML) => {
    // Specify the allowed tags and attributes
    const allowedTags = [
        'b', 'strong',
        'i', 'em',
        'u',
        'small',
        'blockquote',
        'code',
        'ul', 'ol', 'li',
        'a',
        'img',
        'table', 'tr', 'td', 'th',
        'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
        'br', 'p'
    ];

    const allowedAttributes = {
        // Allow attributes for links
        'a': ['href', 'target', 'rel'],
        // Allow attributes for images
        'img': ['src', 'alt', 'title']
    };

    // Sanitize the HTML
    const sanitizedHTML = DOMPurify.sanitize(dirtyHTML, {
        ALLOWED_TAGS: allowedTags,
        ALLOWED_ATTR: allowedAttributes
    });

    return sanitizedHTML;
};

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
focus-order-semantics minor
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
target-size serious

1 similar comment
@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
target-size serious

@adobe-bot
Copy link

Lighthouse scores (mobile)

Performance Accessibility Best-Practices SEO
Scores 94 96 96 75

@adobe-bot
Copy link

Lighthouse scores (desktop)

Performance Accessibility Best-Practices SEO
Scores 100 96 96 75

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
target-size serious

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
focus-order-semantics minor
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

@adobe-bot
Copy link

Lighthouse scores (mobile)

Performance Accessibility Best-Practices SEO
Scores 94 96 96 75

@adobe-bot
Copy link

Lighthouse scores (desktop)

Performance Accessibility Best-Practices SEO
Scores 100 96 96 75

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
target-size serious

2 similar comments
@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
target-size serious

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
target-size serious

Copy link
Collaborator

@rismehta rismehta left a comment

Choose a reason for hiding this comment

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

check comments

@rismehta
Copy link
Collaborator

Please fix the test failures in this PR

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
focus-order-semantics minor
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

@adobe-bot
Copy link

Lighthouse scores (mobile)

Performance Accessibility Best-Practices SEO
Scores 93 96 96 75

@adobe-bot
Copy link

Lighthouse scores (desktop)

Performance Accessibility Best-Practices SEO
Scores 100 96 96 75

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
target-size serious

2 similar comments
@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
target-size serious

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
target-size serious

@im-shiv im-shiv requested a review from rismehta October 30, 2024 08:57
@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
focus-order-semantics minor
label-title-only serious
landmark-one-main moderate
region moderate
target-size serious

@adobe-bot
Copy link

Lighthouse scores (desktop)

Performance Accessibility Best-Practices SEO
Scores 100 96 96 75

@adobe-bot
Copy link

Lighthouse scores (mobile)

Performance Accessibility Best-Practices SEO
Scores 93 96 96 75

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
target-size serious

2 similar comments
@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
target-size serious

@adobe-bot
Copy link

Accessibility Violations Found

Id Impact
label-title-only serious
target-size serious

@im-shiv im-shiv requested a review from barshat7 October 30, 2024 09:21
Copy link
Contributor

@barshat7 barshat7 left a comment

Choose a reason for hiding this comment

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

LGTM

@rismehta rismehta merged commit 7c29f5d into dev Nov 4, 2024
12 checks passed
@rismehta rismehta deleted the san branch November 4, 2024 05:39
sakshi-arora1 pushed a commit that referenced this pull request Dec 3, 2024
* fixing flaky test (#1450)

Co-authored-by: Shivam Agarwal <shivama@adobe.com>

* Fixing vulnerability in GH action (#1452)

* Translation support for strings in switch (#1456)

Co-authored-by: Pavitra Khatri <pavitrakhatri@pavitras-mbp.corp.adobe.com>

* Configured custom validation messages in file attachment (#1459)

Co-authored-by: Pavitra Khatri <pavitrakhatri@pavitras-mbp.corp.adobe.com>

* Fixing gh workflow (#1460)

* Fixing gh workflow

* Fixing GH actions

* Move areOptionsRichText above Options (#1465)

* FORMS-17046 Focus on panel with static text not working via custom function (#1464)

* Focus on panel with static text not working via custom function

* Fixing test

* FORMS-15852 xss security fix for svg upload in file attachment (#1462)

* FORMS-15852 xss fix for svg upload in file upload

* FORMS-15852 xss fix for svg upload in file upload II

* FORMS-15852 xss fix for svg upload in file upload main

* FORMS-15852 xss fix for svg upload in file upload main II

* FORMS-15852 xss fix for svg upload in file upload main II

* FORMS-15852 xss fix for svg upload in file upload main II

---------

Co-authored-by: Rajat Khurana <rajatkhurana@adobe.com>

* FORMS-17068 Fetch custom properties from CoreComponentCustomPropertiesProvider which are behind FT and make part of FormContainer get properties. (#1467)

Also updated FOrms SDK version

* sanitized text should have target attribute in links (#1463)

* sanitized text should have target attribute in links

* catering comments

* correcting test case

* catering comments

---------

Co-authored-by: Shivam Agarwal <shivama@adobe.com>

* FORMS-17091 initializing label in button view (#1471)

Co-authored-by: Shivam Agarwal <shivama@adobe.com>

* Fixing GH workflow (#1472)

* [FORMS-13474] HTML5 datalist enhancement in dropdown component (#1470)

* Adding new custom property for enable suggestions in bundles

* Junit test cases to cover Enable Suggestions and Multi Selection in Dropdown

* HTL template change + listener on checkbox

* Cypress test for enable suggestions

* Cypress test for enable suggestions

* Remove enableSuggestions from JSON

* Remove enableSuggestions from JUnit dropdown test json

* Cypress tests for dropdown with autocomplete

* Cypress tests for dropdown with autocomplete

* Update classname for datalist

* More Test cases to cover different values of enableSuggestions

* Remove extra code

* Simplified the return in enableSuggestions

* Remove JsonIgnore annotation

* JavaDoc for isEnableSuggestions

* Bump up the minor version in package-info

* Sort imports in dropdownimpl

* custom function registration using action url from backend (#1469)

* custom function registration using action url from backend

custom function registration using action url from backend

 custom function registration using action url from backend

* custom function registration using action url from backend

custom function registration using action url from backend

 custom function registration using action url from backend

* custom function registration using action url from backend

* custom function registration using action url from backend

* custom function registration using action url from backend

* custom function registration using action url from backend - reusing the existing function

* custom function registration using action url from backend - marked existing function as deprecated

custom function registration using action url from backend - marked existing function as deprecated

* Update FormContainer.java

* formatting only

* Update utils.js

---------

Co-authored-by: Rishi Mehta <69448117+rismehta@users.noreply.github.com>

* Revert "[FORMS-13474] HTML5 datalist enhancement in dropdown component (#1470)"

This reverts commit ac662e9.

* Moving CI to latest rotary image (#1475)

* using latest rotary image

* Fixing version

* @releng [maven-scm] :prepare release core-forms-components-reactor-3.0.72

* @releng [maven-scm] :prepare for next development iteration

* Update VERSIONS.md and README.md to include version 3.0.72

* Theme Editor POC CC Style Configs

* Fixed minor bug for base error class selector

* Adding style config for hCaptcha and reCaptcha

* Updating style for Buttons

* Updating style for Footer

* Updated style for Checkbox

* Updating style for input components

* Updating style for file input

* Updating style for image

* Updating style for radio button

* Updating style for switch

* Updating style for tnc

* Updating style for captcha

* Updating style for email and accordion

* Updating style for wizard

* Updating style for tabsontop

* Updating style for vertical tabs

* Updating style for panel container

* Updating themeConfig of container

* updating style for base

* Updating ids for theme editor support

* Updating reference to core components

* Clientlib changes

* Updating labels for UI

* Removing GuideException

* Additions in CheckboxGroup style config

* Updating VERTICAL and HORIZONTAL classes for checkbox and radiobutton

* Updating errormessage div styles for components

* Updating error and success states for components

---------

Co-authored-by: Shivam Agarwal <47965724+im-shiv@users.noreply.github.com>
Co-authored-by: Shivam Agarwal <shivama@adobe.com>
Co-authored-by: Rishi Mehta <69448117+rismehta@users.noreply.github.com>
Co-authored-by: pavi41 <82104752+pavi41@users.noreply.github.com>
Co-authored-by: Pavitra Khatri <pavitrakhatri@pavitras-mbp.corp.adobe.com>
Co-authored-by: anshikag-adobe <anshikag@adobe.com>
Co-authored-by: Rajat Khurana <30727855+rajatofficial@users.noreply.github.com>
Co-authored-by: Rajat Khurana <rajatkhurana@adobe.com>
Co-authored-by: Pankaj Girotra <126753223+girotraapankaj@users.noreply.github.com>
Co-authored-by: Barshat Rai <barshatrai99@gmail.com>
Co-authored-by: Rishi Mehta <rismehta@adobe.com>
Co-authored-by: ci-build <ci-build@aemforms>
Co-authored-by: Muskan Gupta <muskgupta@Muskans-MacBook-Pro.local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants