145 Commits

Author SHA1 Message Date
Mike Samuel
1a49df26b4 Bazel plumbing to add bazel_components/polymer-resin
This is a partial roll-forward of c/106190.

It adds a dependency on the latest version of polymer-resin.
Later CLs will actually use this dependency.

Change-Id: I3cf5f9c823d74da58a8b1326153a672959fa3f13
2017-06-07 10:57:56 -04:00
Wyatt Allen
c601abccc3 Revert "Polygerrit now loads polymer-resin"
This reverts commit 0895052c01ac5ac657a9763d2ad9967d9ae55c18.

Reason for revert: issue 6387

Change-Id: I14e00addeab53606952aa3ea2d45a74eac7a9d8a
2017-06-02 09:37:37 -07:00
Mike Samuel
0895052c01 Polygerrit now loads polymer-resin
polymer-resin intercepts polymer property assignments
before they reach XSS-vulnerable sinks like `href="..."`
and text nodes in `<script>` elements.

This follows the instructions in WORKSPACE for adding a new bower
dependency with kaspern's tweak to use the dependency in a rule so
that it's found.  //lib/js/bower_components.bzl has already been
rolled-back per those instructions.

The license is the polymer license as can be seen at
https://github.com/Polymer/polymer-resin/blob/master/LICENSE though
I'm not sure that //tools/js/bower2bazel.py recognizes it as such.

Docs for the added component are available at
https://github.com/Polymer/polymer-resin/blob/master/README.md
https://github.com/Polymer/polymer-resin/blob/master/getting-started.md

With this change, when I introduce an XSS vulnerability as below,
polymer-resin intercepts and stops it.

Patch that introduces a strawman vulnerability.

--- 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
@@ -55,6 +55,10 @@
         url: '/q/status:abandoned',
         name: 'Abandoned',
       },
+      {
+        url: location.hash.replace(/^#/, '') || 'http://example.com/#fragment_echoed_here',
+        name: 'XSS Me',
+      },
     ],
   }];

---

Address kaspern's and paladox's comments.

---

Undo version bumps for bower dependencies.

---

Change Soy index template to parallel app/index.html.

---

update polymer-resin to version 1.1.1-beta

----

Load polymer-resin into polygerrit-ui/**/*_test.html

After this, I ran the tests with
  -l chrome
  -l firefox

I ran a handful of tests with -p and observed that the
console shows "initResin" is called before test cases start
executing.

These changes were done programmaticly by running the script below
(approximately) thus:
```
gerrit/ $ cd polygerrit-ui/app
app/ $ find . -name \*test.html | xargs perl hack-tests.pl
```

```
use strict;

sub removeResin($) {
  my $s = $_[0];
  $s =~ s@<link rel="import" href="[^"]*/polymer-resin/[^"]*"[^>]*>\n?@@;
  $s =~ s@<script src="[^"]*/polymer-resin/[^"]*"></script>\n?@@;
  $s =~ s@<script>\s*security\.polymer_resin.*?</script>\n?@@s;
  return $s;
}

for my $f (@ARGV) {
  next if $f =~ m@/bower_components/|/node_modules/@;

  system('git', 'checkout', $f);
  print "$f\n";

  my @lines = ();
  open(IN, "<$f") or die "$f: $!";
  my $maxLineOfMatch = 0;
  while (<IN>) {
    push(@lines, $_);
    # Put a marker after core loading directives.
    $maxLineOfMatch = scalar(@lines)
      if m@/webcomponentsjs/|/polymer[.]html\b|/browser[.]js@;
  }
  close(IN) or die "$f: $!";

  die "$f missing loading directives" unless $maxLineOfMatch;

  # Given ./a/b/c/my_test.html, $pathToRoot is "../../.."
  # assuming no non-leading . or .. components in the path from find.
  my $pathToRoot = $f;
  $pathToRoot =~ s@^\.\/@@;
  $pathToRoot =~ s@^(.*?/)?app/@@;
  $pathToRoot =~ s@\/[^\/]*$@@;
  $pathToRoot =~ s@[^/]+@..@g;

  my $nLines = scalar(@lines);
  open(OUT, ">$f") or die "$f: $!";

  # Output the lines up to the last polymer-resin dependency
  # loaded explicitly by this test.
  my $before = join '', @lines[0..($maxLineOfMatch - 1)];
  $before = removeResin($before);
  print OUT "$before";

  # Dump out the lines that load polymer-resin and configure it for
  # polygerrit.
  if (1) {
      print OUT qq'<link rel="import" href="$pathToRoot/bower_components/polymer-resin/standalone/polymer-resin-debug.html"/>
<script>
security.polymer_resin.install({allowedIdentifierPrefixes: [\'\']});
</script>
    ';
  }

  # Emit any remaining lines.
  my $after = join '', @lines[$maxLineOfMatch..$#lines];
  $after = removeResin($after);
  $after =~ s/^\n*//;
  print OUT "$after";

  close(OUT) or die "$f: $!";
}
```

