Skip to content

[cve] Migrate jquery.cookie to js.cookie for CVE-2022-23395 #4054

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
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ import huePubSub from 'utils/huePubSub';
import I18n from 'utils/i18n';
import UUID from 'utils/string/UUID';
import hueAnalytics from 'utils/hueAnalytics';
import Cookies from 'js-cookie';

export const NAME = 'download-result-modal';

@@ -72,7 +73,7 @@ class DownloadResultModal {

params.executable.toContext(id).then(jsonContext => {
this.cookieId = 'download-' + id;
$.cookie(this.cookieId, null, { expires: -1, path: '/' });
Cookies.set(this.cookieId, null, { expires: -1, path: '/' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing import statement (import Cookies from 'js-cookie'). Once the import is in place you can remove the eslint-disable lines


this.addAndSubmitDownloadForm(jsonContext, params.format);

@@ -84,14 +85,14 @@ class DownloadResultModal {
trackCookie() {
let timesChecked = 0;
this.checkDownloadInterval = window.setInterval(() => {
if (!$.cookie(this.cookieId)) {
if (!Cookies.get(this.cookieId)) {
if (timesChecked > 9) {
this.$downloadProgressModal.show();
}
} else {
window.clearInterval(this.checkDownloadInterval);
try {
const cookieContent = $.cookie(this.cookieId);
const cookieContent = Cookies.get(this.cookieId);
const result = JSON.parse(
cookieContent
.substr(1, cookieContent.length - 2)
2 changes: 2 additions & 0 deletions desktop/core/src/desktop/js/hue.js
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@ import page from 'page';
import qq from 'ext/fileuploader.custom.new';
import fileuploader from 'ext/fileuploader.custom';
import sprintf from 'sprintf-js';
import Cookies from 'js-cookie';

import ko from 'ko/ko.all';

@@ -117,6 +118,7 @@ window.sqlStatementsParser = sqlStatementsParser;
window.hplsqlStatementsParser = hplsqlStatementsParser;
window.sqlUtils = sqlUtils;
window.createReactComponents = createReactComponents;
window.Cookies = Cookies;

$(document).ready(async () => {
await refreshConfig(); // Make sure we have config up front
1 change: 0 additions & 1 deletion desktop/core/src/desktop/js/jest/jquery.setup.js
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@
// limitations under the License.

import $ from 'jquery';
import 'jquery.cookie';

global.$ = $;
global.jQuery = $;
1 change: 0 additions & 1 deletion desktop/core/src/desktop/js/jquery/jquery.common.js
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ import $ from 'jquery';
import 'jquery/jquery.migration';

import 'jquery-contextmenu'; // TODO: Remove, it's only used for "old" query builder
import 'jquery.cookie';
import 'jquery-form';
import 'jquery/plugins/jquery.selectize';
import 'selectize-plugin-clear';
Original file line number Diff line number Diff line change
@@ -168,10 +168,10 @@ $(document).ready(function () {
});
});

$("#updateSkipWizard").prop('checked', $.cookie("hueLandingPage", { path: "/" }) == "home");
$("#updateSkipWizard").prop('checked', Cookies.set("hueLandingPage", { path: "/" }) == "home");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks incorrect, but so was the old code even before the inline js migration. Lets leave it for this PR.


$("#updateSkipWizard").change(function () {
$.cookie("hueLandingPage", this.checked ? "home" : "wizard", {
Cookies.set("hueLandingPage", this.checked ? "home" : "wizard", {
path: "/",
secure: window.location.protocol.indexOf('https') > -1
});
Original file line number Diff line number Diff line change
@@ -491,7 +491,7 @@ from desktop.lib.django_util import nonce_attribute
window.hueAnalytics.log('notebook', 'download' + format);

var self = this;
$.cookie('download-' + self.snippet.id(), null, { expires: -1, path: '/' })
window.Cookies.set('download-' + self.snippet.id(), null, { expires: -1, path: '/' })
self.$downloadForm.find('input[name=\'format\']').val(format);
self.$downloadForm.find('input[name=\'notebook\']').val(ko.mapping.toJSON(self.notebook.getContext()));
self.$downloadForm.find('input[name=\'snippet\']').val(ko.mapping.toJSON(self.snippet.getContext()));
@@ -502,15 +502,15 @@ from desktop.lib.django_util import nonce_attribute

var timesChecked = 0;
self.checkDownloadInterval = window.setInterval(function () {
if ($.cookie('download-' + self.snippet.id()) === null || typeof $.cookie('download-' + self.snippet.id()) === 'undefined') {
if (window.Cookies.get('download-' + self.snippet.id()) === null || typeof window.Cookies.get('download-' + self.snippet.id()) === 'undefined') {
if (timesChecked == 10) {
$(self.downloadProgressModalId).modal('show');
}
}
else {
window.clearInterval(self.checkDownloadInterval);
try {
var cookieContent = $.cookie('download-' + self.snippet.id());
var cookieContent = window.Cookies.get('download-' + self.snippet.id());
var result = JSON.parse(cookieContent.substr(1, cookieContent.length - 2).replace(/\\"/g, '"').replace(/\\054/g, ','));
self.downloadTruncated(result.truncated);
self.downloadCounter(result.row_counter);
32 changes: 14 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -53,7 +53,6 @@
"jquery-form": "4.3.0",
"jquery-mousewheel": "3.1.13",
"jquery-ui": "1.13.2",
"jquery.cookie": "1.4.1",
"knockout": "3.5.1",
"knockout-sortable": "1.2.0",
"knockout-switch-case": "2.1.0",
@@ -83,7 +82,8 @@
"styled-components": "5.3.10",
"vue": "3.2.0",
"vue-custom-element": "3.2.14",
"vue3-datepicker": "0.2.5"
"vue3-datepicker": "0.2.5",
"js-cookie": "3.0.5"
},
"devDependencies": {
"@babel/cli": "7.24.8",