793 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
Matthias Sohn
8006d21b24 Update JGit to 4.8.0.201705170830-rc1
Change-Id: I005421e8f06e59186a59a29649f878c3f845a218
2017-05-21 06:00:11 +00:00
David Pursehouse
4042d43567 Merge branch 'stable-2.14'
* stable-2.14:
  Bazel: Allow plugins to non-transitively depend on prolog rules

Change-Id: I6d9c7e4795249ab8c97fb064f0ebb2dd5aee8ef1
2017-05-17 19:48:49 +09:00
David Ostrovsky
b9400254a6 Bazel: Allow plugins to non-transitively depend on prolog rules
Some plugins, most notably owners-plugin, depend on prolog:common rule.
Given that this rule transitively depends on gerrit-server:server rule,
and this rule depends on virtually whole gerrit build graph, the final
plugin artifact contains effectively the whole gerrit war file content.

To fix that we expose prolog:common in plugin API. Moreover, adjust
prolog_cafe_library to not transitively depend on prolog runtime
library. We can do it, because gerrit-server already depends on it, so
that it's included in gerrit war anyway.

This change allows the owners-plugin to de-duplicate its size from 45 MB
to 1.5 MB only.

Change-Id: I8d7198a911c2da444c1822509988eda7d369af77
2017-05-17 08:51:13 +02:00
David Ostrovsky
a3844fca7f Bazel: Simplify prolog_cafe_library rule implementation
genrule2 exposes root and temp directpries, but these are not used in
this rule, so that we can just use native genrule.

Change-Id: Id1e56ba47bf04a73559ff84a7c8f69745a6b3129
2017-05-17 06:23:51 +02:00
Kasper Nilsson
c78fb72fd9 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
(cherry picked from commit 1ea918bd367c091fb4128ab33d8ca7c61cfe770c)
2017-05-15 17:00:01 +09:00
David Pursehouse
9cbfae0ada Merge branch 'stable-2.14'
* stable-2.14:
  ReviewersUtil: Fix candidate list multiplier comment
  Replace FileInputStream and FileOutputStream with static Files methods

Change-Id: I5c4e04457b680db7709c522f17cfef1bef91a60f
2017-05-10 15:47:26 +09:00
Hector Oswaldo Caballero
db21e3add0 Replace FileInputStream and FileOutputStream with static Files methods
FileInputStream and FileOutputStream rely on finalize() method to ensure
resources are closed. This implies they are added to the finalizer queue
which causes additional work for the JVM GC process.

This is an open bug on the OpenJDK [1] and the recommended workaround is
to use the Files.newInputStream and Files.newOutputStream static methods
instead.

[1] https://bugs.openjdk.java.net/browse/JDK-8080225

Change-Id: I3cef6fcf198dde2be7cd15bded8d2fa247177654
2017-05-10 00:10:52 +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
9159985f93 Merge "Remove misleading variable from ES dependency file" 2017-04-25 08:05:59 +00:00
Dariusz Luksza
36f85512a5 Remove misleading variable from ES dependency file
VERSION variable is not used any more in the ElasticSearch dependency
file, therefore we can remove it.

Change-Id: I0e9ed69a69976606d5db5e832023e85b5a06f4f1
2017-04-25 07:49:47 +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
Dave Borowitz
c204fa11b3 Update JGit to 4.7.0.201704051617-r.37-gc80d8c590
Change-Id: Ic77a2c7bb9bc63dd7358460fe978417a61210770
2017-04-13 10:34:00 -04:00
David Pursehouse
f7d49955cf Merge branch 'stable-2.14'
* stable-2.14:
  Don't ship bouncycastle libraries in plugin API

Change-Id: I2cecc4784c1821a89313bf71b998943df0a449cc
2017-04-10 08:21:56 +09:00
David Ostrovsky
c5f8066629 Don't ship bouncycastle libraries in plugin API
We cannot shade bouncycastle in the plugin API. Still we need it to be
included in the gerrit.war, licenses file and Eclipse classpath.

Expose bouncycastle libraries in PLUGIN_TEST_DEPS constant, so that
the plugins don't need to change anything in tree build mode.

gerrit_api() bazlet in bazlets repository is extended too, so that the
plugins don't need to change anything in standalone build mode.

One side effect of this change, is that bouncycastle libraries are
now listed with neverlink suffix, e.g.:

* bouncycastle:bcprov-neverlink

