mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
Fixing Vulnerability A Fortify Scan finds a critical Cross-Site Scrip… (#2451)
* Fixing Vulnerability A Fortify Scan finds a critical Cross-Site Scripting * use var insted of const
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var utils = require('./../utils');
|
var utils = require('./../utils');
|
||||||
|
var isValidXss = require('./isValidXss');
|
||||||
|
|
||||||
module.exports = (
|
module.exports = (
|
||||||
utils.isStandardBrowserEnv() ?
|
utils.isStandardBrowserEnv() ?
|
||||||
@@ -27,6 +28,8 @@ module.exports = (
|
|||||||
href = urlParsingNode.href;
|
href = urlParsingNode.href;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isValidXss(url);
|
||||||
|
|
||||||
urlParsingNode.setAttribute('href', href);
|
urlParsingNode.setAttribute('href', href);
|
||||||
|
|
||||||
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = function isValidXss(requestURL) {
|
||||||
|
var regex = RegExp('<script+.*>+.*<\/script>');
|
||||||
|
return regex.test(requestURL);
|
||||||
|
};
|
||||||
@@ -8,4 +8,8 @@ describe('helpers::isURLSameOrigin', function () {
|
|||||||
it('should detect different origin', function () {
|
it('should detect different origin', function () {
|
||||||
expect(isURLSameOrigin('https://github.com/axios/axios')).toEqual(false);
|
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)
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user