add code to detect known 'bad' plugins, and disable plugins in this case for user safety

This commit is contained in:
Jon Atkins 2014-02-03 17:27:06 +00:00
parent b80c4fc7ef
commit 162ac6923e

View File

@ -562,15 +562,47 @@ function boot() {
$('#sidebar').show(); $('#sidebar').show();
if(window.bootPlugins) if(window.bootPlugins) {
$.each(window.bootPlugins, function(ind, ref) { // check to see if a known 'bad' plugin is installed. If so, alert the user, and don't boot any plugins
try { var badPlugins = {
ref(); 'arc': 'Contains hidden code to report private data to a 3rd party server: <a href="https://plus.google.com/105383756361375410867/posts/4b2EjP3Du42">details here</a>',
} catch(err) { };
console.error("error starting plugin: index "+ind+", error: "+err);
// remove entries from badPlugins which are not installed
$.each(badPlugins, function(name,desc) {
if (!(window.plugin && window.plugin[name])) {
// not detected: delete from the list
delete badPlugins[name];
} }
}); });
// if any entries remain in the list, report this to the user and don't boot ANY plugins
// (why not any? it's tricky to know which of the plugin boot entries were safe/unsafe)
if (Object.keys(badPlugins).length > 0) {
var warning = 'One or more known unsafe plugins were detected. For your safety, IITC has disabled all plugins.<ul>';
$.each(badPlugins,function(name,desc) {
warning += '<li><b>'+name+'</b>: '+desc+'</li>';
});
warning += '</ul><p>Please uninstall the problem plugins and reload the page. See this <a href="http://iitc.jonatkins.com/?page=faq#uninstall">FAQ entry</a> for help.</p><p><i>Note: It is tricky for IITC to safely disable just problem plugins</i></p>';
dialog({
title: 'Plugin Warning',
html: warning,
width: 400
});
} else {
// no known unsafe plugins detected - boot all plugins
$.each(window.bootPlugins, function(ind, ref) {
try {
ref();
} catch(err) {
console.error("error starting plugin: index "+ind+", error: "+err);
debugger;
}
});
}
}
window.setMapBaseLayer(); window.setMapBaseLayer();
window.setupLayerChooserApi(); window.setupLayerChooserApi();