diff options
author | NateN1222 <nathannichols454@gmail.com> | 2017-08-12 12:27:49 -0500 |
---|---|---|
committer | NateN1222 <nathannichols454@gmail.com> | 2017-08-12 12:27:49 -0500 |
commit | ab4a4a9c49c25e2703b1fded3272d0a4cfb35838 (patch) | |
tree | c1e2e2ffc73fd6f35c1bfad762d96a4754389513 | |
parent | ec120cf896aee2c595d957745f9909a506c8036c (diff) |
UI improvements, started a file for the JS evaluation
-rw-r--r-- | eval_test.js | 173 | ||||
-rw-r--r-- | html/display_panel/content/display-panel.html | 6 | ||||
-rw-r--r-- | html/display_panel/content/main_panel.js | 41 | ||||
-rw-r--r-- | main_background.js | 11 |
4 files changed, 215 insertions, 16 deletions
diff --git a/eval_test.js b/eval_test.js new file mode 100644 index 0000000..c432b61 --- /dev/null +++ b/eval_test.js @@ -0,0 +1,173 @@ +/** +* This file is the "skeleton" of the final system to determine +* if a script is accepted or blocked. +* +* +* +*/ + +/* + NONTRIVIAL THINGS: + - Fetch + - XMLhttpRequest + - eval() + - ? + JAVASCRIPT CAN BE FOUND IN: + - Event handlers (onclick, onload, onsubmit, etc.) + - <script>JS</script> + - <script src="/JS.js"></script> + WAYS TO DETERMINE PASS/FAIL: + - "// @license [magnet link] [identifier]" then "// @license-end" (may also use /* comments) + - Automatic whitelist: (http://bzr.savannah.gnu.org/lh/librejs/dev/annotate/head:/data/script_libraries/script-libraries.json_ + - <table id="jslicense-labels1"><table> which may be linked to by a link tag identified by rel="jslicense" or data-jslicense="1" + - In the first script tag, declare the license with @licstart/@licend + +*/ +var license_regexes = { + // Looks like + // "// @license [magnet link] [identifier]" + // "// @license-end" + "license" :{ + "start": /\/\/\s*@license\s+magnet:?.*\s\w+/g, + "end": /\/\/\s*@license\-end/g + } + +} +var licenses = { + 'Apache-2.0':{ + 'URL': 'http://www.apache.org/licenses/LICENSE-2.0', + 'Magnet link': 'magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7&dn=apache-2.0.txt' + }, + // No identifier was present + 'Artistic-2.0':{ + 'URL': 'http://www.perlfoundation.org/artistic_license_2_0', + 'Magnet link': 'magnet:?xt=urn:btih:54fd2283f9dbdf29466d2df1a98bf8f65cafe314&dn=artistic-2.0.txt' + }, + // No identifier was present + 'Boost':{ + 'URL': 'http://www.boost.org/LICENSE_1_0.txt', + 'Magnet link': 'magnet:?xt=urn:btih:89a97c535628232f2f3888c2b7b8ffd4c078cec0&dn=Boost-1.0.txt' + }, + // No identifier was present + 'BSD-3-Clause':{ + 'URL': 'http://opensource.org/licenses/BSD-3-Clause', + 'Magnet link': 'magnet:?xt=urn:btih:c80d50af7d3db9be66a4d0a86db0286e4fd33292&dn=bsd-3-clause.txt', + }, + 'CPAL-1.0':{ + 'URL': 'http://opensource.org/licenses/cpal_1.0', + 'Magnet link': 'magnet:?xt=urn:btih:84143bc45939fc8fa42921d619a95462c2031c5c&dn=cpal-1.0.txt' + }, + 'CC0-1.0':{ + 'URL': 'http://creativecommons.org/publicdomain/zero/1.0/legalcode', + 'Magnet link': 'magnet:?xt=urn:btih:90dc5c0be029de84e523b9b3922520e79e0e6f08&dn=cc0.txt' + }, + 'EPL-1.0':{ + 'URL': 'http://www.eclipse.org/legal/epl-v10.html', + 'Magnet link': 'magnet:?xt=urn:btih:4c6a2ad0018cd461e9b0fc44e1b340d2c1828b22&dn=epl-1.0.txt' + }, + 'Expat':{ + 'URL': 'http://www.jclark.com/xml/copying.txt', + 'Magnet link': 'magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt' + }, + 'FreeBSD':{ + 'URL': 'http://www.freebsd.org/copyright/freebsd-license.html', + 'Magnet link': 'magnet:?xt=urn:btih:87f119ba0b429ba17a44b4bffcab33165ebdacc0&dn=freebsd.txt' + }, + 'GPL-2.0':{ + 'URL': 'http://www.gnu.org/licenses/gpl-2.0.html', + 'Magnet link': 'magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt' + }, + 'GPL-3.0':{ + 'URL': 'http://www.gnu.org/licenses/gpl-3.0.html', + 'Magnet link': 'magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt' + }, + 'LGPL-2.1':{ + 'URL': 'http://www.gnu.org/licenses/lgpl-2.1.html', + 'Magnet link': 'magnet:?xt=urn:btih:5de60da917303dbfad4f93fb1b985ced5a89eac2&dn=lgpl-2.1.txt' + }, + 'LGPL-3.0':{ + 'URL': 'http://www.gnu.org/licenses/lgpl-3.0.html', + 'Magnet link': 'magnet:?xt=urn:btih:0ef1b8170b3b615170ff270def6427c317705f85&dn=lgpl-3.0.txt' + }, + 'AGPL-3.0':{ + 'URL': 'http://www.gnu.org/licenses/agpl-3.0.html', + 'Magnet link': 'magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt' + }, + 'ISC':{ + 'URL': 'https://www.isc.org/downloads/software-support-policy/isc-license/', + 'Magnet link': 'magnet:?xt=urn:btih:b8999bbaf509c08d127678643c515b9ab0836bae&dn=ISC.txt' + }, + 'MPL-2.0':{ + 'URL': 'http://www.mozilla.org/MPL/2.0', + 'Magnet link': 'magnet:?xt=urn:btih:3877d6d54b3accd4bc32f8a48bf32ebc0901502a&dn=mpl-2.0.txt' + }, + // "Public domain is not a license" + // Replace with CC0? + 'Public-Domain':{ + 'URL': 'https://www.gnu.org/licenses/license-list.html#PublicDomain', + 'Magnet link': 'magnet:?xt=urn:btih:e95b018ef3580986a04669f1b5879592219e2a7a&dn=public-domain.txt' + }, + 'UPL-1.0': { + 'URL': 'https://oss.oracle.com/licenses/upl/', + 'Magnet link': 'magnet:?xt=urn:btih:478974f4d41c3fa84c4befba25f283527fad107d&dn=upl-1.0.txt' + }, + 'WTFPL': { + 'URL': 'http://www.wtfpl.net/txt/copying/', + 'Magnet link': 'magnet:?xt=urn:btih:723febf9f6185544f57f0660a41489c7d6b4931b&dn=wtfpl.txt' + }, + 'Unlicense':{ + 'URL': 'http://unlicense.org/UNLICENSE', + 'Magnet link': 'magnet:?xt=urn:btih:5ac446d35272cc2e4e85e4325b146d0b7ca8f50c&dn=unlicense.txt' + }, + // No identifier was present + 'X11':{ + 'URL': 'http://www.xfree86.org/3.3.6/COPYRIGHT2.html#3' + 'Magnet link': 'magnet:?xt=urn:btih:5305d91886084f776adcf57509a648432709a7c7&dn=x11.txt' + }, + // Picked one of the two links that were there + 'Modified-BSD':{ + 'URL': 'http://www.xfree86.org/current/LICENSE4.html', + 'Magnet link': 'magnet:?xt=urn:btih:12f2ec9e8de2a3b0002a33d518d6010cc8ab2ae9&dn=xfree86.txt' + } +} + + + +/** +* +* Runs regexes to search for explicit delcarations of script +* licenses on the argument. +* +*/ +function license_read(script_src){ + + +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/html/display_panel/content/display-panel.html b/html/display_panel/content/display-panel.html index e8345ae..8a456c8 100644 --- a/html/display_panel/content/display-panel.html +++ b/html/display_panel/content/display-panel.html @@ -47,9 +47,9 @@ <strong>LibreJS 7.0 <br><br></strong> </div> </div> - <div id="buttons" style="float:right; display:inline;" class="title-area"> - <div id="buttons-l" style="float:center;"></div> - <div id="buttons-r" style="float:right; clear: right;"></div> + <div id="buttons" style="display:inline;" class="title-area"> + <table id="buttons_table"> + </table> </div> <div id="info"> <div id="whitelisted"> diff --git a/html/display_panel/content/main_panel.js b/html/display_panel/content/main_panel.js index 54db745..3848a2e 100644 --- a/html/display_panel/content/main_panel.js +++ b/html/display_panel/content/main_panel.js @@ -69,8 +69,6 @@ function write_elements(data,name,color){ } else{ heading.innerHTML = "<h2 class='blocked-js'>List of <div style='display:inline; color:"+color+";'>" + name.toUpperCase() + "</div> javascript in " + data["url"]+":</h2>"; } - console.log(data); - console.log(data[name]); // Iterate over data[name] and generate bulleted list for(var i = 0; i < data[name].length; i++){ list.innerHTML += "<li><b>"+data[name][i][0]+ ":</b><br>" + data[name][i][1]+"\n"+button_html+"<br><br>\n"+button_html_2+"<br><br>\n"+button_html_3+"</li>"; @@ -112,12 +110,25 @@ function write_elements(data,name,color){ /** * displays the button specified by HTML string "button" */ -var num_buttons = 0; -function write_button(button,lr,callback){ - - document.getElementById("buttons-"+lr).insertAdjacentHTML("beforeend","<div id='buttonno_"+num_buttons+"'>" + button + "</div>"); - document.getElementById("buttonno_"+num_buttons).addEventListener("click",callback); - num_buttons = num_buttons + 1; +var template = '<tr><td id="c1"></td><td id="c2"></td></tr>'; +var lr_flag = true; +var button_num = 0; +function write_button(button,callback){ + var id = "buttonno_"+button_num; + if(lr_flag){ + document.getElementById("buttons_table").insertAdjacentHTML("beforeend",template); + document.getElementById("c1").insertAdjacentHTML("beforeend","<div id='"+id+"'>" + button + "</div>"); + document.getElementById("c1").id = "cell_"+button_num; + }else{ + var temp = document.getElementById("c2"); + temp.id = "cell_"+button_num; + temp.insertAdjacentHTML("beforeend","<div id='"+id+"'>" + button + "</div>"); + } + + button_num = button_num+1; + lr_flag = !lr_flag; + + document.getElementById(id).addEventListener("click",callback); } /** * update the HTML of the pop-up window. @@ -157,10 +168,16 @@ function generate_HTML(blocked_data){ if( blocked_data["blacklisted"].length != 0 || blocked_data["blocked"].length != 0 || blocked_data["whitelisted"].length != 0 || blocked_data["accepted"].length != 0){ - write_button(button_allow_all,"l",function(){console.log("button_allow_all");}); - write_button(button_block_nonfree,"r",function(){console.log("button_block_nonfree");}); - write_button(button_complain,"l",function(){console.log("button_complain");}); - write_button(button_new_tab,"r",function(){ + write_button(button_allow_all,function(){ + console.log("button_allow_all"); + }); + write_button(button_block_nonfree,function(){ + console.log("button_block_nonfree"); + }); + write_button(button_complain,function(){ + myPort.postMessage({"invoke_contact_finder": blocked_data}); + }); + write_button(button_new_tab,function(){ myPort.postMessage({"open_popup_tab": blocked_data}); }); } else{ diff --git a/main_background.js b/main_background.js index 0d8fb13..5242348 100644 --- a/main_background.js +++ b/main_background.js @@ -230,6 +230,7 @@ function connected(p) { return; } var update = false; + var contact_finder = false; if(m["whitelist"] !== undefined){ set_script(m["whitelist"][0],"whitelist"); update = true; @@ -250,14 +251,22 @@ function connected(p) { if(m["printlocalstorage"] !== undefined){ debug_print_local(); } + // invoke_contact_finder + if(m["invoke_contact_finder"] !== undefined){ + contact_finder = true; + inject_contact_finder(); + } // a debug feature (maybe give the user an option to do this?) if(m["deletelocalstorage"] !== undefined){ debug_delete_local(); } function logTabs(tabs) { + if(contact_finder){ + console.log("[TABID:"+tab_id+"] Injecting contact finder"); + inject_contact_finder(tabs[0]["id"]); + } if(update){ - // TODO: check the Firefox equivalent reserved URL pattern if(typeof(tabs[0]["url"].match(/chrome\-extension:\/\/.*display-panel\.html/g)) == "object"){ console.log("%c Not updating popup because this is a reserved page","color: red;"); |