---

update polymer-resin to version 1.2.1-beta

---

update Soy index template to new style polymer-resin initialization

----

fix lint warnings

----

Load test/common-test-setup.html into *_test.html

Instead of inserting instructions to load and initialize polymer-resin into
every test file, add a common-test-setup.html that does that and also fold
iron-test-helpers loading into it.

----

imported files do not need to load webcomponentsjs

Change-Id: I71221c36ed8a0fe7f8720c1064a2fcc9555bb8df
2017-05-30 23:16:09 -04:00
David Pursehouse
12cdfc4ae9 Add comment and TODO in WORKSPACE about org.apache.httpcomponents versioning
Change-Id: Ic139cc518b5ebb982ad571e6426491c08324f4d4
2017-05-11 10:45:04 +09:00
David Pursehouse
59d4297e6f Upgrade joda-time to 2.9.9
Change-Id: Id424e27829ecfec8dd73ae00061369418ebb9916
2017-05-11 10:34:59 +09:00
David Ostrovsky
0a6b9eab13 PolyGerrit: Make ES6 to ES5 transpilation actually work
Bump rules_closure version to this commit[1], that allows us to pass
--force_inject_library=es6_runtime to closure compiler, that fixes
missing injection of ES6 dependency with optimization level whitespace.

One side effect of this change: because of the recently made change in
rules_closure rules of how the external dependencies are consumed, we
cannot reuse some common dependencies that were already fetched during
gerrit build and must re-fetch them again, most notably:

* asm
* gson
* guava
* guice
* soy

The bad news here is, that re-fetching takes place with rules_closure's
java_import_external rule, that is not using our own download_file.py
utility and thus the artifacts are not cached in ~/.gerritcodereview
directory, so that when the build is repeated on the same machine but on
different clone of gerrit repository all rules_closure dependencies
are going to be re-fetched again.

Another complication of re-fetching is that the different versions of
the artifacts are now fetched: e.g. Gerrit is using guava 21, and
closure rule is using guava 20. The reason why we don't have the
collision here is because gerrit mounts this dependency under @guava
directory, whereas rules_closure is using canonical artifact name, so
that we get:

* external/com_google_guava/guava-20.0.jar # fetched by rules_closure
* external/guava/jar/guava-21.0.jar # fetched by gerrit

Test Plan:

1. conduct ES6 modification, e.g. apply this CL: [2]
2. run bazel build gerrit
3. verify that transpiled code actually work

[1] f68d4b5a55
[2] https://gerrit-review.googlesource.com/105104

Bug: Issue 6110
Change-Id: I3f3adf8ce5e613d45d1d0684b823e48e68a14080
2017-05-09 19:36:19 +00:00
David Pursehouse
136b1a2306 Upgrade GWT to 2.8.1
Version 2.8.1 includes several bug fixes.  See the release notes [1]
for details.

