1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 21:00:23 +01: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);
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";
if (data.hasOwnProperty(persistentRndName)){
const persistentRndValue = data[persistentRndName];

View File

@ -57,9 +57,11 @@
return;
}
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);
port.postMessage({
tabId: port.sender.tab.id,
cookieStoreId: port.sender.tab.cookieStoreId,
persistentRnd: persistentRndStorage.persistentRnd,
persistentIncognitoRnd: persistentRndStorage.persistentIncognitoRnd
});

View File

@ -81,6 +81,7 @@
}
var persistentRnd = Object.create(null);
let cookieStoreId = "";
settings.onloaded(function(){
try {
let storedData = JSON.parse(
@ -120,7 +121,7 @@
});
return function getPersistentRnd(window){
var domain = getDomain(window);
var domain = cookieStoreId + getDomain(window);
if (!persistentRnd[domain]){
// create the (sub-)domains random numbers if not existing
persistentRnd[domain] = new Uint8Array(128);
@ -142,6 +143,17 @@
scope.persistent.setDomainRnd = function(domain, 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){
var bitSet = new Uint32Array(getPersistentRnd(window).buffer);
var bitSetLength = bitSet.length;

View File

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

View File

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