Security / privacy improvements on cookies

This commit is contained in:
Squidly271 2022-03-22 16:11:52 -04:00
parent 0909e4bf38
commit 4775a1a59c
3 changed files with 22 additions and 23 deletions

View File

@ -204,7 +204,7 @@ $(function(){
}); });
if ( "<?=$killCookie?>" == "true" ) { // This is needed so that if language gets switched on the home page the home page gets regenerated correctly if ( "<?=$killCookie?>" == "true" ) { // This is needed so that if language gets switched on the home page the home page gets regenerated correctly
$.cookie("ca_languageSwitch",""); $.cookie("ca_languageSwitch","",{path:"/;SameSite=Lax"});
} }
<? if ( $cfg['debugging'] == "yes" ):?> <? if ( $cfg['debugging'] == "yes" ):?>
@ -767,8 +767,8 @@ function updateContent(button) {
$(".caMenuItem[data-category='"+startupScreen+"']").addClass("selectedMenu"); $(".caMenuItem[data-category='"+startupScreen+"']").addClass("selectedMenu");
startupScreen = button ? $(button).data("category") : startupScreen; startupScreen = button ? $(button).data("category") : startupScreen;
$.cookie("ca_startupButton",startupScreen,{expires:365}); $.cookie("ca_startupButton",startupScreen,{expires:365,path:"/;SameSite=Lax",secure:true});
$.cookie("ca_selectedMenu",startupScreen,{expires:365}); $.cookie("ca_selectedMenu",startupScreen,{expires:365,path:"/;SameSite=Lax",secure:true});
disableSearch(); disableSearch();
post({action:'force_update'}, function(result) { post({action:'force_update'}, function(result) {
@ -1093,8 +1093,8 @@ function clearSearchBox() {
function closeSidebar(cookie=false,visible=false) { function closeSidebar(cookie=false,visible=false) {
if ( ! cookie ) { if ( ! cookie ) {
$.cookie("sidebarAppPath",""); $.cookie("sidebarAppPath","",{path:"/;SameSite=Lax"});
$.cookie("sidebarAppName",""); $.cookie("sidebarAppName","",{path:"/;SameSite=Lax"});
} }
context.destroy("#supportPopup"); context.destroy("#supportPopup");
context.destroy("#actionsPopup"); context.destroy("#actionsPopup");
@ -1651,7 +1651,7 @@ function installMulti() {
if ( isConfirm ) { if ( isConfirm ) {
myCloseAlert(); myCloseAlert();
if ( docker.length && plugin.length ) { if ( docker.length && plugin.length ) {
$.cookie("ca_plugininstallpending",plugin); $.cookie("ca_plugininstallpending",plugin,{path:"/;SameSite=Lax"});
} }
if ( docker.length ) { if ( docker.length ) {
$("#sb-nav-close").css("visibility","hidden"); // Because docker install cannot be aborted so why allow window to close $("#sb-nav-close").css("visibility","hidden"); // Because docker install cannot be aborted so why allow window to close
@ -1706,7 +1706,6 @@ function updateDisplay(content) {
var description = $(this).html(); var description = $(this).html();
while (isOverflown(this)) { while (isOverflown(this)) {
description = description.slice(0,-5); description = description.slice(0,-5);
console.log(description);
$(this).html(description + "... <span class='card_readmore'><?=tr("Read more")?></span>"); $(this).html(description + "... <span class='card_readmore'><?=tr("Read more")?></span>");
} }
}); });
@ -1746,10 +1745,10 @@ function saveState() {
<? if ( $cfg['debugging'] == "yes" ):?> <? if ( $cfg['debugging'] == "yes" ):?>
console.log("Save State"); console.log("Save State");
<?endif;?> <?endif;?>
$.cookie("ca_categoryText",$("#Category").html()); $.cookie("ca_categoryText",$("#Category").html(),{path:"/;SameSite=Lax"});
$.cookie("ca_data",JSON.stringify(data)); $.cookie("ca_data",JSON.stringify(data),{path:"/;SameSite=Lax"});
$.cookie("ca_searchActive",data.searchActive); $.cookie("ca_searchActive",data.searchActive,{path:"/;SameSite=Lax"});
$.cookie("ca_installMulti",$(".multi_installDiv").is(":visible")); $.cookie("ca_installMulti",$(".multi_installDiv").is(":visible"),{path:"/;SameSite=Lax"});
var selectedMenu = $(".selectedMenu").data("category"); var selectedMenu = $(".selectedMenu").data("category");
if ( ! selectedMenu ) { if ( ! selectedMenu ) {
selectedMenu = ""; selectedMenu = "";
@ -1758,10 +1757,10 @@ function saveState() {
$(".caMenuEnabled").each(function(){ $(".caMenuEnabled").each(function(){
categoriesEnabled.push($(this).data("category")); categoriesEnabled.push($(this).data("category"));
}); });
$.cookie("ca_categories_enabled",JSON.stringify(categoriesEnabled)); $.cookie("ca_categories_enabled",JSON.stringify(categoriesEnabled),{path:"/;SameSite=Lax"});
$.cookie("ca_selectedMenu",selectedMenu); $.cookie("ca_selectedMenu",selectedMenu,{path:"/;SameSite=Lax"});
$.cookie("ca_filter",$("#searchBox").val()); $.cookie("ca_filter",$("#searchBox").val(),{path:"/;SameSite=Lax"});
$.cookie("ca_categoryName",$(".categoryMenuName").html()); $.cookie("ca_categoryName",$(".categoryMenuName").html(),{path:"/;SameSite=Lax"});
} }
function restoreState() { function restoreState() {
@ -2124,9 +2123,9 @@ function CAswitchLanguage(language) {
data.searchActive = true; // so the system doesn't resort data.searchActive = true; // so the system doesn't resort
saveState(); saveState();
$.cookie('locale',oldlanguage,{path:'/'}); // save the previous locale $.cookie('locale',oldlanguage,{path:"/;SameSite=Lax"}); // save the previous locale
post({action:'switchLanguage',language:language},function(result) { post({action:'switchLanguage',language:language},function(result) {
$.cookie("ca_languageSwitch","switched",{expires:365,path:'/'}); $.cookie("ca_languageSwitch","switched",{expires:365,path:"/;SameSite=Lax"});
myCloseSpinner(); myCloseSpinner();
window.location.reload(); window.location.reload();
}); });
@ -2141,7 +2140,7 @@ function installLanguage(languageURL,language) {
function updateLanguage(language) { function updateLanguage(language) {
disableSearch(); disableSearch();
$.cookie("updateLanguage",language); $.cookie("updateLanguage",language,{SameSite:'Lax'});
openBox('/plugins/community.applications/scripts/languageInstall.sh&arg1=update&arg2='+language,"<?tr('Update Language Pack')?>",600,900,true,"postUpdateLanguage"); openBox('/plugins/community.applications/scripts/languageInstall.sh&arg1=update&arg2='+language,"<?tr('Update Language Pack')?>",600,900,true,"postUpdateLanguage");
} }
@ -2464,8 +2463,8 @@ function popUpChart(descData) {
} }
function showSidebarApp(apppath,appname) { function showSidebarApp(apppath,appname) {
$.cookie("sidebarAppPath",apppath); $.cookie("sidebarAppPath",apppath,{path:"/;SameSite=Lax"});
$.cookie("sidebarAppName",appname); $.cookie("sidebarAppName",appname,{path:"/;SameSite=Lax"});
data.sidebarapppath = apppath; data.sidebarapppath = apppath;
data.sidebarappname = appname; data.sidebarappname = appname;
$("body").addClass("body_sidebarScroll"); $("body").addClass("body_sidebarScroll");
@ -2553,8 +2552,8 @@ function showRepoPopup(repository) {
context.destroy("#supportPopup"); context.destroy("#supportPopup");
context.destroy("#actionsPopup"); context.destroy("#actionsPopup");
if ( ! $(".sidebar").is(":visible") ) { if ( ! $(".sidebar").is(":visible") ) {
$.cookie("sidebarAppName",""); $.cookie("sidebarAppName","",{path:"/;SameSite=Lax"});
$.cookie("sidebarAppPath",""); $.cookie("sidebarAppPath","",{path:"/;SameSite=Lax"});
var fromCard = true; var fromCard = true;
} }

View File

@ -1,4 +1,4 @@
cfc409341cd986ef0f0ca03aa4fa8244 ./Apps.page fba5da7b32a25b10f66b98923ea2fe5b ./Apps.page
4e55f7483b661af21a25b677179baffe ./CA_notices.page 4e55f7483b661af21a25b677179baffe ./CA_notices.page
42a1658a916a3a3eed2a9f2af80603c4 ./ca_settings.page 42a1658a916a3a3eed2a9f2af80603c4 ./ca_settings.page
e718d7825dbdc96a17a915079222b098 ./default.cfg e718d7825dbdc96a17a915079222b098 ./default.cfg