USWDS | xss audit, standardization#4329
Merged
thisisdano merged 34 commits intodevelopfrom Oct 25, 2021
Merged
Conversation
mejiaj
reviewed
Oct 4, 2021
Contributor
mejiaj
left a comment
There was a problem hiding this comment.
Minor comment, but otherwise LGTM.
We have some cases of almost duplicate code when checking single or plural. We should refactor in the future.
Examples:
file-input.js:145
file-input.js:282
combobox.js:448
src/js/components/combo-box.js
Outdated
| const defaultValue = comboBoxEl.dataset.defaultValue; | ||
| const placeholder = comboBoxEl.dataset.placeholder; | ||
| const {defaultValue} = comboBoxEl.dataset; | ||
| const {placeholder} = comboBoxEl.dataset; |
Contributor
There was a problem hiding this comment.
Could we simplify this?
const { defaultValue, placeholder } = comboBoxEl.dataset
mejiaj
approved these changes
Oct 25, 2021
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
It was reported in our community channels that an XSS vulnerability exists in our
combo-box.jsscript, and was resolved and deployed from pull request #4287 .Similar vulnerabilities could be possible through other components that use
innerHTMLassignments.Because of this, we have decided to set up a standard at which we should construct elements while limiting similar vulnerabilities, but without losing the ability to build with those methods.
We have included a new linter plugin eslint-plugin-no-unsanitized created by the folks at mozilla, which,
This linter will notify contributors when unsafe coding patterns have been used. As the plugin suggests, we recommend,
When any of these approaches are properly resolved, the linter will no longer throw an error.
We have included the provided
sanitizer.jslibrary in our utils which will support fixing these errors. More information can be found in the plugin documentationnpm testand make sure the tests for the files you have changed have passed.