[1] http://www.gwtproject.org/release-notes.html#Release_Notes_2_8_1

Change-Id: I328be6c48c50822ca7b497c12dcab3ec890274ae
2017-05-09 11:49:13 +00:00
David Pursehouse
dea7545ddb Update lucene to 5.5.4 and Elasticsearch to 2.4.5
Lucene version 5.5.4 includes several bug fixes [1].

We need to upgrade Elasticsearch at the same time because it has a hard
runtime dependency on the Lucene version. Version 2.4.5 of Elasticsearch
uses Lucene 5.5.4.

[1] https://lucene.apache.org/core/5_5_4/changes/Changes.html

Change-Id: I03bf09c1170db2a57b2e90722898920c2fbe4aaf
2017-04-28 12:38:57 +00:00
Kasper Nilsson
1ea918bd36 Add transpilation to PolyGerrit
Utilize the Closure compiler in Bazel to transpile. As part of this, a
rather large file of 'externs' must be added in order to call external
code. This file is specific to Polymer and copied from the Closure
Github, and should be synced any time there are major changes to
Polymer.

Test Plan:

  - run `bazel build polygerrit` and verify that whitespaces are removed
    from resulting gr-app.js file
  - run `bazel build Documentation:licenses.txt` and verify that the new
    dependency is listed in resulting
    bazel-genfiles/Documentation/licenses.txt

TODO in later changes:
  - Get closure optimizations working
  - Explore sourcemaps possibilities
  - Maybe use closure linting?

Change-Id: Ic358743dda7286fea3ac1e95a7991a92c96d6341
2017-04-26 13:58:50 +02:00
David Pursehouse
74148bc485 Merge "Update web-component-tester to 5.0.1" 2017-04-25 08:05:49 +00:00
Paladox none
23f18ade43 Update web-component-tester to 5.0.1
See changelog at https://github.com/Polymer/web-component-tester/blob/master/CHANGELOG.md#501 please

Change-Id: If5772b898fa7f3e796cbe11933159c73067d5bd7
2017-04-25 07:15:19 +00:00
Paladox none
85f9261f3b Update polymer to 1.9.1
Please see changelog at

1.9.1: https://github.com/Polymer/polymer/releases/tag/v1.9.1

1.9.0: https://github.com/Polymer/polymer/releases/tag/v1.9.0

1.8.1: https://github.com/Polymer/polymer/releases/tag/v1.8.1

1.8.0: https://github.com/Polymer/polymer/releases/tag/v1.8.0

Change-Id: I073b0adbb804a03c716448ec9f9c5ee0122480f8
2017-04-25 07:14:44 +00:00
David Pursehouse
3367b51069 Fix comment in WORKSPACE about easymock version
It looks like part of the comment got lost when migrating the
build from Buck to Bazel.

Change-Id: I8499e466dfa93663a5e36cf12d67b90d905591be
2017-04-21 16:18:23 +02:00
David Pursehouse
260a3c6668 Upgrade auto-value to 1.4.1
According to the release notes [1] the only difference from 1.4 is
removal of a workaround for an Eclipse bug.

[1] https://github.com/google/auto/releases/tag/auto-value-1.4.1

Change-Id: I0de46865ce52cf4fb5f3dde218209fbcace5d18d
2017-04-21 16:04:55 +02:00
ekempin
8659a05503 Merge "Merge branch 'stable-2.14'" 2017-04-11 08:21:01 +00:00
David Pursehouse
87d02830cf Merge "Upgrade commons-validator to 1.6" 2017-04-11 07:39:33 +00:00
David Pursehouse
bee6b2763b Merge branch 'stable-2.14'
* stable-2.14:
  PluginLoader: Remove stale plugin files from /tmp on startup
  Format Java files with google-java-format
  Update blame-cache to 0.2-1
  Set version to 2.13.8
  Upgrade JGit to 4.5.2.201704071617-r