Bug: Issue 5826
Change-Id: Idb8051e16b14e20c8dd528783ab297ee25707bb3
2017-04-07 07:38:04 +02:00
David Pursehouse
d8fd6e1592 Upgrade JGit to 4.7.0.201704051617-r
Change-Id: Ia8a5ebcf4bb55263391476f865c34869e2deee14
2017-04-07 01:31:26 +09:00
David Pursehouse
8d2b2bb95c Upgrade JGit to 4.7.0.201704051617-r.15-gc4e952109
Change-Id: I8b06fbc23593cff99f8b8cef9992a935cbbe90ee
2017-04-06 11:20:21 +09:00
David Pursehouse
fa8988fc8e Upgrade JGit to 4.6.1.201703071140-r.169-g61e336475
This is a snapshot of the latest head of JGit's master branch.

Jetty was changed to version 9.3.17.v20170317.  This version change
will be done for Gerrit in a follow-up commit.

Change-Id: I19ca866f90b16260f72fdd9cdc97683031b48488
2017-04-03 16:07:58 +09:00
David Pursehouse
6558e4d048 Format lib/mina/BUILD with buildifier
Change-Id: I2b18780cf7ebcd5f0bb962935c0e811f0fb19eea
2017-03-30 17:31:27 +09: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
a01b395773 Upgrade JGit to 4.6.1.201703071140-r.149-g61f830d3a
This snapshot includes numerous changes since the previous one.

There is currently nothing that we specifically need in this snapshot,
but it brings us closer to what will be in the upcoming 4.7.0 release
and will allow us to potentially catch any issues before release.

Change-Id: I4c3642eab4c1f1128e2e19cf656dee13270662e2
2017-03-24 09:06:23 +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
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
Paladox none
761a19ebc3 Update soy to 2017-02-01
New release depends on safe-html-types that is released under Apache 2
license: [1].

[1] https://github.com/google/safe-html-types
Change-Id: If46fcf6dd2e7ad7e2c6eac0906e5df0fa401b6cc
2017-03-17 05:33:26 +01:00
David Pursehouse
50f200f3af Merge "Remove an obsolete code comment from the AsciiDoctor class" 2017-03-14 05:07:28 +00:00
David Pursehouse
f32625ac90 Move all JGit related definitions to lib/jgit/jgit.bzl
Move the definitions of the JGit repository and the artifact hashes into
the lib/jgit/jgit.bzl file so that when we change the JGit version we can
make all the necessary modifications in one place.

Change-Id: I4cb97481d62a57bfca960392d696aae3c95c6bb7
2017-03-09 18:10:46 +09:00
David Pursehouse
f4179849bd Remove redundant GUAVA_VERSION and JGIT_VERSION files
These were used by the Buck build, and are no longer needed after
we switched to Bazel.

Change-Id: Ie50b0c2dcff9a7bab707eb7d97e9b5567113c11a
2017-03-09 10:02:09 +09:00
David Pursehouse
9561f38f14 Format BUILD and WORKSPACE files with buildifier
Formatted with buildifier version 0.4.3 installed via homebrew
on OSX.

Change-Id: Iab54e118a5d119b5c031838c267b848b8ead30f2
2017-02-28 17:32:44 +09:00
Paladox none
33d4eafec0 Update CodeMirror to 5.24.2
Change-Id: I9e86bdb59b5f9295bc1ff50e04174856e5b00444
2017-02-22 23:24:18 +00:00
David Pursehouse
4049ba2a62 Upgrade guava to 21.0
Change-Id: I159c6d3a42e5166f93c6eb410018ce3297876e50
2017-02-21 10:44:59 +09:00
Han-Wen Nienhuys
6471e8a94a Ship BouncyCastle in the .war files.
Per
https://www.bis.doc.gov/index.php/forms-documents/encryption/328-flowchart-2/file
open source crypto software can be self-classified as 5D002, and
requires only notification of the U.S. Bureau of Industry and
Security.

This registration has been performed by Google, as of Feb 15, 2017.

This gets rid of the special casing for BouncyCastle, simplifying our
build and deployment process.

Change-Id: I680b0a001e5e2e497ed6e62c90c8b8be30efff48
2017-02-15 13:48:57 +01:00
David Ostrovsky
8eee3669f3 Merge "update web-component-tester to 5.0.0." 2017-02-13 18:46:21 +00:00
Dave Borowitz
39bc108a39 Make implicit reviewers feature actually work on GWT UI
This was presumably fixed in Ia5e6b9791 and in I8b735db4f. It turns
out, that labels map is not null in GWT UI, as it is the case in PG,
but also non empty, even in non-voting case: Code-Review: 0.

Fix the optimization check to account for zero votes.

Bug: Issue 4638
Change-Id: I6d9a2cc42ec51e6b1df13b96cf4bcdd082c87f60
2017-02-11 06:19:54 +00:00
Dave Borowitz
292fa154c1 Format all Java files with google-java-format
Having a standard tool for formatting saves reviewers' valuable time.
google-java-format is Google's standard formatter and is somewhat
inspired by gofmt[1]. This commit formats everything using
google-java-format version 1.2.

