Added whitelist inspection

Fixes #331
This commit is contained in:
kkapsner 2019-05-04 01:12:45 +02:00
parent 783743b777
commit b27cf7087b
10 changed files with 310 additions and 17 deletions

View File

@ -672,11 +672,11 @@
"description": ""
},
"whitelistOnlyAPI": {
"message": "Erlaube nur die \"{api}\" API.",
"message": "Erlaube nur die {api}",
"description": ""
},
"whitelistAllAPIs": {
"message": "Erlaube alle APIs.",
"message": "Erlaube alle APIs",
"description": ""
},
"settings": {
@ -811,6 +811,10 @@
"message": "temporär erlauben",
"description": ""
},
"inspectWhitelist": {
"message": "Erlaubnisse ansehen",
"description": ""
},
"sessionWhiteList_title": {
"message": "Sitzungs-Whitelist",
"description": ""
@ -959,6 +963,10 @@
"message": "Maximale Länge der Browser-History, die der Webseite mitgeteilt wird.",
"description": ""
},
"historyLengthThreshold_urlSpecific": {
"message": "Um diesen Wert für bestimmte Seiten zu ändern, klicken Sie auf den schwarzen Pfeil um das Menü zu öffnen, fügen Sie die gewünschte Domain oder URL mit einem Klick auf \"+\" hinzu und geben Sie dort einen anderen Wert ein.",
"description": ""
},
"protectWindow_title": {
"message": "Window-API beschützen",
"description": ""
@ -1003,6 +1011,10 @@
"message": "Dies ermöglicht Änderungen an der Navigator-API. Diesen Schutz zu aktivieren ändert standardmäßig noch nichts. Öffnen Sie die Navigatoreinstellungen um die gewünschten Änderungen durchzuführen.",
"description": ""
},
"protectNavigator_urlSpecific": {
"message": "Um bestimmte Seiten von diesem Schutz auszuschließen, klicken Sie auf den schwarzen Pfeil um das Menü zu öffnen, fügen Sie die gewünschte Domain oder URL mit einem Klick auf \"+\" hinzu und entfernen Sie das zugehörige Häkchen.",
"description": ""
},
"openNavigatorSettings_title": {
"message": "Navigatoreinstellungen",
"description": ""
@ -1159,6 +1171,10 @@
"message": "Laden",
"description": ""
},
"inspectWhitelist_label": {
"message": "Erlaubnisse ansehen",
"description": ""
},
"resetSettings_title": {
"message": "Einstellungen zurücksetzen",
"description": ""
@ -1306,5 +1322,13 @@
"sanitation_error.doNotSharePersistentRndBetweenDomains": {
"message": "Teilen Sie die persistenten Zufallszahlen nicht zwischen Domains, da dies den Browser 100% eindeutig identifizierbar macht.",
"description": ""
},
"whitelist_inspection_title": {
"message": "CanvasBlocker Erlaubnisse ansehen",
"description": ""
},
"whitelist_all_apis": {
"message": "Alle APIs",
"description": ""
}
}

View File

