-
Notifications
You must be signed in to change notification settings - Fork 934
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
USWDS | xss audit, standardization #4329
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we simplify this?
const { defaultValue, placeholder } = comboBoxEl.dataset
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.