From ada88090ead2c3b9d0804794c5f20f9b24d1c2b1 Mon Sep 17 00:00:00 2001 From: Nik Nyby Date: Sat, 17 Jan 2015 17:12:36 -0500 Subject: Import to new git repository The old repository was using almost 100mb of space because of all the unnecessary files in the history. So I've imported the code to a new git repository. Unfortunately the history isn't viewable from this repository anymore. To see what happened with LibreJS before 2015, see the old Bazaar repo here: http://bzr.savannah.gnu.org/lh/librejs/ --- doc/librejs.texi | 878 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 878 insertions(+) create mode 100644 doc/librejs.texi (limited to 'doc/librejs.texi') diff --git a/doc/librejs.texi b/doc/librejs.texi new file mode 100644 index 0000000..2ff6271 --- /dev/null +++ b/doc/librejs.texi @@ -0,0 +1,878 @@ +\input texinfo @c -*-texinfo-*- +@c %**start of header +@setfilename librejs.info +@include version.texi +@settitle GNU LibreJS @value{VERSION} + +@copying +This manual is for GNU LibreJS (version @value{VERSION}, @value{UPDATED}), +a GNU IceCat extension to detect and block nonfree nontrivial +JavaScript on webpages. + +Copyright @copyright{} 2011 2012 2014 Loic J. Duros + +@quotation +Permission is granted to copy, distribute and/or modify this document +under the terms of the GNU Free Documentation License, Version 1.3 or +any later version published by the Free Software Foundation; with no +Invariant Sections, with no Front-Cover Texts, and with no Back-Cover +Texts. A copy of the license is included in the section entitled +``GNU Free Documentation License''. +@end quotation +@end copying + +@dircategory GNUzilla +@direntry +* LibreJS: (librejs). Detect nonfree nontrivial in GNU Icecat +@end direntry + +@titlepage +@title GNU LibreJS +@subtitle for version @value{VERSION}, @value{UPDATED} +@author Loic J. Duros (@email{librejs@@lduros.net}) +@page +@vskip 0pt plus 1filll +@insertcopying +@end titlepage + + +@contents + + +@node Top +@top LibreJS +This manual is for GNU LibreJS (version @value{VERSION}, @value{UPDATED}). + +@menu +* Overview:: General purpose and information. +* Disclaimer:: Emphasize what LibreJS does and does not. +* Installation:: Installing LibreJS from source. +* How to Use:: How to use LibreJS in IceCat. +* JavaScript Detection:: How LibreJS detects nontrivial Javascript. +* Free Licenses Detection:: List of licenses detected by LibreJS. +* Setting Your JavaScript Free:: Information for website owners/maintainers. +* Installation Requirements:: Requirements to build and install LibreJS. +* LibreJS Internals:: How LibreJS works under the hood. +* Tests:: Test LibreJS and better understand it. +* GNU Free Documentation License:: Copying and sharing this documentation. +@end menu + +@node Overview +@chapter Overview + +@cindex overview +GNU LibreJS ---an add-on for GNU IceCat and Mozilla Firefox--- detects +and blocks nonfree nontrivial JavaScript while allowing its execution on +pages containing code that is either trivial and/or free. + +Many websites run nontrivial JavaScript on your computer. Some use it +for complex tasks; many use it gratuitously for minor jobs that could be +done easily with plain HTML. Sometimes this JavaScript code is +malicious. Either way, the JavaScript code is often nonfree. For +explanation of the issue, see "The JavaScript +Trap"(@url{http://www.gnu.org/philosophy/javascript-trap.html}). + +If you care about freedom in your computing, and don't wish to let all +and sundry make you run nonfree programs, now you can prevent it by +using LibreJS. + + +@node Disclaimer +@chapter Disclaimer + +@cindex disclaimer + +@itemize @bullet +@item +LibreJS is not a security tool. Its goal is to detect nonfree nontrivial +JavaScript, and it currently does not detect whether free or trivial +code is malicious or not. Other free Mozilla extensions and add-ons may +be available for this purpose. + +@item +LibreJS is always a work in progress. If you find a bug, please report +it to @email{bug-librejs@@gnu.org}. + +@end itemize + +@node Installation +@chapter Installation +@cindex Installation + +You can install LibreJS directly using a generated @file{librejs.xpi} +file, or by building it from source. + + +@section Building the Package +After enabling the Add-on SDK, you should be able to use the @code{make} +command to build LibreJS from source. + +After running @code{make}, a new file, @file{librejs.xpi} should be +generated. This is the file that can be installed in a Mozilla browser. + +@section Installing LibreJS +To install the add-on for all users, run: +@example +sudo make install +@end example + +or as root: +@example +make install +@end example + +Next time you open a Mozilla-browser as a user of your system, you +should be notified that a new add-on (in this case, LibreJS) as been +installed and whether to allow it to run or not. + +@node How to Use +@chapter How to Use + +@section LibreJS in action + +After installing the add-on, you will see the LibreJS widget in the +add-on bar at the bottom of the browser window. After loading a page, +left-click on the widget to view the deactivated JavaScript code from +the page (both on page and external) and, if applicable, the scripts +that were accepted. + +@section Complaint Feature + +It is very important to complain when a site has nonfree JavaScript +code, especially if it won't work without that code. LibreJS makes it +easy to complain by heuristically finding where to send the complaint. + +When nonfree/nontrivial code is detected in a page, LibreJS attempts to +find a relevant contact link or email for the website you are +visiting. In order to do so, it will attempt to visit a few links from +the current page (for instance, a link labeled ``contact'' on the same +domain as the current page, @dots{}) + +LibreJS detects contact pages, email addresses that are likely to be +owned by the maintainer of the site, Twitter and identi.ca links, and +phone numbers. + +After LibreJS detects any of the above, a ``Complain'' tab will appear +on the right of your web browser. When you click on this tab, a large +panel will appear with contact information. Ideally, at the top you will +find the email address of the maintainer, labeled as the ``Email you +should use''. + +When you complain to the website for their nonfree nontrivial +JavaScript, provide them with the link to the JavaScript Trap essay so +that they can get more information on what the issue is and how they can +solve it on their own site. + +LibreJS includes a default subject line and body for the complaint email, +with a link to the JavaScript Trap essay. This can be configured in the +LibreJS add-on preferences in your web browser. + + +@section Options + +@table @dfn +@item Whitelist +LibreJS lets you whitelist domain names and subdomains to bypass the +regular JavaScript check. This might be useful, for example, if you are +running your own code in a local web server. In order to add a +whitelisted domain or url, go to Tools >> Add-ons, or press @kbd{Control ++ Shift + A}. Inside the add-on window, click on @dfn{Extensions}, and in +the list, where you see LibreJS, click on the @dfn{Preferences} button. +You will see an input field labeled @dfn{Whitelist}. In the field, +enter comma-separated domain names. Do not enter the protocol. For +instance to whitelist all the pages of @url{http://www.gnu.org} and +@url{https://gnu.org}, enter @samp{gnu.org}. To allow all subdomains from +gnu.org, enter: @samp{*.gnu.org}. This will match such sites as +@url{http://savannah.gnu.org} and @url{http://audio-video.gnu.org}. + +@item Complaint tab +This specifies whether the complaint tab appears when a site is running +nonfree JavaScript. + +@item Display notifications of JavaScript analysis +This option enables an info bar of realtime JavaScript analysis. + +@item Complaint email subject +Configure the default subject used in complaint emails. + +@item Complaint email body +Configure the default body used in complaint emails. +@end table + +@node JavaScript Detection +@chapter JavaScript Detection +@cindex javascript + +@itemize +LibreJS considers JavaScript on a page nontrivial if any of the +following are true: + +@item +It makes an AJAX request or is loaded along with scripts that make +an AJAX request, + +@item +It loads external scripts dynamically or is loaded along with +scripts that do, + +@item +It defines functions or methods and either loads an external script +(from HTML) or is loaded as one, + +@item +It uses dynamic JavaScript constructs that are difficult to analyze +without interpreting the program or is loaded along with scripts +that use such constructs. These constructs are: +@itemize +@item +Using the eval function +@item +Calling methods with the square bracket notation +@item +Using any other construct than a string literal with certain methods +(@code{Obj.write}, @code{Obj.createElement}, @dots{}). +@end itemize +@end itemize + +In practice, the JavaScript code in your page may be found trivial by +LibreJS if, as a whole: +@itemize @bullet + +@item +It does not define functions and it does not load external scripts +(with the HTML src attribute in a @code{ + +@end example + +While @code{$.doSomething();} may seem trivial, you will nevertheless +have to add a stylized license comment on your main HTML page because +the external script (in this case jQuery) has been found to define +methods that make AJAX calls. @code{$.doSomething()} might make an AJAX call, +and LibreJS does not check for that. The rule of thumb is that when you +use a library or code that handles AJAX, JSON, JSONP, the loading of +scripts dynamically, you should have license mentions for all your +JavaScript files and for your main page regardless. In practice this is +a case that happens very often with code that uses libraries. + +In practice also, the JavaScript code in an external file (an external +@file{.js} file loaded on your page) may be found trivial if it does not +define functions/methods. + +And in the same manner it will be considered nontrivial if AJAX calls, +dynamic script loading, or non-obvious dynamic JavaScript constructs +are used in another script. + +If your JavaScript code makes AJAX requests, it's important to get an +accurate @dfn{Content-Type} in the response from the server. For +example, if you're using JSON, set it to @code{application/json}. +This is because LibreJS alters the content of @code{text/html} +responses. + +@node Free Licenses Detection +@chapter Free Licenses Detection +@cindex freelicenses + +@section Detected Free Licenses + +In order for a file to be detected as free, the license notice should +appear in a JavaScript file above all code, at the very top of the file. + +For inline JavaScript code inside @code{