1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-05-25 09:13:27 +02:00

Persistent rng is no longer shared between containers

(different cookieStoreId)

Fixes #350
This commit is contained in:
kkapsner 2019-05-29 00:37:33 +02:00
parent 97e08d874a
commit 621106ffbf
5 changed files with 23 additions and 2 deletions

View File

@ -85,6 +85,11 @@
notice("my tab id is", data.tabId); notice("my tab id is", data.tabId);
tabId = data.tabId; tabId = data.tabId;
} }
if (data.hasOwnProperty("cookieStoreId")){
notice("my tab cookie store id is", data.cookieStoreId);
const {persistent: persistentRnd} = require("./randomSupplies");
persistentRnd.setCookieStoreId(data.cookieStoreId);
}
const persistentRndName = "persistent" + (extension.inIncognitoContext? "Incognito": "") + "Rnd"; const persistentRndName = "persistent" + (extension.inIncognitoContext? "Incognito": "") + "Rnd";
if (data.hasOwnProperty(persistentRndName)){ if (data.hasOwnProperty(persistentRndName)){
const persistentRndValue = data[persistentRndName]; const persistentRndValue = data[persistentRndName];

View File

@ -57,9 +57,11 @@
return; return;
} }
verbose("send back the tab id", port.sender.tab.id); verbose("send back the tab id", port.sender.tab.id);
verbose("send back the tab cookie store id", port.sender.tab.cookieStoreId);
verbose("send back the persistent random seeds", persistentRndStorage.persistentRnd); verbose("send back the persistent random seeds", persistentRndStorage.persistentRnd);
port.postMessage({ port.postMessage({
tabId: port.sender.tab.id, tabId: port.sender.tab.id,
cookieStoreId: port.sender.tab.cookieStoreId,
persistentRnd: persistentRndStorage.persistentRnd, persistentRnd: persistentRndStorage.persistentRnd,
persistentIncognitoRnd: persistentRndStorage.persistentIncognitoRnd persistentIncognitoRnd: persistentRndStorage.persistentIncognitoRnd
}); });

View File

@ -81,6 +81,7 @@
} }
var persistentRnd = Object.create(null); var persistentRnd = Object.create(null);
let cookieStoreId = "";
settings.onloaded(function(){ settings.onloaded(function(){
try { try {
let storedData = JSON.parse( let storedData = JSON.parse(
@ -120,7 +121,7 @@
}); });
return function getPersistentRnd(window){ return function getPersistentRnd(window){
var domain = getDomain(window); var domain = cookieStoreId + getDomain(window);
if (!persistentRnd[domain]){ if (!persistentRnd[domain]){
// create the (sub-)domains random numbers if not existing // create the (sub-)domains random numbers if not existing
persistentRnd[domain] = new Uint8Array(128); persistentRnd[domain] = new Uint8Array(128);
@ -142,6 +143,17 @@
scope.persistent.setDomainRnd = function(domain, rnd){ scope.persistent.setDomainRnd = function(domain, rnd){
persistentRnd[domain] = new Uint8Array(rnd); persistentRnd[domain] = new Uint8Array(rnd);
}; };
scope.persistent.setCookieStoreId = function(newCookieStoreId){
if (
typeof newCookieStoreId === "string" &&
newCookieStoreId !== "firefox-default"
){
cookieStoreId = (
newCookieStoreId !== "" &&
newCookieStoreId !== "firefox-default"
)? newCookieStoreId + "@": "";
}
};
scope.persistent.getRng = function(length, window){ scope.persistent.getRng = function(length, window){
var bitSet = new Uint32Array(getPersistentRnd(window).buffer); var bitSet = new Uint32Array(getPersistentRnd(window).buffer);
var bitSetLength = bitSet.length; var bitSetLength = bitSet.length;

View File

@ -85,7 +85,8 @@
"tabs", "tabs",
"activeTab", "activeTab",
"webRequest", "webRequest",
"webRequestBlocking" "webRequestBlocking",
"cookies"
], ],
"applications": { "applications": {

View File

@ -4,6 +4,7 @@ Version 0.5.10:
new features: new features:
- added date and time to the settings export file - added date and time to the settings export file
- persistent rng is no longer shared between containers (different cookieStoreId)
fixes: fixes:
- setter for innerHTML broke pages - setter for innerHTML broke pages