Change-Id: Ia27737010984ba58ff74c844aa252d9b7adffbad
2017-04-11 16:12:06 +09:00
David Pursehouse
7608de0aa2 Update blame-cache to 0.2-1
Change-Id: If6507cea23bca1fcfa39fa941c3b8eb51e2d09da
2017-04-10 09:27:09 +09:00
Dave Borowitz
d69ac8e8c2 Upgrade juniversalchardet
v1.0.3 is 5+ years old and no longer receiving updates. Switch to a
supported version. We make only minimal use of this library and the
usage we do have is backwards compatible.

Change-Id: Ibbbd49a806b1df312f2166faa38fc519113b6b38
2017-04-08 13:02:52 -04:00
David Pursehouse
e890117b1c Merge branch 'stable-2.14'
* stable-2.14:
  Upgrade Jetty to 9.3.17.v20170317

Change-Id: I2f18197b9700dea66d7c98a40dd9c97bc7928860
2017-04-05 22:13:13 +09:00
David Pursehouse
3ede86cb2e Upgrade Jetty to 9.3.17.v20170317
This aligns Gerrit with the version of Jetty used in JGit since [1].

[1] https://git.eclipse.org/r/#/c/94257/

Change-Id: I5c847d30476862d879df4508e8cc51489cd3389c
2017-04-05 08:31:24 +00:00
David Pursehouse
83c085573d Upgrade commons-validator to 1.6
Version 1.6 upgrades the TLD list to version 2017020400 [1].

The version available at the IANA site [2] at the time of writing
this commit is 2017032102. Prior versions are not provided. Update
the test data to this later version, commenting out the only TLD
that is not supported in 2017020400 ("AFRICA").

[1] fe29c2dd86
[2] http://data.iana.org/TLD/tlds-alpha-by-domain.txt

Change-Id: I2fb3fbc6e4db205d0a1aafdbc6b73a91b2e844ed
2017-04-04 05:06:42 +00:00
David Pursehouse
2d9d71f6c6 Merge branch 'stable-2.14'
* stable-2.14:
  SSHD: Exclude SFTP file system provider

Change-Id: I7e91a531cb63ef5c13c176823445d379297d2e11
2017-04-03 16:05:21 +09:00
David Ostrovsky
06892ace70 SSHD: Exclude SFTP file system provider
In SSHD 1.4 security providers infra-structure was overhauled in order
to add support for pluggable providers. It's possible that regressions
were introduced or some kind of class loading race conditions.

Since the upgrade Gerrit cannot be started when file systems with zip
PolyGerrit fonts and bower components are used. Given that Gerrit code
doesn't depend on supporting sftp://xxxx URLs' we can exclude the file
system provider. Once this upstream issue: [1] is fixed, we can remove
the exclusion again.

[1] https://issues.apache.org/jira/browse/SSHD-736

Bug: Issue 5905
Change-Id: Ib273ae50924c26949b037d9f2419471209c6ad36
2017-04-03 05:54:09 +00:00
David Pursehouse
405f39df4d Merge branch 'stable-2.14'
* stable-2.14:
  WORKSPACE: Remove redundant comment about BouncyCastle version

Change-Id: Ic8cf73ac43ee7b03855840729f481f73c8c3e625
2017-03-29 16:25:23 +09:00
David Pursehouse
01a139b2e9 WORKSPACE: Remove redundant comment about BouncyCastle version
BouncyCastle is now bundled in the release war file, and is no longer
included in libraries.config.

Change-Id: Ie2b76630676f11998166148d80ee7548bc61c583
2017-03-29 05:36:55 +00:00
Paladox
13dd034acf Merge branch 'stable-2.14'
* stable-2.14:
  Add support for elliptic curve/ed25519 SSH keys

Change-Id: I6d7472ca9d2eda4d7e6feef9168756cb474285c2
2017-03-28 20:42:03 +01:00
Paladox none
f2d4fac3f3 Add support for elliptic curve/ed25519 SSH keys
Adds a dependency on net.ip2.crypto.eddsa, which is released under
the CC0 1.0 Universal license [1].

