Skip to content
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

Security #1270

Merged
merged 20 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!--
<!--
Federalist recommends you use Continuous Integration to automatically test
and validate any new changes to your site. CircleCI is free for open source
projcets. You should replace this badge with your own.
Expand Down
1 change: 1 addition & 0 deletions _includes/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<script type="text/javascript" src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<!-- <script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.min.js"></script> -->
<!-- <script src="{{ site.baseurl }}/assets/js/jquery-ui.js"></script> -->
<!-- <script>var $j = $.noConflict(true);</script> -->

<script src="https://code.jquery.com/jquery-migrate-3.4.1.min.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion _pages/coffa/assets/js/blob-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ Buffer._augment = function (arr) {
return arr
}

var INVALID_BASE64_RE = /[^+\/0-9A-z]/g
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z]/g

function base64clean (str) {
// Node strips out invalid characters like \n and \t from the string, base64-js does not
Expand Down
2 changes: 1 addition & 1 deletion _pages/payment-accuracy/assets/js/blob-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ Buffer._augment = function (arr) {
return arr
}

var INVALID_BASE64_RE = /[^+\/0-9A-z]/g
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z]/g

function base64clean (str) {
// Node strips out invalid characters like \n and \t from the string, base64-js does not
Expand Down
11 changes: 7 additions & 4 deletions _pages/payment-accuracy/assets/js/magnific-popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
},
_getCloseBtn = function(type) {
if(type !== _currPopupType || !mfp.currTemplate.closeBtn) {
mfp.currTemplate.closeBtn = $( mfp.st.closeMarkup.replace('%title%', mfp.st.tClose ) );
mfp.currTemplate.closeBtn = $( mfp.st.closeMarkup.replace('%title%', mfp.st.tClose) );

Check warning

Code scanning / CodeQL

Unsafe jQuery plugin Medium

Potential XSS vulnerability in the
'$.fn.magnificPopup' plugin
.
_currPopupType = type;
}
return mfp.currTemplate.closeBtn;
Expand Down Expand Up @@ -353,7 +353,7 @@
$('html').css(windowStyles);

// add everything to DOM
mfp.bgOverlay.add(mfp.wrap).prependTo( mfp.st.prependTo || $(document.body) );
mfp.bgOverlay.add(mfp.wrap).prependTo( mfp.st.prependTo ? $(document).find(mfp.st.prependTo) : $(document.body) );

// Save last focused element
mfp._lastFocusedEl = document.activeElement;
Expand Down Expand Up @@ -506,7 +506,10 @@
_mfpTrigger('FirstMarkupParse', markup);

if(markup) {
mfp.currTemplate[type] = $(markup);
var parser = new DOMParser();
var doc = parser.parseFromString(markup, 'text/html');
var sanitizedMarkup = doc.body.textContent || "";
mfp.currTemplate[type] = $(sanitizedMarkup);
} else {
// if there is no markup found we just define that template is parsed
mfp.currTemplate[type] = true;
Expand Down Expand Up @@ -1857,4 +1860,4 @@
});

/*>>retina*/
_checkInstance(); }));
_checkInstance(); }));
26 changes: 16 additions & 10 deletions _pages/payment-accuracy/assets/js/slick.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
Issues: http://github.com/kenwheeler/slick/issues

