Commit graph

698 commits

Author SHA1 Message Date
Tal Levy
b545b83390 Migrate Logstash to Log4j2 Logging (#5651)
Migrate to use Log4j2 for Logstash logging
2016-08-26 18:11:22 +00:00
Pier-Hugues Pellerin
23e87bc44f Remove spec/integration
With the addition of the qa acceptance test suite we have decide that we
don't need to maintain this suite also since the acceptance test are
running really similar test.

Fixes: #5744

Fixes #5760
2016-08-14 15:09:29 -04:00
Pier-Hugues Pellerin
b2c5c55d53 making sure that flores rspec are acessible everywhere
Fixes #5542
2016-06-27 18:37:03 -04:00
Suyog Rao
655adc677e Fix failing tests on master and 5.0
License tests was failing because of GPL2 in mime-types.Added an
exception for this gem because v2.6.2 is triple-licensed and we pick
MIT.

Metrics test is failing because of address in use which is fixed in
PR #5307. Skipping this test for now.

Fixes #5369
2016-05-26 23:28:39 +00:00
Pere Urbon-Bayes
6c92fa9f58 Add a new command that generate a plugin skeleton that can be used to create a new plugin
Fixes #4190
2016-05-24 16:14:46 +00:00
Joao Duarte
3a6b1dafaa introduce yaml settings file and cli long switches
* by default lives in LOGSTASH_HOME/config/logstash.yml
* location can be changed by $LS_SETTINGS_DIR or --path.settings
* overrides defaults of LogStash::Environment, BUT
* CLI flags override the yaml file
* several breaking changes to cli flag names (see config/logstash.yml)
* setting values are now type checked (see Setting and Settings classes)

Fixes #5313
2016-05-19 19:20:37 +01:00
Jordan Sissel
c6aaf58ff0 Add missing require
This lets plugins test against core. Oops.

Fixes #5297

Fixes #5305
2016-05-16 19:22:41 +00:00
Pere Urbon-Bayes
834d52a9aa refactor integration test to be inside the specs directory and not in the main level
Fixes #5268
2016-05-12 06:56:25 +00:00
Pere Urbon-Bayes
1bb73ca123 use only one plugin manager folder for specs
Fixes #5268
2016-05-12 06:56:25 +00:00
Jordan Sissel
3fa057e3bc Enable JSON logging for all test runs.
Use an internal subscriber to verify that JSON output is valid JSON. The
purpose is to catch any json serialization errors that would occur while
logging.

Also had to update a few logger calls to log values that could be
serialized (Class instances and similar, at this time, fail to serialize
to JSON).

Fixes #4820
2016-05-09 19:53:17 +00:00
Pere Urbon-Bayes
2195f145b2 This adds a feature to let users dump all their installed plugins,
including dependencies, and reuse them in an offline installation by
providing an package for it. It adds two important commands to the
plugin manager, the pack and upack, to handle package creation and
installation and adds the --local flag to install and update to pull
plugins from the installed local packages.

Former commits:

add a task to create a bundle, under vendor/cache of the installed gems + their dependencies, this can be used later on to be installed offline

add an option to pass the --local flag to the bin/plugin update task, so it fetch plugins from a local cache, by default under vendor/cache

rename package:build to package:build-cache as is more meaningfull

add a --local flag to bin/plugin install to users can install plugins from the local cache, under the default directory of vendor/cache

add a plugin manager command to build the local cache of installed plugins using bundler package alike command

It adds code for compressing and extracting in zip and tar formats to
the utils module of logstash. The zip module is only jruby dependant as
it uses functions provided by java.
There is also code add in the plugin manager package command to handle
compression of plugins dumping.

Cleanup the custom java code to compress and extract zip files as it has
been known that using rubyzip is good and it has a more ruby like
features so the code is more clean and portable.

set of smallish improvement requested during review

added several options to handle situation when the package of plugins we want to generate is already there

clean up old code

applyed feedback from review, mostly changed in documentating behaviour plus better wording for messages

relocate the Environment.windows? check to the bootstrap side as it's used also in the plugin manager

add an unpack bin/plugin command so users can install packages of plugins throw the plugin manager

document override behaviour in the compress helpers (for zip and tar) plus add a fix for the tar extract when reading entries

made the unpack filename parameter a required one

add a force option to the bin/plugin unpack command

add a notice to that if using a local cache the --local flag should be passed with

Code cleanup and refactor introduced during review

add two wording suggestions comming from review

ammend more wording

skip the major version validation as in situation where there is no internet connection like when using the local vendor/cache to do the update

move compress to the bootstrap environment as being used in the plugin manager means not being loaded with logstash-core

Bring pack cached gems in the vendor directory so they can be used for bundler when packaging dependencies

Revert "Bring pack cached gems in the vendor directory so they can be used for bundler when packaging dependencies"

This reverts commit a9d7f46649932b06efaafebdd0eed2b4c63c2235.

patch the Bundler::Source::Rubygems to fetch only gems from a remote  source

small changes in several parts of the plugin manager and the creation of a common pack command with shared code

change compress to read in chuncks

fix wrong var name in the bootstrap compress utils module

fix namespacing conflicts

add basic test for the compress utility module

ammend more namespace issues

add a comment to the rubygems mockey patch to rebuild the gem cache

apply cosmetic changes

make the compress module raise CompressError

remove vendor_path and pattern_path form environment as they where mix up during rebase

change the bin/pack force option to be force-delete-cache

rename force_delete_cache to overwrite

change force for overwrite in tha pack command

remove the override option for bin/plugin unpack

revert Gemfile and Genfile.lock wrong committed
2015-11-18 12:03:51 +01:00
Pere Urbon-Bayes
29b6301199 stub the warn_local_gems call in the update command of the plugin manager as is only relevant for master, not for the version branches
Fixes #4212
2015-11-17 14:05:05 +00:00
Pere Urbon-Bayes
ba96b1f0b3 Fix the plugin manager install and update commands to perform the validation properly when a private gem server (not rubygems) has been configured. This basically loads the sources so the system is able to perform the validation with the right destionation and not with the default source (rubygems.org)
Former commits:

add all defined sources to rubygems so verification can talk to all the repositories, even the private ones

added a very simple plugin manager install command spec, to check for properly loading sources when validating

broke long lines into smaller ones in the install command

make sure the update command takes into account all declared sources, plus there is the option to avoid gem validation in case of only having a private gem repo and no internet connection

fix wrong conditional in the validation of plugins

move the Gem.sources loading to a common place, to sources are loaded all at once and we don't need to worry on each call to be sure we do the right thing for other sources different that rubygems

update test to the last changes in the way gemfile is loaded

move Gem::SourceList.from to bundler::invoke! so we use the default gemset.sources array

fix loading path for Gem::SourceList in bundler, so it's not colliding with other classes

Revert "move the Gem.sources loading to a common place, to sources are loaded all at once and we don't need to worry on each call to be sure we do the right thing for other sources different that rubygems"

This reverts commit 6e1c809665d61495b5461e7522a7adc745fe27fc.

Revert "update test to the last changes in the way gemfile is loaded"

This reverts commit dc5f65c2ac5380b1640cb732946f1a8ababcc9dc.

make the Gem.sources load to happen inside the logstash_plugin? call

add the idea of settings to the plugin manager module, like this we can pass throw different stuff usefull to setup dependant components

add the install spec back

remove the PluginManager::Settings concept

change sources for rubygems_sources in the plugin manager options

change rubygems_sources to be rubygems_source

update comments

ammend plugin manager options description in the comments

spaces and new lines cleanup

merged duplicated plugin manager util_spec introduced during rebase

add a check when Gems.versions fail

Add the validation exception for the plugin manager

add better error handling for situation where the validation is not possible due to a connection issue with the remote server

Fixes #3583
2015-11-17 08:38:55 +00:00
Colin Surprenant
2e80cd0cb7 fix coverage paths for new structure by #4123 2015-11-16 19:34:45 -05:00
Colin Surprenant
d74d41cb30 logstash-core & logstash-core-event extraction to support logstash-core-event-java impl, relates to #4191
fixed timezone issue

extracted logstash-core and reorganized specs

extracted logstash-core-event

extract java Event into logstash-core-event-java in a proper gem

remove obsolete jruby_event bootstrapping

fix require path

add java code bootstrap

use logstash-core-event/logstash-core-event.rb

remove obsolete files

basic instructions

LogStash::Json need to be initialized from event

update jruby and gradle versions

update compile:logstash-core-event-java rake task

WIP tasks refactor

fix gem.files

skip test if class is not defined

fix gem related tasks for new structure

add gem spec dirs in core tests

bootstrap java implementation when requiring timestamp

new Cloner class and Event clone impl

fix array fields assignments, see #4140

don't rely on json implementation ordering

fix skipped last iterpolation char

remove implementation specific unnecessary check

also require ruby classes

define error class in ruby

raise exception on invalid format

remove implementation specific tests and extract and put logger related test in pending

missing bits for having all core timestamp specs pass

run all core specs

remove leftover

comment regex

missing encoding header

revert to logstash-core-event by default

finished proper gemification

useless require

dynamically pick specs depending on logstash-core-event-* implementation

logstash root package version

missing file for proper gemification

do not build java event by default

always check for root logstash lib dir

fix concurrent-ruby version confict

fix rebase conflict

re-enable specs

user vars instead of constants

move non core code in bootstrap

document version files

move version file

remove useless code

use version in logstash-core

fix gem files list

put back concurrent-ruby version constrain as in master

add dependency on logstash-core-event

remove dependency on logstash-core to avoid circular dependency

fix rebase conflict

remove circular dependency

fix specs

update README
2015-11-16 16:40:19 -05:00
Tal Levy
e28f188e12 refactor to gradle project, relates to #4191
more event java updates

- updated metadata
- moved #append to java
- other small test fixes

commit gradle wrapper jar
2015-11-16 16:39:47 -05:00
Colin Surprenant
4ada9363f9 more Event java impl, relates to #4191
event clone

append in Ruby

tag & append

add timestamp assignment spec

comment out original classes

fix at signature

implemented del

remove from array

del test
2015-11-16 16:38:40 -05:00
Colin Surprenant
e5fb1d2977 logstash-core-event-java initial impl, relates to #4191
wip initial Accessors, Event, EventImpl, Path, Timestamp and PathTest

wip

wip

FieldReference and Accessors implementation

rename targetCache to lut and set it protected

initial Accessors tests

todo comment

more tests

Timestamp implementation

Timestamp tests

fix method name

add Long constructor

event initialization, timestamp handling and json serialization

add <> type information

custom json serializer for Timestamp

remove toJson test

initial Event test

more tests

comments

debug traces

initial jruby Event wrapper and specs

added PathCache

implemented includes

added clone

wrap all Event methods

Rakefile to build and jar

missing getters and implement overwrite

support Date conversion

proper cast and coercion

replace Ruby Event with Java Event

test for field reference setter type coercion

disable specs

timestap setter should also set in map, accept more timestamp types

pre cache timestamp and expose isTimestamp

constructor from DateTime

expose proper Ruby Timestamp object

Ruby Timestamp basic specs

also load JRuby Timestamp

transpose Java<->Ruby Timestamp

fix timestamp specs

new jar

cleanup object construction
2015-11-16 16:35:26 -05:00
Pere Urbon-Bayes
01994032a1 add artistic 2.x license to the list of accepted licenses
Fixes #4196
2015-11-16 16:26:33 +00:00
Colin Surprenant
af245b9ed2 add specs for Retryable module
Fixes #4093
2015-11-05 21:05:53 +00:00
Colin Surprenant
42830bd09b cleanups
Fixes #4037
2015-10-15 21:31:08 +00:00
Colin Surprenant
c09481897c added FileWatch::BufferedTokenizer spec
Fixes #4037
2015-10-15 21:31:08 +00:00
Pier-Hugues Pellerin
dbb034ec45 Plugin#params should not return obsolete params
Fixes #4011
2015-10-13 16:18:15 +00:00
Suyog Rao
62c42be8e2 Remove deprecated config options. Will also make docs nicer
Fixes #4011
2015-10-13 16:18:15 +00:00
Pere Urbon-Bayes
0eecea3e9a added an option to skip given dependencies from the license test.
Fixes #4022
2015-10-13 14:32:31 +00:00
Jordan Sissel
7e7e4c8719 New plugin config attribute :obsolete
An obsolete setting is one that will cause a configuration error if it
is used.

The purpose of `:obsolete` is to help inform users when a setting has
been completely removed. The lifecycle of a plugin setting is now 4
phases: available, deprecated, obsolete, deleted.

"Available" is the default, and deprecated remains the same as it was
(logging a warning). The new obsolete will cause a configuration error
if such a setting is used. Then later, we can finally delete the config
setting after it's been obsolete for some time.

Fixes #3977

Fixes #3978
2015-10-02 09:31:29 +00:00
guyboertje
5b47009648 Add basic defaults module and spec. Use defaults in pipeline and agent
move/rename defaults under config, use Concurrent.processor_count
remove method `filter_workers_count`

add CpuCoreStrategy module functions/tests. Use fifty_percent as default.

use extend self for Module functions

added defaults printing facility

change comment

add tests to defaults printer subsystem

closes #3852
2015-09-24 14:59:05 +01:00
Joao Duarte
112b28149e rename teardown to close
remove edge case when running from rubinius

add do_stop and do_close to avoid using super
2015-09-18 16:23:40 -04:00
Pier-Hugues Pellerin
aca58da536 sprintf should work if there is no fieldref in the string
Fixes #3937
2015-09-18 15:39:44 +00:00
Pier-Hugues Pellerin
935ac9285b String Interpolation skip the last character
This PR fix a problem when doing the interpolation with a string that
did not end with a fieldref but with a character. The interpolation was
ignoring the last character.

Example:
```
"%{type}|" => "syslog"
```

Fixes #3931

Fixes #3937
2015-09-18 15:39:44 +00:00
guyboertje
7bb94d0692 add test for compact and compact! in java_integrations
Fixes #3772
2015-09-03 19:43:10 +00:00
Pere Urbon-Bayes
ae4c49be3b Exclude pre releases when checking if the update is targetting a major release in the plugin manager, as bundler is not going to update anyway to this version without an explicit install command.
Fixes #3826
2015-09-02 21:17:02 +00:00
Andrew Cholakian
f2fcc41aee Non Oracle Javas are all detected as 'good'
Fixes #3824
2015-08-31 14:16:13 +00:00
Pere Urbon-Bayes
028d76497c add the missing magic header # encoding: utf-8 so all internal strings are UTF-8 in Ruby < 2.0
Fixes #3723
2015-08-17 13:30:07 +00:00
Pere Urbon-Bayes
45e768e833 makes sure that all property interpolation throught event.sprintf are returned in UTF-8
Fixes #3718
2015-08-17 13:21:24 +00:00
Andrew Cholakian
9e88c90b28 Handle non-hotspot javas in version check
Fixes #3685
2015-08-03 21:25:58 +00:00
Pier-Hugues Pellerin
cbfd1eebf5 Do not force a verify_mode with a our stronger ssl settings
We have discovered that in some cases and some plaftorms
configuring a default `verify_mode` when creating a SSL/TCPServer
could make the certificate verification fail. Ruby default behavior is
to use `NIL` when creating a new ssl context, this revert that change.

keep in mind that all TCP clients using SSL **must** use `VERIFY_PEER`
as their verify mode to prevent man in the middle attack.

Fix: https://github.com/elastic/logstash/issues/3657
2015-07-31 20:56:11 -04:00
Colin Surprenant
52aec3b244 add back --pluginpath option
support adding plugin paths

support --pluginpath option

missing doc

refactor using @purbon suggestions

Agent#configure_plugin_paths spec

solves #3580
2015-07-15 16:43:13 -04:00
Jordan Sissel
fbf8e1e320 Improve default security for SSLContext with a monkeypatch.
New defaults:
* Cipher suite based on Mozilla's Intermediate set from
  https://wiki.mozilla.org/Security/Server_Side_TLS (at time of writing)
* Disable SSLv2 explicitly
* Disable SSLv3 explicitly
* Disable compression if possible

The SSL option setting came from the ruby-ftw library's FTW::Connection
(apache 2 licensed, I am author), and transitively through work
published by jmhodges to improve Ruby's SSL strength.

I include specs to ensure we never include export or weak ciphers by
default.

Using this patch to test the security improvements according to
`www.howsmyssl.com` shows much improved results:

---

Testing this:

```
ruby -r ./lib/logstash/patches/stronger_openssl_defaults.rb  -ropenssl -rsocket -rjson -rawesome_print -e 'c = OpenSSL::SSL::SSLContext.new; t = TCPSocket.new("www.howsmyssl.com", 443); o = OpenSSL::SSL::SSLSocket.new(t, c); o.connect; o.puts "GET /a/check HTTP/1.1\r\nHost: www.howsmyssl.com\r\n\r\n"; headers,body = o.read.split("\r\n\r\n", 2); puts body'
```

(I processed the JSON output w/ jq for easier reading)

The purpose of the above is to test the default behavior of SSLContext.

* JRuby 1.7.19 w/ this patch reports no cipher problems.
* JRuby 1.7.19 without this patch has several weak ciphers used:

```
  "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA: [\"uses keys smaller than 128 bits in its encryption\"]",
  "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA: [\"uses keys smaller than 128 bits in its encryption\"]",
  "TLS_DHE_RSA_WITH_DES_CBC_SHA: [\"uses keys smaller than 128 bits in its encryption\"]",
  "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA: [\"uses keys smaller than 128 bits in its encryption\"]",
  "TLS_RSA_EXPORT_WITH_RC4_40_MD5: [\"uses keys smaller than 128 bits in its encryption\",\"use RC4 which has insecure biases in its output\"]",
  "TLS_RSA_WITH_DES_CBC_SHA: [\"uses keys smaller than 128 bits in its encryption\"]",
  "TLS_RSA_WITH_RC4_128_MD5: [\"use RC4 which has insecure biases in its output\"]",
  "TLS_RSA_WITH_RC4_128_SHA: [\"use RC4 which has insecure biases in its output\"]"
```

Under MRI, similar cipher selection problems are observed without this patch (weak export
ciphers, other weak small-key ciphers, RC4 complaints). With this patch, no cipher complaints
are reported by www.howsmyssl.com

One other note: Because JRuby defaults to TLS 1.0 and only makes CBC ciphers
available under the Mozilla Intermediate cipher set, I believe (and
howsmyssl.com agrees) that these defaults still make the BEAST exploit a
problem. Switching to TLS 1.1 should fix this, but we need to do more research
to determine the what, if any, impact it will have if we force TLS 1.1 to be
the default..

Fixes #3579
2015-07-13 21:41:15 +00:00
Andrew Cholakian
f7b76fa2ae Fix namespacing for unicode trimmer
Fixes #3593
2015-07-10 21:34:52 +00:00
Joao Duarte
d7bfd25dab make plugin#inspect show number config parameters
Fixes #3564
2015-07-10 15:24:24 +00:00
Pere Urbon-Bayes
bd7516108f workarround the version check for pre released plugins as looks like rubygems is not activating them by default
Add a pre release gem test by using a mock to reproduce the behaviour
reaised by Gem::Specification.find_by_name when dealing with pre release
gems.

Fixes #3476
2015-07-02 16:06:48 +00:00
Pere Urbon-Bayes
a81f0249b1 locate plugin manager command dependencies to the specific commands as it should be
Fixes #3509
2015-07-02 14:17:50 +00:00
Pere Urbon-Bayes
40c57454a2 introduce direct loading for modules that need to be loaded in a given order becuase of missing dependencies, this fix the issue we had with early released of JDK7 and linux systems
Fixes #3509
2015-07-02 14:17:49 +00:00
Pier-Hugues Pellerin
3f38575758 Wrong namespace for json serialization
Fixes #3536
2015-06-30 20:53:14 +00:00
Andrew Cholakian
f0e5bcd597 Make inspecting collections a bit more friendly
Fixes #3474
2015-06-30 17:02:58 +00:00
Andrew Cholakian
13ed78790f Add unicode trimmer utility function
Fixes #3505
2015-06-26 20:13:59 +00:00
Pier-Hugues Pellerin
1380119ac8 Removing reference of fieldreference
Fixes #3467
2015-06-26 17:35:46 +00:00
Pere Urbon-Bayes
cf10890d63 fix the coverage analysis throw simplecov to take care of all files
make the eager loading patterns consistent in the spec_helper.rb file

make the setup-simplecov task not a dependency, but an explicit task only executed when ENV['COVERAGE'] is defined

refactor eager loading code plus add some documentation to the setup-simplecov task

Added more comments to the test:setup task

Fixes #3465
2015-06-25 15:36:57 +00:00
wiibaa
e715248b4a harmonize add_field and add_tag behavior in inputs and filters
Fixes #2390
2015-06-24 20:52:14 +00:00