[1] https://github.com/str4d/ed25519-java/blob/master/LICENSE.txt

Feature: Issue 4507
Change-Id: Icab3a3e367b69c14132f0cc9478a84ebb9df834c
2017-03-28 15:26:29 +00:00
David Pursehouse
6cbae560fa Merge branch 'stable-2.14'
* stable-2.14:
  Bump Mina core to 2.0.16 and sshd to 1.4

Change-Id: I9184620c384325ae1ffc88c0ebf4ba0e009bc6d9
2017-03-28 08:16:27 +09:00
David Ostrovsky
12c48938cd Bump Mina core to 2.0.16 and sshd to 1.4
This release moves to Java 8 and fixes various bugs. See the sshd-core
release notes [1] and mina-project page [2] for details.

[1] https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12310849&version=12338322
[2] https://mina.apache.org/mina-project/

Change-Id: I5df8540fa96f91126ccd45446a070f2000436b15
2017-03-27 15:55:03 +00:00
David Pursehouse
58b40f1632 Upgrade pegdown to 1.6.0
Change-Id: Id764e2df463db8784f7bfe564856bf405223474c
2017-03-24 11:27:31 +00:00
David Pursehouse
75892593ce Upgrade joda-time to 2.9.8
Change-Id: I0f41984ccb9061c78360f0c779130ec7d8de9c1f
2017-03-24 11:27:12 +00:00
David Pursehouse
ee1a51e013 Merge branch 'stable-2.14'
* stable-2.14:
  Upgrade metrics-core to 3.2.2
  ArchiveFormat: Don't use deprecated ArchiveCommand.Format#putEntry
  Upgrade JGit to 4.6.1.201703071140-r.149-g61f830d3a
  Simplify local JGit development
  Consume JGit from development tree: Add missing dependency

Change-Id: I11641b024e9e141f6ef119d9a4300dbb316f13b4
2017-03-24 14:54:04 +09:00
David Pursehouse
aae6da8e91 Upgrade commons-compress to 1.13
Change-Id: I96caeb81f4dff131262ffb9ede604550abf63b4b
2017-03-24 05:43:59 +00:00
David Pursehouse
ce1fa4d9a4 Merge changes Icabf651e,I0fd16c26 into stable-2.14
* changes:
  Simplify local JGit development
  Consume JGit from development tree: Add missing dependency
2017-03-24 05:42:31 +00:00
David Pursehouse
6cb616e0ad Upgrade metrics-core to 3.2.2
This fixes a couple of bugs since 3.2.1

Change-Id: If7c3148679a07299d05a3574dc4d825cbe2a717c
2017-03-24 11:18:13 +09:00
David Pursehouse
9bc76521e1 Merge branch 'stable-2.14'
* stable-2.14:
  Fix error in file-list setReviewedFiles logic
  Upgrade auto-value to 1.4

Change-Id: I3843189e90a6fd1dbb0a6495df027b1ac36ab916
2017-03-24 09:10:41 +09:00
Han-Wen Nienhuys
fe81f93215 Simplify local JGit development
Put all the logic in jgit.bzl, where a single edit suffices to get
the local flavor.

Given that all sha1 for jgit dependencies are in jgit.bzl, we can
remove the constants and use sha1 values directly.

Change-Id: Icabf651e02f226e5c025457d54588074a11ae283
2017-03-24 08:36:18 +09:00
David Ostrovsky
ca0587bcbe Consume JGit from development tree: Add missing dependency
To run the tests, hamcrest_library is needed for jgit project and
because of this issue: [1], bazel tries to resolve this external
dependency in gerrit project. Add hamcrest library to WORKSPACE file.

Test Plan:

* switch to using JGit from the development tree
* run the tests:

  bazel test --define jgit-dev=1 //...

