logstash-filter-urldecode 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6491119f22ace1156122a895195fb7011e29eb2
4
- data.tar.gz: 175d7d0ea848c22a09bc3e9287a0869b20e14732
3
+ metadata.gz: 489cfc844fa459e5fe25e2dcb134657faa8fc6f1
4
+ data.tar.gz: 5ebaef11ad403ef90147d63fc3e241545076c2b0
5
5
  SHA512:
6
- metadata.gz: 4946824bebdd97a16df7cbefc07b9d6a8690880258c8c891590d058bb5fe69650592f5b606483f5429d3e10926297e37238a50bafbaf00dc6cb97cedbfe305cc
7
- data.tar.gz: aa30dc26dd77b61e537b8b003f5ef21977c5c6a3b9b6b7df6471b2566b6bff5916ce49c86d751aef68b0cc575266c15a6f53da6bee9a49277f77008ba3b35fcb
6
+ metadata.gz: e4041ffec8b2ac004d0274138754833b289d56b43c8a8d6763a61650e1113d86a37b3412e598f9bf73f26ca82050c564af46e6ed73f4734e6bb470731c1b72fa
7
+ data.tar.gz: 872cc43b30abd074c78d425387d27ec9fd782cd1070202bd5442e91d346be1fcb4daad5413e9135ff1ce5389a8dc88e91c7660c28a8ef220b89fdabf912cae9d
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012-2014 Elasticsearch <http://www.elasticsearch.org>
1
+ Copyright (c) 2012-2015 Elasticsearch <http://www.elasticsearch.org>
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
@@ -0,0 +1,95 @@
1
+ # Logstash Plugin
2
+
3
+ This is a plugin for [Logstash](https://github.com/elasticsearch/logstash).
4
+
5
+ It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
6
+
7
+ ## Documentation
8
+
9
+ Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elasticsearch.org/guide/en/logstash/current/).
10
+
11
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
12
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elasticsearch/docs#asciidoc-guide
13
+
14
+ ## Need Help?
15
+
16
+ Need help? Try #logstash on freenode IRC or the logstash-users@googlegroups.com mailing list.
17
+
18
+ ## Developing
19
+
20
+ ### 1. Plugin Developement and Testing
21
+
22
+ #### Code
23
+ - To get started, you'll need JRuby with the Bundler gem installed.
24
+
25
+ - Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization.
26
+
27
+ - Install dependencies
28
+ ```sh
29
+ bundle install
30
+ ```
31
+
32
+ #### Test
33
+
34
+ ```sh
35
+ bundle exec rspec
36
+ ```
37
+
38
+ The Logstash code required to run the tests/specs is specified in the `Gemfile` by the line similar to:
39
+ ```ruby
40
+ gem "logstash", :github => "elasticsearch/logstash", :branch => "1.5"
41
+ ```
42
+ To test against another version or a local Logstash, edit the `Gemfile` to specify an alternative location, for example:
43
+ ```ruby
44
+ gem "logstash", :github => "elasticsearch/logstash", :ref => "master"
45
+ ```
46
+ ```ruby
47
+ gem "logstash", :path => "/your/local/logstash"
48
+ ```
49
+
50
+ Then update your dependencies and run your tests:
51
+
52
+ ```sh
53
+ bundle install
54
+ bundle exec rspec
55
+ ```
56
+
57
+ ### 2. Running your unpublished Plugin in Logstash
58
+
59
+ #### 2.1 Run in a local Logstash clone
60
+
61
+ - Edit Logstash `tools/Gemfile` and add the local plugin path, for example:
62
+ ```ruby
63
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
64
+ ```
65
+ - Update Logstash dependencies
66
+ ```sh
67
+ rake vendor:gems
68
+ ```
69
+ - Run Logstash with your plugin
70
+ ```sh
71
+ bin/logstash -e 'filter {awesome {}}'
72
+ ```
73
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
74
+
75
+ #### 2.2 Run in an installed Logstash
76
+
77
+ - Build your plugin gem
78
+ ```sh
79
+ gem build logstash-filter-awesome.gemspec
80
+ ```
81
+ - Install the plugin from the Logstash home
82
+ ```sh
83
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
84
+ ```
85
+ - Start Logstash and proceed to test the plugin
86
+
87
+ ## Contributing
88
+
89
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
90
+
91
+ Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
92
+
93
+ It is more important to me that you are able to contribute.
94
+
95
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elasticsearch/logstash/blob/master/CONTRIBUTING.md) file.
@@ -1,12 +1,12 @@
1
1
  # encoding: utf-8
