logstash-filter-useragent 2.0.8 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/Gemfile +3 -1
- data/LICENSE +1 -1
- data/README.md +12 -2
- data/lib/logstash/filters/useragent.rb +11 -11
- data/logstash-filter-useragent.gemspec +3 -3
- data/spec/filters/useragent_spec.rb +13 -13
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 598bbd9355cf951cd710c2b09fadc85853f26522
|
4
|
+
data.tar.gz: 767669dbe7e9824374f47c99d24a4e776d0dc96c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aecb151986072624ead48ca4fd894a5161ad9513a3c36751fe97db8347129ef3f889a9902bcdcdc25230182890ae4c9499ebae08e2b776120609abf1abe8cab2
|
7
|
+
data.tar.gz: 6d4af28f0a412d5765a6723689d02f760f5a2aa4e649ae1acc0a2f2064884612a93250572a322e5e405a6bea6cb6d577cf1bd8660d180deba9b23f789defff0c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
## 3.0.0
|
2
|
+
- Update the plugin to the version 2.0 of the plugin api, this change is required for Logstash 5.0 compatibility. See https://github.com/elastic/logstash/issues/5141
|
1
3
|
# 2.0.8
|
2
4
|
- Revert addition of Mutex. This plugin now depends on jruby having threadsafe regexps
|
3
5
|
# 2.0.7
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Logstash Plugin
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/logstash-plugins/logstash-filter-useragent.svg
|
3
|
+
[![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-filter-useragent.svg)](https://travis-ci.org/logstash-plugins/logstash-filter-useragent)
|
4
4
|
|
5
5
|
This is a plugin for [Logstash](https://github.com/elastic/logstash).
|
6
6
|
|
@@ -55,7 +55,12 @@ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
|
|
55
55
|
```
|
56
56
|
- Install plugin
|
57
57
|
```sh
|
58
|
+
# Logstash 2.3 and higher
|
59
|
+
bin/logstash-plugin install --no-verify
|
60
|
+
|
61
|
+
# Prior to Logstash 2.3
|
58
62
|
bin/plugin install --no-verify
|
63
|
+
|
59
64
|
```
|
60
65
|
- Run Logstash with your plugin
|
61
66
|
```sh
|
@@ -73,7 +78,12 @@ gem build logstash-filter-awesome.gemspec
|
|
73
78
|
```
|
74
79
|
- Install the plugin from the Logstash home
|
75
80
|
```sh
|
76
|
-
|
81
|
+
# Logstash 2.3 and higher
|
82
|
+
bin/logstash-plugin install --no-verify
|
83
|
+
|
84
|
+
# Prior to Logstash 2.3
|
85
|
+
bin/plugin install --no-verify
|
86
|
+
|
77
87
|
```
|
78
88
|
- Start Logstash and proceed to test the plugin
|
79
89
|
|
@@ -93,7 +93,7 @@ class LogStash::Filters::UserAgent < LogStash::Filters::Base
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def filter(event)
|
96
|
-
useragent = event
|
96
|
+
useragent = event.get(@source)
|
97
97
|
useragent = useragent.first if useragent.is_a?(Array)
|
98
98
|
|
99
99
|
return if useragent.nil? || useragent.empty?
|
@@ -135,7 +135,7 @@ class LogStash::Filters::UserAgent < LogStash::Filters::Base
|
|
135
135
|
def set_fields(event, ua_data)
|
136
136
|
# UserAgentParser outputs as US-ASCII.
|
137
137
|
|
138
|
-
event
|
138
|
+
event.set(@prefixed_name, ua_data.name.dup.force_encoding(Encoding::UTF_8))
|
139
139
|
|
140
140
|
#OSX, Andriod and maybe iOS parse correctly, ua-agent parsing for Windows does not provide this level of detail
|
141
141
|
|
@@ -143,23 +143,23 @@ class LogStash::Filters::UserAgent < LogStash::Filters::Base
|
|
143
143
|
# and corrupt the cache. See uap source here for details https://github.com/ua-parser/uap-ruby/tree/master/lib/user_agent_parser
|
144
144
|
if (os = ua_data.os)
|
145
145
|
# The OS is a rich object
|
146
|
-
event
|
147
|
-
event
|
146
|
+
event.set(@prefixed_os, ua_data.os.to_s.dup.force_encoding(Encoding::UTF_8))
|
147
|
+
event.set(@prefixed_os_name, os.name.dup.force_encoding(Encoding::UTF_8)) if os.name
|
148
148
|
|
149
149
|
# These are all strings
|
150
150
|
if (os_version = os.version)
|
151
|
-
event
|
152
|
-
event
|
151
|
+
event.set(@prefixed_os_major, os_version.major.dup.force_encoding(Encoding::UTF_8)) if os_version.major
|
152
|
+
event.set(@prefixed_os_minor, os_version.minor.dup.force_encoding(Encoding::UTF_8)) if os_version.minor
|
153
153
|
end
|
154
154
|
end
|
155
155
|
|
156
|
-
event
|
156
|
+
event.set(@prefixed_device, ua_data.device.to_s.dup.force_encoding(Encoding::UTF_8)) if ua_data.device
|
157
157
|
|
158
158
|
if (ua_version = ua_data.version)
|
159
|
-
event
|
160
|
-
event
|
161
|
-
event
|
162
|
-
event
|
159
|
+
event.set(@prefixed_major, ua_version.major.dup.force_encoding(Encoding::UTF_8)) if ua_version.major
|
160
|
+
event.set(@prefixed_minor, ua_version.minor.dup.force_encoding(Encoding::UTF_8)) if ua_version.minor
|
161
|
+
event.set(@prefixed_patch, ua_version.patch.dup.force_encoding(Encoding::UTF_8)) if ua_version.patch
|
162
|
+
event.set(@prefixed_build, ua_version.patch_minor.dup.force_encoding(Encoding::UTF_8)) if ua_version.patch_minor
|
163
163
|
end
|
164
164
|
end
|
165
165
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-filter-useragent'
|
4
|
-
s.version = '
|
4
|
+
s.version = '3.0.0'
|
5
5
|
s.licenses = ['Apache License (2.0)']
|
6
6
|
s.summary = "Parse user agent strings into structured data based on BrowserScope data"
|
7
|
-
s.description = "This gem is a
|
7
|
+
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
8
8
|
s.authors = ["Elastic"]
|
9
9
|
s.email = 'info@elastic.co'
|
10
10
|
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
|
21
21
|
|
22
22
|
# Gem dependencies
|
23
|
-
s.add_runtime_dependency "logstash-core-plugin-api", "~>
|
23
|
+
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
|
24
24
|
|
25
25
|
s.add_runtime_dependency 'user_agent_parser', ['>= 2.0.0']
|
26
26
|
s.add_runtime_dependency 'lru_redux', "~> 1.1.0"
|
@@ -17,10 +17,10 @@ describe LogStash::Filters::UserAgent do
|
|
17
17
|
|
18
18
|
sample "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31" do
|
19
19
|
insist { subject }.include?("ua")
|
20
|
-
insist { subject[
|
21
|
-
insist { subject[
|
22
|
-
insist { subject[
|
23
|
-
insist { subject[
|
20
|
+
insist { subject.get("[ua][name]") } == "Chrome"
|
21
|
+
insist { subject.get("[ua][os]") } == "Linux"
|
22
|
+
insist { subject.get("[ua][major]") } == "26"
|
23
|
+
insist { subject.get("[ua][minor]") } == "0"
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -34,10 +34,10 @@ describe LogStash::Filters::UserAgent do
|
|
34
34
|
CONFIG
|
35
35
|
|
36
36
|
sample "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31" do
|
37
|
-
insist { subject
|
38
|
-
insist { subject
|
39
|
-
insist { subject
|
40
|
-
insist { subject
|
37
|
+
insist { subject.get("name") } == "Chrome"
|
38
|
+
insist { subject.get("os") } == "Linux"
|
39
|
+
insist { subject.get("major") } == "26"
|
40
|
+
insist { subject.get("minor") } == "0"
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
@@ -91,7 +91,7 @@ describe LogStash::Filters::UserAgent do
|
|
91
91
|
}.each do |field, uad_getter|
|
92
92
|
context "for the #{field} field" do
|
93
93
|
let(:value) {uad_getter.call(ua_data)}
|
94
|
-
let(:target_field) { target
|
94
|
+
let(:target_field) { target.get(field)}
|
95
95
|
|
96
96
|
it "should not have a nil value" do
|
97
97
|
expect(target_field).to be_truthy
|
@@ -120,10 +120,10 @@ describe LogStash::Filters::UserAgent do
|
|
120
120
|
|
121
121
|
sample "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.63 Safari/537.31" do
|
122
122
|
insist { subject.to_hash }.include?("message")
|
123
|
-
insist { subject[
|
124
|
-
insist { subject[
|
125
|
-
insist { subject[
|
126
|
-
insist { subject[
|
123
|
+
insist { subject.get("[message][name]") } == "Chrome"
|
124
|
+
insist { subject.get("[message][os]") } == "Linux"
|
125
|
+
insist { subject.get("[message][major]") } == "26"
|
126
|
+
insist { subject.get("[message][minor]") } == "0"
|
127
127
|
end
|
128
128
|
end
|
129
129
|
end
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-filter-useragent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: '
|
18
|
+
version: '2.0'
|
19
19
|
name: logstash-core-plugin-api
|
20
20
|
prerelease: false
|
21
21
|
type: :runtime
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
29
29
|
requirements:
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description: This gem is a
|
69
|
+
description: This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program
|
70
70
|
email: info@elastic.co
|
71
71
|
executables: []
|
72
72
|
extensions: []
|