Skip to content

Commit

Permalink
Fixing Vulnerability A Fortify Scan finds a critical Cross-Site Scrip… (
Browse files Browse the repository at this point in the history
#2451)

* Fixing Vulnerability A Fortify Scan finds a critical Cross-Site Scripting

* use var insted of const
  • Loading branch information
Wataru authored and felipewmartins committed Oct 9, 2019
1 parent 4f189ec commit 19969b4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/helpers/isURLSameOrigin.js
@@ -1,6 +1,7 @@
'use strict';

var utils = require('./../utils');
var isValidXss = require('./isValidXss');

module.exports = (
utils.isStandardBrowserEnv() ?
Expand All @@ -27,6 +28,8 @@ module.exports = (
href = urlParsingNode.href;
}

isValidXss(url);

urlParsingNode.setAttribute('href', href);

// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
Expand Down
6 changes: 6 additions & 0 deletions lib/helpers/isValidXss.js
@@ -0,0 +1,6 @@
'use strict';

module.exports = function isValidXss(requestURL) {
var regex = RegExp('<script+.*>+.*<\/script>');
return regex.test(requestURL);
};
4 changes: 4 additions & 0 deletions test/specs/helpers/isURLSameOrigin.spec.js
Expand Up @@ -8,4 +8,8 @@ describe('helpers::isURLSameOrigin', function () {
it('should detect different origin', function () {
expect(isURLSameOrigin('https://github.com/axios/axios')).toEqual(false);
});

it('should detect xss', function () {
expect(isURLSameOrigin('https://github.com/axios/axios?<script>alert("hello")</script>')).toEqual(false)
})
});

0 comments on commit 19969b4

Please sign in to comment.