2
2
  require "logstash/filters/base"
3
3
  require "logstash/namespace"
4
+ require "logstash/util/charset"
4
5
  require "uri"
5
6
 
6
7
  # The urldecode filter is for decoding fields that are urlencoded.
7
8
  class LogStash::Filters::Urldecode < LogStash::Filters::Base
8
9
  config_name "urldecode"
9
- milestone 2
10
10
 
11
11
  # The field which value is urldecoded
12
12
  config :field, :validate => :string, :default => "message"
@@ -14,9 +14,17 @@ class LogStash::Filters::Urldecode < LogStash::Filters::Base
14
14
  # Urldecode all fields
15
15
  config :all_fields, :validate => :boolean, :default => false
16
16
 
17
+ # Thel character encoding used in this filter. Examples include `UTF-8`
18
+ # and `cp1252`
19
+ #
20
+ # This setting is useful if your url decoded string are in `Latin-1` (aka `cp1252`)
21
+ # or in another character set other than `UTF-8`.
22
+ config :charset, :validate => ::Encoding.name_list, :default => "UTF-8"
23
+
17
24
  public
18
25
  def register
19
- # Nothing to do
26
+ @converter = LogStash::Util::Charset.new(@charset)
27
+ @converter.logger = logger
20
28
  end #def register
21
29
 
22
30
  public
@@ -25,9 +33,7 @@ class LogStash::Filters::Urldecode < LogStash::Filters::Base
25
33
 
26
34
  # If all_fields is true then try to decode them all
27
35
  if @all_fields
28
- event.to_hash.each do |name, value|
29
- event[name] = urldecode(value)
30
- end
36
+ event.to_hash.each { |name, value| event[name] = urldecode(value) }
31
37
  # Else decode the specified field
32
38
  else
33
39
  event[@field] = urldecode(event[@field])
@@ -41,7 +47,8 @@ class LogStash::Filters::Urldecode < LogStash::Filters::Base
41
47
  def urldecode(value)
42
48
  case value
43
49
  when String
44
- return URI.unescape(value)
50
+ escaped = URI.unescape(value)
51
+ return @converter.convert(escaped)
45
52
  when Array
46
53
  ret_values = []
47
54
  value.each { |v| ret_values << urldecode(v) }
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-urldecode'
4
- s.version = '0.1.2'
4
+ s.version = '0.1.3'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "The urldecode filter is for decoding fields that are urlencoded."
7
7
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
@@ -4,7 +4,6 @@ require "logstash/devutils/rspec/spec_helper"
4
4
  require "logstash/filters/urldecode"
5
5
 
6
6
  describe LogStash::Filters::Urldecode do
7
-
8
7
  describe "urldecode of correct urlencoded data" do
9
8
  # The logstash config goes here.
10
9
  # At this time, only filters are supported.
@@ -48,7 +47,16 @@ describe LogStash::Filters::Urldecode do
48
47
  insist { subject["message"] } == "http://logstash.net/docs/1.3.2/filters/urldecode"
49
48
  insist { subject["nonencoded"] } == "http://logstash.net/docs/1.3.2/filters/urldecode"
50
49
  end
51
-
52
50
  end
53
51
 
52
+ describe "urldecode should replace invalid UTF-8" do
53
+ config <<-CONFIG
54
+ filter {
55
+ urldecode {}
56
+ }
57
+ CONFIG
58
+ sample("message" => "/a/sa/search?rgu=0;+%C3%BB%D3%D0%D5%D2%B5%BD=;+%B7%A2%CB%CD=") do
59
+ insist { subject["message"] } == "/a/sa/search?rgu=0;+û\\xD3\\xD0\\xD5ҵ\\xBD=;+\\xB7\\xA2\\xCB\\xCD="
60
+ end
61
+ end
54
62
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-urldecode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elasticsearch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-19 00:00:00.000000000 Z
11
+ date: 2015-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash
@@ -53,6 +53,7 @@ files:
53
53
  - .gitignore
54
54
  - Gemfile
55
55
  - LICENSE
56
+ - README.md
56
57
  - Rakefile
57
58
  - lib/logstash/filters/urldecode.rb
58
59
  - logstash-filter-urldecode.gemspec
@@ -79,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
80
  version: '0'
80
81
  requirements: []
81
82
  rubyforge_project:
82
- rubygems_version: 2.4.4
83
+ rubygems_version: 2.1.9
83
84
  signing_key:
84
85
  specification_version: 4
85
86
  summary: The urldecode filter is for decoding fields that are urlencoded.