The downside of this one-off formatting is breaking blame. This can be
somewhat hacked around with a tool like git-hyper-blame[2], but it's
definitely not optimal until/unless this kind of feature makes its way
to git core.

Not in this change:
* Tool support, e.g. Eclipse. The command must be run manually [3].
* Documentation of best practice, e.g. new 100-column default.

[1] https://talks.golang.org/2015/gofmt-en.slide#3
[2] https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html
[3] git ls-files | grep java$ | xargs google-java-format -i

Change-Id: Id5f3c6de95ce0b68b41f0a478b5c99a93675aaa3
Signed-off-by: David Pursehouse <dpursehouse@collab.net>
2017-02-07 10:04:39 +09:00
Han-Wen Nienhuys
afdd224496 update web-component-tester to 5.0.0.
Change-Id: I8e4b409574cd0b660f290213fdec26f8d2e7411c
2017-02-01 13:33:56 +01:00
Han-Wen Nienhuys
3dede1653a bower2bazel: don't specify versions for non-seed packages.
The 'seed' packages are the ones whose versions are set by us in
WORKSPACE. We should not set the versions for the rest of the packages
in the bower input JSON, so bower can suggest the right versions to
use.

Change-Id: I9b75f16655d049e2064726862980a339c91dd534
2017-02-01 13:33:55 +01:00
Paladox none
603fb17b44 Remove one last buck file from gerrit's core
Change-Id: I48ab5af8be5493b36f903e4e32277a611de97a17
2017-01-27 19:41:56 +00:00
David Ostrovsky
a3acef8de4 Bazel: Fix powermock-core declaration
In the definition of //lib/powermock:powermock the dependency to
@powermock_core//jar was missing.

Change-Id: I4055085592ad556e7b1da730344b7e48460be7af
2017-01-24 23:31:15 +01:00
David Ostrovsky
fdbfcad77d Remove Buck based build
Bug: Issue 5302
Change-Id: I6e860446ef30ff0ad1c7c49fc0e39d39d921820b
2017-01-23 12:44:58 +00:00
David Pursehouse
074cf23832 Upgrade JGit to 4.6.0.201612231935-r.30-gd3148f300
This snapshot includes several fixes since the release, including some
improvements in LFS support:

  d3148f300 Make ObjectDownloadListener public
  55c629a9f LfsProtocolServlet#LfsRequest: Add operation type helper methods
  56fe21778 Expose LFS operation strings as public constants
  590141163 LfsProtocolServlet: Improve error on getLargeFileRepository failure
  7245aa031 Add support for refusing LFS request due to invalid authorization
  0e187f148 Add LfsPointerFilter TreeFilter

Change-Id: Ib3cd9d8677b6c6017becc5c46e7fa4dfc5192807
2017-01-19 23:45:46 +00:00
Paladox
10649e4550 Update bouncy castle to 1.56
See release notes at https://www.bouncycastle.org/releasenotes.html

Change-Id: Id0c5b1e929118469b4a80252e44a201b7b8f62f5
2017-01-11 23:05:10 +00:00
Matthias Sohn
e1d12494d9 Update JGit to 4.6.0.201612231935-r
Change-Id: Ibd58603e6c1975c883dbf9f1d115e03a25467774
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Signed-off-by: David Pursehouse <dpursehouse@collab.net>
2016-12-29 21:21:37 +00:00
David Ostrovsky
1b44bb8430 Merge "Update codemirror to 5.22.0" 2016-12-27 20:06:02 +00:00
Paladox
1e55a382d6 Update codemirror to 5.22.0
Highlights include:
 - New themes duotone-light and duotone-dark
 - Various small fixes to language modes

Change-Id: I632cc2dd3815767293ea9638b0551f7a98f330b2
2016-12-22 23:40:25 -04:00
Dave Borowitz
bb6896caad Update gwtorm to v1.17
$ git log --oneline v1.16..v1.17
09ada04 Version 1.17
4ce1c32 JdbcAccess: Defer exceptions when in a transaction
b46ab3e Incorporate table into H2 column constraint name
0bfc2e3 Start 1.17

Change-Id: Iee0002cbc74678cac53c1931acf1bea92ef25c7e
2016-12-22 12:20:56 -05:00
David Ostrovsky
86da32cd24 Buck: Simplify jsoup integration
Remove unnecessary java_library rule wrapper around another
java_library defined through maven_jar rule.

Change-Id: I197df73f8944b9d17c7738c036035b2daccd8e61
2016-12-21 23:25:11 +01:00