-
Notifications
You must be signed in to change notification settings - Fork 437
Centralize and Fix DOMPurify Sanitizer #1544
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
Open
Zachary-Squires
wants to merge
26
commits into
OpenEnergyDashboard:development
Choose a base branch
from
Andrew-Bonner:development
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
23bca3d
Adding the commit from 1488 called "fix: resolved PR feedback on sani…
Landon-Wivell bacc35d
feat(security): centralize DOMPurify sanitizer and patch XSS in succe…
Landon-Wivell 979c3de
Added the commit from 1488 called "feat(security): centralize DOMPuri…
Zachary-Squires 7cfcb79
fix: resolved PR feedback on sanitizer imports and tests
Landon-Wivell e642e0e
Ran npm install, should bring jsdom and dompurify
Zachary-Squires 7cb2438
Restore executable permissions on scripts and binaries
Zachary-Squires 2ceee19
Merge pull request #1 from Andrew-Bonner/team_b
Zachary-Squires c24d3c4
Normalize all line endings to LF
Zachary-Squires f38a83e
Merge pull request #2 from Andrew-Bonner/team_b
Zachary-Squires ad31fd0
Change to not allow default postgres or secret token in OED production.
Zachary-Squires 2ba98fc
Merge branch 'OpenEnergyDashboard:development' into team_b
Zachary-Squires f5d6ce0
Merge branch 'team_b' of https://github.com/Andrew-Bonner/OED into te…
Zachary-Squires 489cc17
Merge pull request #3 from Andrew-Bonner/team_b
Zachary-Squires 3c3b6cc
Fix PR suggestions
Zach-O-Bates 6eb6d29
Revert "Merge pull request #3 from Andrew-Bonner/team_b"
Zachary-Squires 7611ae5
Merge branch 'team_b' into development
Zach-O-Bates 040f138
Simplify test to better align with mentor suggestions
Zach-O-Bates da2dd00
Update .gitattributes
Zachary-Squires 5a40623
Update docker-compose.yml
Zachary-Squires 9acd4b6
Update jsdom package
Zach-O-Bates c03723a
Addressing Suggestions for PR 1544
Zachary-Squires 533c588
Mark cron scripts as executable
Zachary-Squires df29aaa
Mark docker-compose.yml as executable
Zachary-Squires 80382e2
Update docker-compose.yml
Zachary-Squires fea6028
try to resolve some blank line change issues
huss 2ba9168
Merge remote-tracking branch 'origin/development' into pr/Zachary-Squ…
huss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| const { JSDOM } = require('jsdom'); | ||
huss marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const createDOMPurify = require('dompurify'); | ||
|
|
||
| // Create jsdom window application and initialize | ||
| const window = new JSDOM('').window; | ||
| const DOMPurify = createDOMPurify(window); | ||
|
|
||
| module.exports = DOMPurify; | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| /* This file tests the functionality of the DOMPurify library. It tests for XSS | ||
| vulnerabilities in HTML of user uploaded data.*/ | ||
|
|
||
| /* Run in OED Docker web container terminal/shell: | ||
| npm run testsome src/server/test/crossSite/crossSite.js */ | ||
| const { chai, mocha, expect, app, testUser } = require('../common'); | ||
|
|
||
| mocha.describe('Cross site', () => { | ||
| mocha.it('Test for sanitization of HTML', async () => { | ||
| const filePath = 'src/server/test/crossSite/readings.csv'; | ||
|
|
||
| const res = await chai.request(app).post('/api/csv/readings') | ||
| .field('email', testUser.username) | ||
| .field('password', testUser.password) | ||
| /* This next line should produce: | ||
| res.text: <h1>FAILURE</h1>CSVPipelineError: | ||
| User Error: Meter with name '<img src="x">' not found. */ | ||
| .field('meterName','<img src=x onerror="alert(document.domain)">') | ||
| .field('gzip', "no") | ||
| .attach('csvfile', 'src/server/test/crossSite/something.csv'); | ||
| expect(res).to.have.status(400); | ||
| expect(res.text).to.include('<img src="x">'); | ||
| }) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think testing for .not having "alert" (and maybe other strings?) would strengthen this test. |
||
| }) | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 1,2,3 |
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
22 changes: 11 additions & 11 deletions
22
...r/test/web/readingsData/expected_bar_group_ri_15-20_mu_kWh_gu_kWh_st_-inf_et_inf_bd_7.csv
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| reading,start time,end time | ||
| 57744.5416303119,2022-08-23 00:00:00,2022-08-30 00:00:00 | ||
| 58457.1956496669,2022-08-30 00:00:00,2022-09-06 00:00:00 | ||
| 59276.647957841,2022-09-06 00:00:00,2022-09-13 00:00:00 | ||
| 58879.1789750532,2022-09-13 00:00:00,2022-09-20 00:00:00 | ||
| 58647.346330365,2022-09-20 00:00:00,2022-09-27 00:00:00 | ||
| 58324.4920477014,2022-09-27 00:00:00,2022-10-04 00:00:00 | ||
| 58177.8818425628,2022-10-04 00:00:00,2022-10-11 00:00:00 | ||
| 58573.7982237878,2022-10-11 00:00:00,2022-10-18 00:00:00 | ||
| 58642.2652124796,2022-10-18 00:00:00,2022-10-25 00:00:00 | ||
| 58818.8114100034,2022-10-25 00:00:00,2022-11-01 00:00:00 | ||
| reading,start time,end time | ||
| 57744.5416303119,2022-08-23 00:00:00,2022-08-30 00:00:00 | ||
| 58457.1956496669,2022-08-30 00:00:00,2022-09-06 00:00:00 | ||
| 59276.647957841,2022-09-06 00:00:00,2022-09-13 00:00:00 | ||
| 58879.1789750532,2022-09-13 00:00:00,2022-09-20 00:00:00 | ||
| 58647.346330365,2022-09-20 00:00:00,2022-09-27 00:00:00 | ||
| 58324.4920477014,2022-09-27 00:00:00,2022-10-04 00:00:00 | ||
| 58177.8818425628,2022-10-04 00:00:00,2022-10-11 00:00:00 | ||
| 58573.7982237878,2022-10-11 00:00:00,2022-10-18 00:00:00 | ||
| 58642.2652124796,2022-10-18 00:00:00,2022-10-25 00:00:00 | ||
| 58818.8114100034,2022-10-25 00:00:00,2022-11-01 00:00:00 |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.