Commit graph

3699 commits

Author SHA1 Message Date
github-actions[bot]
525fd342f1
Fix debug output for bin/logstash-plugin (#14132) (#14144)
When run in debug mode, #invoke was returning an instance of UI::Shell rather
than a string, causing the plugin to crash when `<<` was called on.
This commit ensures that a string is returned regardless of whether debug is set

Fixes: #14131
(cherry picked from commit 02c2aec710)

Co-authored-by: Rob Bavey <rob.bavey@elastic.co>
2022-09-26 14:54:06 -04:00
Karol Bucek
6f447440fe
Feat: conservative plugin (dependency) updates by default (#13794) (#13804)
(cherry picked from commit 67fd99b5b6)
2022-02-28 22:34:02 +00:00
kaisecheng
c77994f438
Fix logstash-plugin install command to install non default plugin (#13405) (#13587)
After the fix of unlocking ecs_compatibility_support version in plugin update (#13218), `logstash-plugin install` has a problem of installing non default plugin.
This commit removes `Bundler.setup` in install path to avoid Gemfile froze by bundler
Fixed: #13404

Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>
2022-01-06 14:52:25 +00:00
Rob Bavey
292b2ebb57
Backport PR #13351 to 7.16: Fix bundler handling of 'without' (#13362)
Backport PR #13351 to 7.16 branch. Original message:

* Fix bundler handling of 'without'

Prior to this change, the values set in `set_local` are ignored when invoking
bundler via the command line, as is used with `invoke!`. This commit sets those
values in `ENV` variables instead, fixing the functionality to not install
development gems.
* Update bundler spec to check ENV variable
* Added test to ensure kramdown gem not vendored
* Re-add set_local setting to play nice with `expand_logstash_mixin_dependencies`
* logstash service needs to be installed
* gem_vendored? needs to use full path to vendor files
* use `stdout` from `cat` command to generate spec temporary file
* Removed unnecessary support for supplying a block from #gem_vendored?

Co-authored-by: Ry Biesemeyer <ry.biesemeyer@elastic.co>
2021-10-26 18:36:14 -04:00
kaisecheng
f59bd179dc
fix plugin installation script (#13289) (#13290)
This commit requires `set`, as bundler #expand_logstash_mixin_dependencies call `to_set`
Fixed: #13281
2021-10-07 17:13:29 +02:00
kaisecheng
f675a39841
unlock ecs_compatibility_support version in plugin update (#13218) (#13268)
This commit fixes the `logstash-plugin update` command which fail to update plugin
that depends on a new version of logstash-mixin-ecs_compatibility_support.
It resolves logstash-* dependencies and puts them in bundler update command.
Fixed: #13181
2021-10-04 15:33:56 +02:00
Rob Bavey
2ac869a9c4
Backport PR #13015 to 7.x: Bundler: freeze lockfile on run, and "norm… (#13140)
* Backport PR #13015 to 7.x: Bundler: freeze lockfile on run, and "normalize" platform on plugin changes

Backport PR #13015 to 7.x branch. Original Message:

This PR enables the upgrade of bundler to the latest version.

Prior to this PR, the ability to do so was blocked by bundler.setup in versions of bundler > `2.23` making runtime changes to `Gemfile.lock` (unless the lock file was `frozen`) based on the specific platform the application was being run on, overriding any platforms (including generic `java` platform) set during build time. This was in conflict with changes made in #12782, which prevented the logstash user writing to files in `/usr/share/logstash`.

This PR will freeze the lockfile when logstash is run, and unfreeze it when manipulating plugins (install, update, remove, install from offline pack) to allow new plugins to be added. While unfrozen, changes are also made to ensure that the platform list remains as the generic `java` platform, and not changed to the specific platform for the runtime JVM.

This PR also introduces a new runtime flag, `--enable-local-plugin-development`. This flag is intended for use by Logstash developers only, and enables a mode of operation where a Gemfile can be manipulated, eg

```
gem "logstash-integration-kafka", :path => '/users/developer/code/plugins/logstash-integration-kafka'
```

to facilitate quick and simple plugin testing.

This PR also sets the `silence_root_warning` flag to avoid bundler printing out alarming looking warning messages when `sudo` is used. This warning message was concerning for users - it would be printed out during normal operation of `bin/logstash-plugin install/update/remove` when run under `sudo`, which is the expected mode of operation when logstash is installed to run as a service via rpm/deb packages.

This PR also updates the vagrant based integration tests to ensure that Logstash still runs after plugin update/install/remove operations, fixes up some regular expressions that would cause test failures, and removes some dead code from tests.

* Updated Bundler to latest version
* Ensured that `Gemfile.lock` are appropriately frozen
* Added new developer-only flag to facilitate local plugin development to allow unfrozen lockfile in a development environment

(cherry picked from commit 4707cb)

* Remove code pinning bundler to ~> 1.17
2021-08-17 20:31:26 -04:00
Andrea Selva
854fad6339
Avoid hard-coded plugin alias definitions (#12841) (#12960)
Remove hard coded alias definitions in favor of yaml descriptor file.

Introduce a single point of aliases definition (logstash-core/src/main/resources/org/logstash/plugins/AliasRegistry.yml),  checksum and copy it around to be used by Logstash and by Logstash's plugin management tool.

The descriptor yml file contains a checksum to verify it's not changed accidentally in a deployment of Logstash, if the verification phase fail Logstash avoid to start and plugin management tool avoid to operate.
The signing and copying around is managed by a specific Gradle task invoked during the build.

Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>

Fixes #12831

(cherry picked from commit 446dc7d906)
2021-06-16 17:34:46 +02:00
Karol Bucek
419b1dc988
Backport PR #12791 to 7.x: Deps: update JRuby to 9.2.18.0 (#12971)
Backport PR #12791 to 7.x branch. Original message:

Version bump of JRuby.

+ Fix: a missing require in bootstrap

(cherry picked from commit ee6038afec)
2021-06-10 07:24:17 +02:00
Andrea Selva
0bc53b4b8a
Adapted install/uninstall/list PluginManager's command to respect the alised plugins (#12821) (#12836)
Adapted install/uninstall/list PluginManager's CLI commands to respect the alised plugins
- adapt install plugin to resolve an alias giving precedence on a real plugin
- changed list to mark alised plugins
- uninstall avoid to remove the alias and ask the user to remove the original plugin
- update update the original plugin in case of alias, else fallback on usual behavior

Co-authored-by: Ry Biesemeyer <ry.biesemeyer@elastic.co>
(cherry picked from commit 1e08341e1e)
2021-04-20 23:43:47 +02:00
kaisecheng
b852daf202
Allow plugin manager uninstall plugin regardless of working directory (#12786) (#12808)
Fixed: #10781
2021-04-08 18:25:58 +02:00
João Duarte
b3bcf29d73
use correct headers api for redirects in plugin manager http client (#12626) (#12628)
* fix plugin installation QA test

(cherry picked from commit 7c4bd8f875)
2021-02-01 16:08:21 +00:00
vijairaj
734ec04186 Ensure line codec can be found in example ruby filter (#12042)
Fixes elastic/logstash#12041

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2020-06-26 14:16:56 +01:00
Colin Milhaupt
24ac6800c8 Update proxy_support.rb
Backport of #9787 to 7.x
2020-06-26 09:29:58 +00:00
João Duarte
1fc169b7f6 Add apache and elastic license headers to source code files (#11673)
* add license header to ruby and java files
* add license header to erb and rake files
* add license headers to gradle files
2020-03-11 11:54:32 +00:00
Rob Bavey
f06c5ef806 Replace references to JDBC plugins with integration plugins
Fixes #11406
2020-01-10 19:07:54 +00:00
andsel
17fe14c086 Changed GemInstaller to don't blank gemspec attribute, close 11325
Fixes #11340
2019-11-26 11:27:08 +00:00
Peter Dyson
44f08e20c7 hint plugins need to be installed before bundle
Fixes #11080
2019-08-26 08:58:28 +00:00
Joao Duarte
f18992c647 avoid clashes between Environment class methods
Fixes #10860
2019-06-14 17:44:38 +00:00
Joao Duarte
86cae08547 updated bundler to 1.17.3
Fixes #10685
2019-04-12 21:07:54 +00:00
Joao Duarte
62f8282a3b bump jruby to 9.2.7.0
Revert "work around jruby-5642 during package installation on jdk11 (#10658)"

This reverts commit 033c896330.

skip the bundler-1.16.6 files when unpacking jruby

Fixes #10674
2019-04-11 21:32:32 +00:00
João Duarte
563fa8117c
work around jruby-5642 during package installation on jdk11 (#10658)
fixes #10593
2019-04-05 15:38:46 +01:00
Karen Metts
67e62a9c00 Add sample doc files to plugin generator
Fixes #10029
2019-03-19 20:21:19 +00:00
Ry Biesemeyer
583ec6b625
Java 11 support (#10279)
* bump jruby to 9.2

* don't rely on logstash-base docker image

* work around webmock ruby 2.5 support

* ensure data folder exists in docker

* change fixnum and bignum to integer

* FileUtils.rmdir to rm_rf

this is because from 2.3 to 2.5 FileUtils.rmdir will throw an exception
if the directory isn't empty. On 2.3 the operation will just not delete
the directory silently.

* bump jruby to 9.2.5.0 and fix test

* make rake default task since prepare pack needs it

* Resolve compiler warnings (#10247)

There are 3 types of compiler warnings that are either resolved or suppressed:

1. Rawtypes: In JRuby 9.2, `RubyArray` is a generic, so references throughout
   our codebase to the now "raw" type trigger warnings. In most cases we cannot
   actually resolve the issue, since the JRuby-provided methods for creating
   `RubyArray`s still return the raw type, so these have been suppressed.

2. Deprecations:
   - `RubyString#intern19()` -> `RubyString#intern()`
   - `RubyString#downcase19(ThreadContext)` -> `RubyString#downcase(ThreadContext)`
   - `NativeException`: remove import & reference directly; suppress usage
     warnings
   - `RaiseException()`: migrate to equivalent non-deprecated methods wherever
     possible; in some cases where we are using this in conjunction with the
     also-deprecated `NativeException` to preserve java stacktraces, there
     seems to be no non-deprecated path forward, so these cases have been
     suppressed.

3. Redundant Casts
   - Resolved

* JRuby 9.2 bundler shenanigans (#10266)

* Revert "Revert "remove forced dependency on old bundler (#9395)""

This reverts commit bef984143d.

* plugin management: update internal bundler to 1.17.x APIs

* deps: update dev dependency webmock to version compatible with JRuby 9.2

* spec: update Pack fixture to include manticore version that doesn't conflict

* build: update gradle to version that has Java 11 support

* java11: resolve or suppress deprecation warnings

* Remove superfluous flag opting into ParNew GC implementation

When opting into CMS garbage collector with `XX:+UseConcMarkSweepGC`, the
young generation collector ParNew has been the default since Java 8, making
the `XX:+UseParNew` flag redundant; the flag was removed in Java 9, and
should no longer be specified to work with modern Javas.

https://bugs.openjdk.java.net/browse/JDK-8006478
https://openjdk.java.net/jeps/214

* spec: set thread name to example description for easier debugging

* spec: prevent errors in testing specs by checking against skip list before using

* no-op: remove use of `HashMap#computeIfAbsent` on single-threaded code

> This method will, on a best-effort basis, throw a `ConcurrentModificationException`
> if it is detected that the mapping function modifies this map during computation.
>
> -- https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/HashMap.html#computeIfAbsent(K,java.util.function.Function)

* qa: by default, run integration against Elastic Stack 6.5.x

To support development on Logstash on top of Java 11, default to testing
against an Elastic Stack that is capable of running on Java 11.

* qa: ignore deprecation warnings when comparing offline pack output

* qa: add Java 9+ support to ChildProcess dev dependency

this can safely be removed when the childprocess gem supports Java9+
https://github.com/enkessler/childprocess/pull/141

* qa: allow connections to localhost in webmock

* bump jrjackson version

* fix filebeat integration tests

* spec: ensure license compliance spec runs first

The license compliance spec that validates the licenses of bundled
plugins appears to not be compatible with the hooks that we inject
into bundler for plugin management, and will fail in obscure ways
when run after those hooks have been added. Since those hooks are
not necessary for validating licenses, the easiest solution was to
ensure that those specs run first, before the VM has been poluted.

Since the gradle/junit/rspec bridge that is currently in place
runs all specs in the same JVM, we also need to make sure that the
rspec "world" is reset before a run, to ensure that it doesn't
retain spec definitions from previous runs.

Also updates the rake invocation, although I'm not sure it is used
any more.
2019-02-04 16:36:11 -08:00
Josh Soref
186a588e57 Remove excess period
The error is supplemented by ", message: " + exception

As such, a period is unhelpful.

Fixes #9749
2019-01-09 10:25:34 +00:00
João Duarte
bef984143d
Revert "remove forced dependency on old bundler (#9395)"
This reverts commit ab20b40e47.

Due to failing tests like https://logstash-ci.elastic.co/job/elastic+logstash+master+multijob--ruby-unit-tests/86/
2018-12-03 13:49:54 +00:00
João Duarte
ab20b40e47
remove forced dependency on old bundler (#9395)
* update bundler to 1.17.1

This commit required some tweaking of how we setup Bundler
due to changes in reset behaviour, an internal variable name change,
and the Bundler::Settings api changing.
2018-11-30 09:25:24 +00:00
Joao Duarte
859cbaaea9 Support for integration plugins in plugin manager
* List action shows integration and provided plugins
* List action shows integration when searching by inner plugin
* Install action removed plugins provided by integration
* Install action aborts if plugin is provided by an integration
* Remove action aborts if plugin is provided by an integration

Fixes #9802

Fixes #9811
2018-09-27 10:07:26 +00:00
Dan Hermann
75684020e5 port SecretStore to Java
Fixes #9662
2018-05-25 20:47:34 +00:00
Armin
6179c9662a JAVAFICATION: Port namespace definitions to Java
Fixes #9490
2018-04-26 12:00:15 +00:00
Ry Biesemeyer
256a6f748c opening x-pack: make plugin install/remove error helpfully
Fixes #9239
2018-03-20 17:40:26 +00:00
Tudor Golubenco
093603c378 Detect invalid proxy and raise error
As reported in #9132, if one sets `http_proxy=myproxy:8080` the URL
gets parsed to scheme=myproxy and host=nil. This results in a
NullPointerException.

To solve it, we check that the URL is valid as HTTP/HTTPs and raise a
slightly better error message.

Fixes #9132.

Fixes #9230
2018-03-15 18:17:08 +00:00
Jake Landis
058c9a6c47 Secret Store: Ability to set and use secret data from an encrypted data store.
Fixes #8657

Part 1: API and JavaKeyStore implementation (#8657)

Introduces the API to read/write/delete sensitive data from a secure store and includes a Java KeyStore implementation. Note - this commit does NOT integrate with the Logstash configuration or settings.

Part 2: Secret Store: SecretStoreFactory, SecureConfig, Obfuscation and X-JVM support (#8659)

*  Secret Store: SecretStoreFactory, SecureConfig, Obfuscation and X-JVM support

* Introduce a SecretStoreFactory to allow runtime definition of SecretStore implementation.
* Introduce a SecureConfig to allow simple configuration of different SecretStore implementaiton.
* Introduce random default password plus obfuscation. Best attempt at security through obscurity.
* Corrections / better support for x-JVM modification.

Part 3: Secret Store: SecretStore, SecretStoreFactory, JavaKeystore - refacactor (#8745)

* Adds more CRUD like operations for SecretStore API
* SecretStoreFactory Mirror API's CRUD operations
* Adds 'exists' to API to allow command line warning 'Overwrite ?'
* Minor readabiliy

Part 4: Integrate secret store with Logstash core (#8905)

This change introduces the command line tooling and hooks needed to allow Logstash to use the secret store. This change hooks into the same logic that the does the environment variable substitution. The commnad line mirrors the Elasticsearch command line, and is implemented primarily in Java.

Part 5: Hardening and test fixes (this PR)

Fixes #8935
2018-01-13 01:22:53 +00:00
Armin
f069eac40c BUILD: Execute RSPEC from JUnit
Fixes #8517
2017-10-26 19:57:54 +00:00
Armin
c7b7025cc1 #8216 Use standard name for Gemfile.lock
Fixes #8525
2017-10-26 08:33:03 +00:00
Armin
09101ca491 MINOR: Remove outdated Rubygems hack
Fixes #8534
2017-10-26 08:32:35 +00:00
Armin
3f5007c2ee MINOR: Remove dead code supporting non-java platforms
Fixes #8513
2017-10-23 18:02:03 +00:00
Joao Duarte
88d6a3d3f4 fix a few issues with proxy handling when installing plugins
* allow installing a plugin using proxy without having to use the `--no-verify` flag
* allow the use of proxies that have basic authentication
* add tests for proxy handling in plugin manager

Fixes #8435
2017-10-05 11:50:33 +00:00
Pier-Hugues Pellerin
4dc2fd3ddd Remove unecessary dependency file-dependencies
To understand why we can now remove this gem we have to go back at the
history of LS 1.5 and the choice we made back them. In the begining
plugins depending on external files like the `user-agent` or the `filter-geoip`
were not bundling theses files in the gem.

The `file-dependencies` was providing a new hook when plugins were
installed to trigger the file download.

In the context of making the plugins work in an offline environment we
need to make sure that every plugins external resources are present in
the gem.

We have currently a few plugins that require external files and they all
bundle it. So I think its safe to remove that feature, also the hook was
not triggered correctly. So it was a NOOP.

Fixes #8298
2017-09-18 18:56:58 +00:00
Colin Surprenant
21dbde2567 fixes for Windows platform tests/specs
use rm_rf to delete dir and shutdown pipeline after run

avoid the use of rescue nil, bad practice

do not mock close as it prevents closing the file an prevents removing it on Windows

cleanup temporary files and relax file name check for Windows

fix paths handling for Windows

flag the read file string as UTF-8 which is what we expect

fix Windows issues

ignore load_average on windows

windows safe URI

cleanup and fix file handling for windows

wait for pipeline shutdown to complete

revert to original puts

cleanups

use environment for windows platform check

fix hash path

wait for pipeline thread to complete after shutdown
2017-08-31 19:42:49 -04:00
Colin Surprenant
67c2d9a7d9 force UTF-8 encoding for gem file reading 2017-08-25 12:43:52 -04:00
Jake Landis
0d2ecf5a8b Revert "always use JARS_SKIP when installing or updating plugins"
This reverts commit 628207e96c.

Fixes #8070
2017-08-24 23:46:59 +00:00
Joao Duarte
3608a54698 always use JARS_SKIP when installing or updating plugins
Fixes #8058
2017-08-24 08:23:54 +00:00
Benjamin Dahon
2105b498ec Update default license (#7502)
* Update default license

The current value issues a warning when building: 

WARNING:  license value 'Apache License (2.0)' is invalid.  Use a license identifier from
http://spdx.org/licenses or 'Nonstandard' for a nonstandard license.
Did you mean 'Apache-2.0'?

* Update license

* Update license

* Update license
2017-06-22 10:05:57 -07:00
Christoph Wurm
385dda00b3 Properly catch connection refused error when installing plugin.
Fixes #7447
2017-06-14 12:52:06 +00:00
Pier-Hugues Pellerin
76286b4f0e use jruby 9.1.9.0
Work done by @guyboertje and @ph

Since JRuby 1.7.25 is now EOL we are migrating Logstash to use JRuby 9k and JDK8 only,
Not much needed updating to make this work, its was mostly a drop in replacement from the previous version.

The major point was the change in the implementation of Time in JRuby, JRuby now use `java.time`
instead of joda time, this allow JRuby to have nanoseconds precision on time object.
2017-06-12 12:35:10 -04:00
Pier-Hugues Pellerin
1113f0cffc refactor extract into 2 methods
Fixes #7065
2017-05-11 12:54:44 +00:00
Pier-Hugues Pellerin
276c6e9602 Check for empty string when configuring proxies
On some Linux system like debian, the `HTTP_PROXY` are set to an empty
string and was causing the plugin manager to raise an exception. We now
strip the string and check if it is empty before trying to configure the
proxies.

Fixes: #7045

Fixes #7065
2017-05-11 12:54:44 +00:00
Armin Braun
e6ea222c33 bundler.rb fixes for @pr review
Fixes #6985
2017-05-02 13:23:34 +00:00
Armin Braun
2f47cfd076 Allow copying a release template for Gemfile.jruby-1.9.lock.release
Fixes #6985
2017-05-02 13:23:34 +00:00