gerrit/gerrit-httpd
Mike Samuel 5ee6971a61 Integrates polymer-resin into polygerrit-ui
This is attempt 3 at rolling-forward c/106190

New Dependency
==============
This adds polymer-resin as a bower archive.
See `bower info polymer-resin\#1.2.6-beta` for details.
Polymer-resin is part of the larger polymer project so is
license compatible.

Integration
===========
The main application element, app/elements/gr-app.html, now HTML
imports polymer-resin per
github.com/Polymer/polymer-resin/blob/master/getting-started.md#loading
It uses the following configuration:
1. All dynamic IDs are allowed.
2. Policy violation reports are sent to the dev console.

test/common-test-setup.html does the same so that tests are run in the
same environment.

Testing
=======
1.  Running local tests
    gerrit $ ./polygerrit-ui/app/run_tests.sh
    With 1.2.6-beta tests run green on (Chrome, Firefox, Safari).
2.  Testing for false positives
    I ran two servers.
    a. polygerrit-ui/run_server.sh
    b. gerrit.war per https://git.eclipse.org/r/Documentation/dev-readme.html
    I noticed that in both the dev console showed 'initResin' early and
    paging around showed no violation reports.
3.  Testing for true negatives
    I patched in the diff at the end of this description, and reran
    both server environments.
    I noted that browsing to localhost:8081/#javascript:alert(1)
    and localhost:8080/#javascript:alert(1) both showed a
    violation report about javascript:alert(1) being rejected.
    Clicking Changes / XSS did not result in a popup.

Differences
===========
This loads the non-debug version but configured with a console reporter
so should minimize code size and speed overhead.
This loads via gr-app so the input is automatically vulcanized.

--- a/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js
+++ b/polygerrit-ui/app/elements/core/gr-main-header/gr-main-header.js
@@ -56,6 +56,11 @@
         url: '/q/status:abandoned',
         name: 'Abandoned',
       },
+      {  // HACK DO NOT SUBMIT
+        url: (location.hash && location.hash.replace(/^#/, ''))
+            || '/echoes_hash',
+        name: 'XSS',
+      },
     ],
   }];
--- a/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.js
+++ b/polygerrit-ui/app/elements/shared/gr-dropdown/gr-dropdown.js
@@ -93,6 +93,7 @@
     },

     _computeRelativeURL(path) {
+if (path && /^\w+\:/.test(path)) { return path; }  // HACK DO NOT SUBMIT
       const host = window.location.host;
       return this._computeURLHelper(host, path);
     },

Change-Id: I38bfa124abd4fb35972833f29fc1664ec2404e34
2017-06-26 10:45:10 -07:00
..
src Integrates polymer-resin into polygerrit-ui 2017-06-26 10:45:10 -07:00
BUILD Serve PolyGerrit index.html from a Soy template 2017-04-03 18:12:54 +00:00