Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to new event api #6

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
---
sudo: false
language: ruby
cache: bundler
jdk:
- oraclejdk8
rvm:
- jruby-1.7.23
script:
- bundle exec rspec spec
- jruby-1.7.25
before_script:
- bundle exec rake vendor
script:
- bundle exec rspec spec
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.0.0
- breaking: Updated plugin to use new Java Event APIs

## 2.0.4
- internal,deps: Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash

Expand Down
2 changes: 0 additions & 2 deletions lib/logstash/filters/cidr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ def register

public
def filter(event)


address = @address.collect do |a|
begin
IPAddr.new(event.sprintf(a))
Expand Down
5 changes: 3 additions & 2 deletions logstash-filter-cidr.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Gem::Specification.new do |s|

s.name = 'logstash-filter-cidr'
s.version = '2.0.4'
s.version = '3.0.0'
s.platform = 'java'
s.licenses = ['Apache License (2.0)']
s.summary = "The CIDR filter is for checking IP addresses in events against a list of network blocks that might contain it."
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"
Expand All @@ -20,7 +21,7 @@ Gem::Specification.new do |s|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }

# Gem dependencies
s.add_runtime_dependency "logstash-core-plugin-api", "~> 1.0"
s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"

s.add_development_dependency 'logstash-devutils'
end
Expand Down
21 changes: 10 additions & 11 deletions spec/filters/cidr_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
require "logstash/filters/cidr"

describe LogStash::Filters::CIDR do

# IPV4

describe "IPV4 match test" do
config <<-CONFIG
filter {
Expand All @@ -17,7 +16,7 @@
CONFIG

sample("clientip" => "192.168.0.30") do
insist { subject["tags"] }.include?("matched")
insist { subject.get("tags") }.include?("matched")
end
end

Expand All @@ -33,10 +32,10 @@
CONFIG

sample("clientip" => "123.52.122.33") do
insist { subject["tags"] }.nil?
insist { subject.get("tags") }.nil?
end
end

# Test multple CIDR blocks passed into 'network'. Make sure we try an
# IP in every range.

Expand All @@ -52,20 +51,20 @@
CONFIG

sample("clientip" => "192.168.0.30") do
insist { subject["tags"] }.include?("matched")
insist { subject.get("tags") }.include?("matched")
end

sample("clientip" => "10.10.220.3") do
insist { subject["tags"] }.include?("matched")
insist { subject.get("tags") }.include?("matched")
end

sample("clientip" => "172.16.45.50") do
insist { subject["tags"] }.include?("matched")
insist { subject.get("tags") }.include?("matched")
end

# No match
sample("clientip" => "8.8.8.8") do
insist { subject["tags"] }.nil?
insist { subject.get("tags") }.nil?
end

end
Expand All @@ -84,7 +83,7 @@
CONFIG

sample("clientip" => "fe80:0:0:0:0:0:0:1") do
insist { subject["tags"] }.include?("matched")
insist { subject.get("tags") }.include?("matched")
end
end

Expand All @@ -100,7 +99,7 @@
CONFIG

sample("clientip" => "fd82:0:0:0:0:0:0:1") do
insist { subject["tags"] }.nil?
insist { subject.get("tags") }.nil?
end
end

Expand Down