@ -706,11 +706,11 @@
"description": ""
},
"whitelistOnlyAPI": {
"message": "Whitelist only the API \"{api}\".",
"message": "Whitelist only the {api}",
"description": ""
},
"whitelistAllAPIs": {
"message": "Whitelist all APIs.",
"message": "Whitelist all APIs",
"description": ""
},
"settings": {
@ -845,6 +845,10 @@
"message": "whitelist temporarily",
"description": ""
},
"inspectWhitelist": {
"message": "inspect whitelist",
"description": ""
},
"sessionWhiteList_title": {
"message": "Session whitelist",
@ -999,6 +1003,10 @@
"message": "Maximal length of the history that is reported to the website.",
"description": ""
},
"historyLengthThreshold_urlSpecific": {
"message": "To change this value for specific websites, click on the black arrow to open the menu, add the domain or URL by clicking on \"+\" and set a different value.",
"description": ""
},
"protectWindow_title": {
"message": "Protect window API",
@ -1047,6 +1055,10 @@
"message": "This page allows for changes in the navigator API. Enabling this protection does not change anything by default. Open the navigator settings to specify the changes you want to have there.",
"description": ""
},
"protectNavigator_urlSpecific": {
"message": "To exclude specific websites from this protection, click on the black arrow to open the menu, add the domain or URL by clicking on \"+\" and remove its checkmark.",
"description": ""
},
"openNavigatorSettings_title": {
"message": "Navigator settings",
@ -1212,6 +1224,10 @@
"message": "Load",
"description": ""
},
"inspectWhitelist_label": {
"message": "Inspect whitelist",
"description": ""
},
"resetSettings_title": {
"message": "Reset settings",
@ -1362,5 +1378,14 @@
"sanitation_error.doNotSharePersistentRndBetweenDomains": {
"message": "Do not share persistent randomness between domains because this makes the browser 100% trackable.",
"description": ""
},
"whitelist_inspection_title": {
"message": "CanvasBlocker whitelist inspection",
"description": ""
},
"whitelist_all_apis": {
"message": "All APIs",
"description": ""
}
}

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="19"
height="19"
id="svg2"
version="1.1"
inkscape:version="0.92.4 5da689c313, 2019-01-14"
sodipodi:docname="pageAction-inspectWhitelist.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="7.9195959"
inkscape:cx="4.6442693"
inkscape:cy="37.008101"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1600"
inkscape:window-height="841"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Ebene 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1033.3622)">
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;line-height:0%;font-family:sans-serif;text-align:start;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none"
x="-4.8717484"
y="1008.9256"
id="text3755"><tspan
sodipodi:role="line"
id="tspan3757"
x="-4.8717484"
y="1008.9256"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:20px;line-height:1.25;font-family:'Times New Roman';-inkscape-font-specification:'Times New Roman';text-align:start;text-anchor:start">www.</tspan></text>
<path
style="fill:none;stroke:#00be00;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
d="m 4.1668789,1040.8717 c 2.65165,3.1567 3.661803,3.788 4.293148,8.5863 0.883884,-3.7881 2.3550471,-9.0615 7.0710681,-13.3846"
id="path2985"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccc" />
<path
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:Sans;-inkscape-font-specification:Sans;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;baseline-shift:baseline;text-anchor:start;display:inline;overflow:visible;visibility:visible;fill:#909090;fill-opacity:1;stroke:none;stroke-width:3.00000048;marker:none;enable-background:accumulate"
d="m 12.132528,1038.8104 c -1.951229,-2.0055 -5.1650311,-2.0621 -7.1557308,-0.1252 -1.9906536,1.9366 -2.0133742,5.1417 -0.062156,7.1474 1.7410193,1.7895 4.4869752,2.0432 6.4725938,0.7011 l 5.832664,5.995 1.259219,-1.225 -5.832666,-5.9951 c 1.397863,-1.9497 1.227084,-4.7088 -0.513935,-6.4985 z m -0.876012,0.8523 c 1.495926,1.5376 1.473088,3.9665 -0.03868,5.4376 -1.5117245,1.4706 -3.9312443,1.4177 -5.4271737,-0.1197 -1.495926,-1.5376 -1.473329,-3.9486 0.038391,-5.4192 1.5117684,-1.4709 3.9315303,-1.4359 5.4274577,0.1004 z"
id="path2985-3"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -310,7 +310,8 @@
},
{
name: "protectNavigator",
defaultValue: false
defaultValue: false,
urlSpecific: true
},
{
name: "navigatorDetails",

View File

@ -56,6 +56,10 @@
link.click();
document.body.removeChild(link);
},
inspectWhitelist: function(){
logging.verbose("open whitelist inspection");
window.open("whitelist.html", "_blank");
},
loadSettings: function(){
logging.verbose("load settings");
new Promise(function(resolve, reject){

View File

@ -538,7 +538,7 @@
},
{
"name": "exportSettings",
"actions": ["inspectSettings", "saveSettings", "loadSettings"]
"actions": ["inspectSettings", "inspectWhitelist", "saveSettings", "loadSettings"]
},
{
"name": "resetSettings"

18
options/whitelist.html Normal file
View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<title>CanvasBlocker whitelist inspection</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" media="screen" href="sanitize.css" />
</head>
<body>
<script src="../lib/require.js"></script>
<script src="../lib/extension.js"></script>
<script src="../lib/logging.js"></script>
<script src="../lib/settingDefinitions.js"></script>
<script src="../lib/settingContainers.js"></script>
<script src="../lib/settings.js"></script>
<script src="../lib/theme.js"></script>
<script src="whitelist.js"></script>
</body>
</html>

132
options/whitelist.js Normal file
View File

@ -0,0 +1,132 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
(function(){
"use strict";
const extension = require("../lib/extension");
const settings = require("../lib/settings");
const settingContainers = require("../lib/settingContainers");
require("../lib/theme").init();
const searchParameters = new URLSearchParams(window.location.search);
var title = document.createElement("h1");
title.className = "title";
title.textContent = extension.getTranslation("whitelist_inspection_title");
document.body.appendChild(title);
document.querySelector("head title").textContent = title.textContent;
settings.onloaded(function(){
const sets = settingContainers.urlContainer.get();
const setSelect = document.createElement("select");
sets.forEach(function(set){
setSelect.appendChild(new Option(set.url));
});
document.body.appendChild(setSelect);
if (searchParameters.has("urls")){
const urls = JSON.parse(searchParameters.get("urls")).map(function(url){
return new URL(url);
});
if (
!sets.some(function(set, index){
if (urls.some(function(url){
return set.match && set.match(url);
})){
setSelect.selectedIndex = index;
return true;
}
}) &&
searchParameters.has("domain")
){
setSelect.appendChild(new Option(searchParameters.get("domain")));
setSelect.selectedIndex = setSelect.options.length - 1;
}
}
const whitelistSettings = [
{
title: extension.getTranslation("whitelist_all_apis"),
name: "blockMode",
whitelistValue: "allow",
protectedValue: "fake"
},
{
title: extension.getTranslation("section_canvas-api"),
name: "protectedCanvasPart",
whitelistValue: "nothing",
protectedValue: "readout"
},
{
title: extension.getTranslation("section_audio-api"),
name: "protectAudio",
whitelistValue: false,
protectedValue: true
},
{
title: extension.getTranslation("section_history-api"),
name: "historyLengthThreshold",
whitelistValue: 10000,
protectedValue: 2
},
{
title: extension.getTranslation("section_window-api"),
name: "protectWindow",
whitelistValue: false,
protectedValue: true
},
{
title: extension.getTranslation("section_DOMRect-api"),
name: "protectDOMRect",
whitelistValue: false,
protectedValue: true
},
{
title: extension.getTranslation("section_navigator-api"),
name: "protectNavigator",
whitelistValue: false,
protectedValue: true
},
];
const table = document.createElement("table");
whitelistSettings.forEach(function(setting){
const row = document.createElement("tr");
setting.row = row;
const name = document.createElement("td");
name.textContent = setting.title || extension.getTranslation(setting.name + "_title");
row.appendChild(name);
setting.input = document.createElement("input");
setting.input.type = "checkbox";
setting.input.addEventListener("change", function(){
settings.set(
setting.name,
this.checked? setting.protectedValue: setting.whitelistValue,
setSelect.value
);
});
const input = document.createElement("td");
input.appendChild(setting.input);
row.appendChild(input);
table.appendChild(row);
});
document.body.appendChild(table);
function update(){
whitelistSettings.forEach(function(setting){
setting.row.style.display = settings.get(setting.name) === setting.whitelistValue?
"none":
"";
const currentValue = settings.get(setting.name, setSelect.value);
setting.input.checked = currentValue !== setting.whitelistValue;
});
}
update();
setSelect.addEventListener("change", update);
settings.on("any", update);
});
}());

View File

@ -128,16 +128,6 @@
extension.getTranslation("selectWhitelist"),
extension.getTranslation("inputWhitelistURL")
).then(function(choice){
const allAPIs = {
choice,
setting: "blockMode",
settingValue: "allow"
};
const onlyAPI = {
choice,
setting: whitelistingSettings[api],
settingValue: false
};
if (
api &&
whitelistingSettings[api]
@ -147,7 +137,10 @@
[
{
text: extension.getTranslation("whitelistOnlyAPI")
.replace(/\{api\}/g, api),
.replace(
/\{api\}/g,
extension.getTranslation("section_" + api + "-api")
),
value: api
},
{
@ -194,6 +187,21 @@
}
});
}
},
{
name: "inspectWhitelist",
isIcon: true,
callback: function({domain, urls}){
window.open(
browser.extension.getURL(
"options/whitelist.html?domain=" +
encodeURIComponent(domain) +
"&urls=" +
encodeURIComponent(JSON.stringify(Array.from(urls.values())))
),
"_blank"
);
}
}
].forEach(function(domainAction){
domainNotification.addAction(domainAction);

View File

@ -2,6 +2,7 @@ Version 0.5.9:
changes:
- code cleanup
- made history length threshold url specific
- made navigator protection url specific
- uniform themes
new features:
@ -12,6 +13,8 @@ Version 0.5.9:
- added option to protect no part of the canvas API
- apply themes to all extension pages (options, page action, browser action, setting sanitation, setting inspection, navigator settings)
- theme for automatic detection of dark mode (only works with Firefox >= 67)
- within the page action the used API can be whitelisted alone
- added overview page for whitelist
fixes:
- search could show hidden settings