*/
/* global window, document, define, jQuery, setInterval, clearInterval */
/* global window, document, define, jQuery, setInterval, clearInterval, DOMPurify */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
define(['jquery', 'dompurify'], factory);
} else if (typeof exports !== 'undefined') {
module.exports = factory(require('jquery'));
module.exports = factory(require('jquery'), require('dompurify'));
} else {
factory(jQuery);
factory(jQuery, DOMPurify);
}

}(function ($) {
}(function ($, DOMPurify) {
'use strict';
var Slick = window.Slick || {};

Expand Down Expand Up @@ -1459,15 +1459,15 @@
$('img[data-lazy]', imagesScope).each(function () {

var image = $(this),
imageSource = $(this).attr('data-lazy'),
imageSource = DOMPurify.sanitize($(this).attr('data-lazy')),
imageToLoad = document.createElement('img');

imageToLoad.onload = function () {

image
.animate({ opacity: 0 }, 100, function () {
image
.attr('src', imageSource)
.attr('src', encodeURI(imageSource))
.animate({ opacity: 1 }, 200, function () {
image
.removeAttr('data-lazy')
Expand All @@ -1489,7 +1489,7 @@

};

imageToLoad.src = imageSource;
imageToLoad.src = encodeURI(imageSource);

});

Expand Down Expand Up @@ -1639,6 +1639,12 @@

tryCount = tryCount || 1;

function sanitizeUrl(url) {
var a = document.createElement('a');
a.href = encodeURI(url);
return a.href;
}

var _ = this,
$imgsToLoad = $('img[data-lazy]', _.$slider),
image,
Expand All @@ -1648,7 +1654,7 @@
if ($imgsToLoad.length) {

image = $imgsToLoad.first();
imageSource = image.attr('data-lazy');
imageSource = sanitizeUrl(image.attr('data-lazy'));
imageToLoad = document.createElement('img');

imageToLoad.onload = function () {
Expand Down Expand Up @@ -2891,4 +2897,4 @@
return _;
};

}));
}));
2 changes: 1 addition & 1 deletion assets/js/blob-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ Buffer._augment = function (arr) {
return arr
}

var INVALID_BASE64_RE = /[^+\/0-9A-z]/g
var INVALID_BASE64_RE = /[^+\/0-9A-Za-z]/g

function base64clean (str) {
// Node strips out invalid characters like \n and \t from the string, base64-js does not
Expand Down
11 changes: 8 additions & 3 deletions assets/js/magnific-popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,11 @@
$('html').css(windowStyles);

// add everything to DOM
mfp.bgOverlay.add(mfp.wrap).prependTo( mfp.st.prependTo || $(document.body) );
var prependToElement = $(document.body);
if (mfp.st.prependTo) {
prependToElement = $(document).find(mfp.st.prependTo);
}
mfp.bgOverlay.add(mfp.wrap).prependTo(prependToElement);

// Save last focused element
mfp._lastFocusedEl = document.activeElement;
Expand Down Expand Up @@ -506,7 +510,8 @@
_mfpTrigger('FirstMarkupParse', markup);

if(markup) {
mfp.currTemplate[type] = $(markup);
var sanitizedMarkup = $.parseHTML(markup);
mfp.currTemplate[type] = $(sanitizedMarkup);
} else {
// if there is no markup found we just define that template is parsed
mfp.currTemplate[type] = true;
Expand Down Expand Up @@ -1857,4 +1862,4 @@
});

/*>>retina*/
_checkInstance(); }));
_checkInstance(); }));
10 changes: 6 additions & 4 deletions assets/js/slick.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

*/
/* global window, document, define, jQuery, setInterval, clearInterval */
import DOMPurify from 'dompurify';
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
Expand All @@ -28,6 +29,7 @@
}(function ($) {
'use strict';
var Slick = window.Slick || {};
var DOMPurify = require('dompurify');

Slick = (function () {

Expand Down Expand Up @@ -1459,7 +1461,7 @@
$('img[data-lazy]', imagesScope).each(function () {

var image = $(this),
imageSource = $(this).attr('data-lazy'),
imageSource = DOMPurify.sanitize($(this).attr('data-lazy')),
imageToLoad = document.createElement('img');

imageToLoad.onload = function () {
Expand Down Expand Up @@ -1648,7 +1650,7 @@
if ($imgsToLoad.length) {

image = $imgsToLoad.first();
imageSource = image.attr('data-lazy');
imageSource = DOMPurify.sanitize(image.attr('data-lazy'));
imageToLoad = document.createElement('img');

imageToLoad.onload = function () {
Expand Down Expand Up @@ -1695,7 +1697,7 @@

};

imageToLoad.src = imageSource;
imageToLoad.src = encodeURI(imageSource);

} else {

Expand Down Expand Up @@ -2891,4 +2893,4 @@
return _;
};

}));
}));
Loading