[1] https://github.com/bazelbuild/bazel/issues/2391
Change-Id: I0fd16c26a6048aa1c852cf097cfca4ab230d0496
2017-03-24 08:36:12 +09:00
David Pursehouse
1a8d460653 Upgrade commons-codec to 1.10
Change-Id: I1342d79247fe42cbc39d8e229e3f243b633fb032
2017-03-23 23:30:32 +00:00
Han-Wen Nienhuys
ccb26667ba Simplify local JGit development
Put all the logic in jgit.bzl, where a single edit suffices to get
the local flavor.

Given that all sha1 for jgit dependencies are in jgit.bzl, we can
remove the constants and use sha1 values directly.

Change-Id: Icabf651e02f226e5c025457d54588074a11ae283
2017-03-23 21:46:55 +01:00
David Ostrovsky
b1040c8526 Merge "Consume JGit from development tree: Add missing dependency" 2017-03-23 19:53:14 +00:00
David Pursehouse
14d009e036 Upgrade auto-value to 1.4
Change-Id: I942a7623e78b747af7743944aeede44ee278e2c1
2017-03-23 11:11:41 +00:00
David Ostrovsky
967ba953d4 Consume JGit from development tree: Add missing dependency
To run the tests, hamcrest_library is needed for jgit project and
because of this issue: [1], bazel tries to resolve this external
dependency in gerrit project. Add hamcrest library to WORKSPACE file.

Test Plan:

* switch to using JGit from the development tree
* run the tests:

  bazel test --define jgit-dev=1 //...

[1] https://github.com/bazelbuild/bazel/issues/2391
Change-Id: I0fd16c26a6048aa1c852cf097cfca4ab230d0496
2017-03-23 07:38:52 +01:00
David Pursehouse
d786b5cf79 Upgrade gson to 2.8.0
Change-Id: If745228181fce478e562d78fe354109a4e76f3bb
2017-03-23 14:03:19 +09:00
Dave Borowitz
c81ad3135a Merge "Update codemirror to 5.25.0" 2017-03-23 01:18:05 +00:00
Paladox none
d1dab17ce4 Update codemirror to 5.25.0
See release notes at https://codemirror.net/doc/releases.html

Change-Id: Ia55811afecc9bc6c2fcf0a0edaa9a35b05152ae4
2017-03-22 21:44:40 +00:00
David Ostrovsky
e51b745efa Bazel: Allow to consume jgit from development tree
Now that Bazel build for JGit is fully implemented, we can document
the process of routing the JGit dependency to the development tree
instead of consuming it from Central or ~/.m2 local repository:

1. Activate local jgit repository in WORKSPACE file:

  local_repository(
      name = "jgit",
      path = "/home/<user>/projects/jgit",
  )

2. Uncomment alias to jgit repository in lib/jgit/**/BUILD files.
It shouldn't be needed and is tracked under this issue upstream: [1]:

  alias(
      name = "jgit-alias",
      actual = select({
          "@//lib:jgit-dev": "@jgit//org.eclipse.jgit:jgit",
          "//conditions:default": "@jgit_lib//jar",
      }),
      visibility = ["//visibility:public"],
  )

Test plan:

Update local JGit tree, run tests and verify that local JGit tree
modifications are relfected in gerrit build:

  $ bazel build --define jgit-dev=1 headless

To consume JGit from Central, do not pass jgit-dev=1:

  $ bazel test ...

[1] https://github.com/bazelbuild/bazel/issues/2707
Change-Id: I1b0fee7df802f6cbd54acbb0bc73157e2b8bc7cf
2017-03-22 22:27:12 +01:00
David Pursehouse
de2b137664 Merge "Upgrade metrics-core to 3.2.1" 2017-03-20 12:05:29 +00:00
David Pursehouse
ac5f4426cf Upgrade Jest to 2.4.0
Change-Id: I7c1d2f8fc88d6626194f431a96bed2d2769b3db1
2017-03-18 13:54:20 +09:00