fluent-plugin-ufw 0.0.3 → 0.0.4

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: c71257b4fae307040cd23f60bed50163d90b8697
4
- data.tar.gz: 07e224c028339bfc0e9c4fb6b86324ed2e85c8b6
3
+ metadata.gz: 327bf9d605416f3711df25a1dd321466808ab38d
4
+ data.tar.gz: 846b003b4a06b26ea9bda0f190db70dbceab319c
5
5
  SHA512:
6
- metadata.gz: aa814ea8afb5b0e17c6029abbafb34a0f635bc6b232e79885dff49bc96cc680779618276a3d733712edf730896673084d5d91dc035815d6556fbf61c935f5624
7
- data.tar.gz: 5724616c78a568c9a6c13d5588ce9a69ae3c1ed8a7150070717e76b7718899f3de60aa8cfc473dedf0412cf08ebfd0183a7b0c15239aaf19367b65bd0d2c3397
6
+ metadata.gz: c3b8c1415317687bfcf6f7ccec3f4c47bbcc1fc6de389b8ef97adc741b46e257b87bd5e2d40166fd7838543e15dda284816c98175e4756448e921ff8c0fff424
7
+ data.tar.gz: c24a485875a92407fe9cdde3d607e38dc01a15856bc6b39a01e63d4699bea45acdece78213aec87e74144aa16945b9e6da6410a20dea0f1d9843d5b2a307e730
@@ -1,16 +1,20 @@
1
+ sudo: required
1
2
  language: ruby
2
- sudo: true
3
+ services:
4
+ - docker
3
5
  before_install:
4
6
  - gem update bundler
5
- - gem update
6
7
 
7
8
  rvm:
8
- # - 1.9.3
9
- # - 2.0
10
- - 2.1
11
- - 2.2
12
- - 2.3.3
13
- - 2.4.0
9
+ - 2.1.*
10
+ - 2.2.*
11
+ - 2.3.*
12
+ - 2.4.*
13
+ - 2.5.*
14
14
 
15
15
  gemfile:
16
16
  - Gemfile
17
+
18
+ after_script:
19
+ - docker-compose build
20
+ - docker-compose run builder ./run_appraisal.sh
data/Appraisals CHANGED
@@ -1,61 +1,22 @@
1
- appraise "fluentd-0.12.39" do
2
- gem "fluentd", "0.12.39"
1
+ appraise "fluentd-1.2.6" do
3
2
  end
4
3
 
5
- appraise "test-unit-3" do
6
- gem "fluentd", "0.12.39"
7
- gem "test-unit", "3.0.0"
8
- end
9
-
10
- appraise "test-unit-2" do
11
- gem "fluentd", "0.12.39"
12
- gem "test-unit", "2.0.0"
13
- end
14
-
15
- # ok
16
- appraise "test-unit-1" do
17
- gem "fluentd", "0.12.39"
18
- gem "test-unit", "1.2.3"
19
- end
20
-
21
- appraise "rake-0.9.2" do
22
- gem "fluentd", "0.12.39"
23
- gem "test-unit", "1.2.3"
24
- gem "rake", "0.9.2"
4
+ appraise "fluentd-1.2.6" do
5
+ gem "fluentd", "1.2.6"
25
6
  end
26
7
 
27
- appraise "appraisal-1.0.0" do
28
- gem "fluentd", "0.12.39"
29
- gem "test-unit", "1.2.3"
30
- gem "rake", "0.9.2"
31
- gem "appraisal", "1.0.0"
32
- end
33
-
34
- # ok
35
- appraise "fluentd-0.12.30" do
36
- gem "fluentd", "0.12.30"
37
- end
38
-
39
- # ng
40
- appraise "fluentd-0.12.29" do
41
- gem "fluentd", "0.12.29"
8
+ appraise "test-unit-3-1.2.6" do
9
+ gem "fluentd", "1.2.6"
10
+ gem "test-unit", "3.0.0"
42
11
  end
43
12
 
44
- # ok
45
- appraise "fluentd-0.12.25" do
46
- gem "fluentd", "0.12.25"
13
+ appraise "fluentd-0.14.22" do
14
+ gem "fluentd", "0.14.22"
47
15
  end
48
16
 
49
- # ok
50
- appraise "fluentd-0.12.22" do
51
- gem "fluentd", "0.12.22"
17
+ appraise "test-unit-3-0.14.22" do
18
+ gem "fluentd", "0.14.22"
19
+ gem "test-unit", "3.0.0"
52
20
  end
53
21
 
54
- appraise "fluentd-0.12.21" do
55
- gem "fluentd", "0.12.21"
56
- end
57
22
 
58
- # failed
59
- #appraise "fluentd-0.12.20" do
60
- # gem "fluentd", "0.12.20"
61
- #end
data/Dockerfile CHANGED
@@ -1,8 +1,11 @@
1
- FROM fluent/fluentd:v0.14.20
1
+ FROM ubuntu:16.04
2
+ LABEL maintainer "Takashi Masuyama <mamewotoko@gmail.com>"
2
3
 
3
- COPY pkg/fluent-plugin-ufw-*.gem .
4
- RUN gem install --local fluent-plugin-ufw-*.gem
4
+ RUN apt-get update && apt-get upgrade -y && apt-get install -y ruby git ruby-bundler ruby-dev curl make gcc
5
+ # install fluentd (gem)
6
+ RUN curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-xenial-td-agent3.sh | sed 's:sudo ::g' | sh
5
7
 
6
- COPY docker/etc/fluent.conf /fluentd/etc/
7
- RUN mkdir /var/log/ufw/
8
- COPY docker/var/log/ufw/ufw.log /var/log/ufw/
8
+ RUN mkdir work
9
+
10
+ WORKDIR work
11
+ VOLUME work
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
- fluent-plugin-ufw
1
+ fluent-plugin-ufw [![Build Status](https://travis-ci.org/mamewotoko/fluent-plugin-ufw.svg?branch=master)](https://travis-ci.org/mamewotoko/fluent-plugin-ufw) [![Gem Version](https://badge.fury.io/rb/fluent-plugin-ufw.svg)](https://badge.fury.io/rb/fluent-plugin-ufw)
2
2
  ==================
3
- [![Build Status](https://travis-ci.org/mamewotoko/fluent-plugin-ufw.svg?branch=master)](https://travis-ci.org/mamewotoko/fluent-plugin-ufw)
4
3
 
5
4
  A [fluent](https://www.fluentd.org/) plugin to parse [ufw](https://help.ubuntu.com/community/UFW) log
6
5
 
@@ -29,13 +28,28 @@ specify `format ufw` in fluent.config like example below.
29
28
  * read [Interpreting Log Entries of UFW](https://help.ubuntu.com/community/UFW#Interpreting_Log_Entries)
30
29
 
31
30
  ## Test
32
- ### A. Using installed fluetntd
31
+ ### Overview
32
+
33
+ Test tool
34
+
35
+ * a. unit-test
36
+ * b. appraisal
37
+ * c. manual
38
+
39
+ Test environment
40
+
41
+ * A. local pc
42
+ * B. Vagrant VirtualBox VM (`ubuntu/xenial64`)
43
+ * C. Docker
44
+
45
+ ### a. unit-test
46
+
33
47
  ```
34
48
  bundle install
35
49
  bundle exec rake
36
50
  ```
37
51
 
38
- ### B. Multiple version of fluentd with appraisal tool
52
+ ### b. Multiple version of fluentd with appraisal tool
39
53
 
40
54
  ```
41
55
  bundle install
@@ -43,32 +57,88 @@ appraisal install
43
57
  appraisal rake test
44
58
  ```
45
59
 
46
- ### C. Install gem and run with fluentd as docker container
47
-
48
- Run for fluentd version specified in Dockerfile
60
+ ### c. Install gem as fluentd plugin (manual test)
61
+ 1. build and install gem
49
62
 
50
63
  ```
51
- sh run_docker_test.sh
64
+ bundle exec rake build
65
+ gem install --local pkg/fluent-plugin-ufw-0.0.4.gem
52
66
  ```
53
67
 
54
- Run for multiple fluentd version
68
+ 2. write td-agent.conf
69
+
70
+ sample
55
71
 
56
72
  ```
57
- sh run_docker_test.sh
73
+ <source>
74
+ @type tail
75
+ time_key time
76
+ read_from_head true
77
+ format ufw
78
+
79
+ path /var/log/ufw.log
80
+ pos_file /var/log/td-agent/ufw.pos
81
+ tag ufw.combined
82
+ </source>
83
+
84
+ <match ufw.*>
85
+ @type file
86
+ path /var/log/td-agent/ufw.output
87
+ append true
88
+ flush_interval 5s
89
+ time_slice_format %Y%m%d
90
+ time_slice_wait 10m
91
+ time_format %Y%m%dT%H%M%S%z
92
+ </match>
58
93
  ```
59
94
 
60
- ## Install for development
61
- ### A. build gem file and install
95
+ 3. restart td-agent and check output
96
+
97
+ ### a. local pc (ubuntu/debian)
62
98
 
63
99
  ```
100
+ sudo apt-get update
101
+ sudo apt-get install -y ruby git ruby-bundler ruby-dev
102
+ curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-xenial-td-agent3.sh | sh
103
+
104
+ # clone this source using git
105
+
64
106
  bundle exec rake build
65
- gem install --local pkg/fluent-plugin-ufw-0.0.1.gem
107
+ gem install --local pkg/fluent-plugin-ufw-0.0.4.gem
108
+
109
+ ```
110
+
111
+ ### b. Vagrant
112
+
113
+ [Vagrantfile](Vagrantfile) is to run virtual box vm to build and test gem
114
+
115
+ 1. prepare
116
+
117
+ ```
118
+ vagrant up
119
+ ```
120
+
121
+ 2. login to vm
122
+
123
+ ```
124
+ vagrant ssh
125
+ cd /vagrant
126
+ ```
127
+
128
+ 3. run test
129
+
130
+ ### c. docker container
131
+
132
+ Build image for fluentd version specified in Dockerfile
133
+
134
+ ```
135
+ docker-compose build
66
136
  ```
67
137
 
68
- ### B. copy plugin file
138
+ Then, run test run_test.sh or run_appraisal.sh
69
139
 
70
140
  ```
71
- cp lib/fluent/plugin/parser_ufw.rb /etc/fluent/plugin/
141
+ docker-compose run builder ./run_test.sh
72
142
  ```
73
143
 
74
144
  ## License
@@ -91,7 +161,9 @@ limitations under the License.
91
161
 
92
162
  ## References
93
163
  * [UFW](https://help.ubuntu.com/community/UFW)
164
+ * [test-unit](https://test-unit.github.io/)
165
+ * [thoughtbot/appraisal](https://github.com/thoughtbot/appraisal)
94
166
 
95
167
  ----
96
168
  Takashi Masuyama < mamewotoko@gmail.com >
97
- http://mamewo.ddo.jp/
169
+ https://mamewo.ddo.jp/
data/TODO.md ADDED
@@ -0,0 +1,9 @@
1
+ TODO
2
+ ====
3
+ * add lint
4
+ * rubocop
5
+ * build gem using docker
6
+ * test using docker
7
+ * method A
8
+ * method B
9
+ * method C
@@ -0,0 +1,31 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # All Vagrant configuration is done below. The "2" in Vagrant.configure
5
+ # configures the configuration version (we support older styles for
6
+ # backwards compatibility). Please don't change it unless you know what
7
+ # you're doing.
8
+ Vagrant.configure(2) do |config|
9
+ config.vm.box = "ubuntu/xenial64"
10
+ config.vm.network "private_network", ip: "192.168.33.10"
11
+ config.vm.boot_timeout = 60 * 15
12
+
13
+ config.vm.provider "virtualbox" do |vb|
14
+ # Display the VirtualBox GUI when booting the machine
15
+ vb.gui = true
16
+
17
+ # Customize the amount of memory on the VM:
18
+ vb.memory = "1024"
19
+ end
20
+
21
+ config.vm.provision "shell", inline: <<-SHELL
22
+ sudo apt-get update
23
+ sudo apt-get install -y ruby git ruby-bundler ruby-dev
24
+ curl -L https://toolbelt.treasuredata.com/sh/install-ubuntu-xenial-td-agent3.sh | sh
25
+
26
+ cd /vagrant
27
+ bundle exec rake build
28
+ gem install --local pkg/fluent-plugin-ufw-0.0.4.gem
29
+ SHELL
30
+ end
31
+
@@ -1,6 +1,7 @@
1
1
  version: '2'
2
2
 
3
3
  services:
4
- fluent-plugin-ufw:
4
+ builder:
5
5
  build: .
6
-
6
+ volumes:
7
+ - .:/work
@@ -12,6 +12,7 @@
12
12
  <match ufw.*>
13
13
  @type file
14
14
  path /home/fluent/ufw.output
15
+ flush_interval 5s
15
16
  time_slice_format %Y%m%d
16
17
  time_slice_wait 10m
17
18
  time_format %Y%m%dT%H%M%S%z
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fluent-plugin-ufw"
6
- s.version = "0.0.3"
6
+ s.version = "0.0.4"
7
7
  s.authors = ["Takashi Masuyama"]
8
8
  s.email = ["mamewotoko@gmail.com"]
9
9
  s.homepage = "https://github.com/mamewotoko/fluent-plugin-ufw"
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.require_paths = ["lib"]
17
17
  s.license = "Apache-2.0"
18
18
 
19
- s.add_runtime_dependency "fluentd", [">= 0.12.21"]
19
+ s.add_runtime_dependency "fluentd", [">= 0.14.0", "< 2"]
20
20
 
21
21
  s.add_development_dependency "rake", [">= 0.9.2"]
22
22
  s.add_development_dependency "test-unit", [">= 1.2.3"]
@@ -1,7 +1,7 @@
1
- require 'fluent/parser'
1
+ require 'fluent/plugin/parser'
2
2
 
3
3
  module Fluent
4
- class TextParser
4
+ module Plugin
5
5
  class UFWParser < Parser
6
6
  # Register this parser as "time_key_value"
7
7
  Fluent::Plugin.register_parser("ufw", self)
@@ -41,7 +41,7 @@ module Fluent
41
41
  record[key] = value
42
42
  end
43
43
  record['time'] = m['time'] if @keep_time_key
44
-
44
+
45
45
  yield time, record
46
46
  end
47
47
  end
@@ -0,0 +1,5 @@
1
+ #! /bin/bash
2
+ set -e
3
+ bundle install
4
+ appraisal install
5
+ appraisal rake test
@@ -0,0 +1,6 @@
1
+ #! /bin/bash
2
+ set -e
3
+
4
+ bundle install
5
+ bundle exec rake
6
+
@@ -3,8 +3,8 @@ require 'test_helper'
3
3
  class UFWTest < Test::Unit::TestCase
4
4
  def setup
5
5
  Fluent::Test.setup
6
-
7
- @parser = Fluent::Test::ParserTestDriver.new(Fluent::TextParser::UFWParser).configure({})
6
+
7
+ @parser = Fluent::Test::Driver::Parser.new(Fluent::Plugin::UFWParser).configure({})
8
8
  @expected = {
9
9
  'host' => 'hostnm',
10
10
  'action' => 'UFW BLOCK',
@@ -35,7 +35,8 @@ class UFWTest < Test::Unit::TestCase
35
35
  expected_time = Time.strptime('1/Aug 19:03:54', '%d/%b %H:%M:%S')
36
36
  assert_equal(expected_time.to_i, time.to_i)
37
37
  assert_equal(@expected, record)
38
+ p record.to_json
38
39
  }
39
40
  end
40
-
41
+
41
42
  end
@@ -3,3 +3,4 @@ require 'fluent/plugin/parser_ufw'
3
3
 
4
4
  require 'test/unit'
5
5
  require 'fluent/test'
6
+ require 'fluent/test/driver/parser'
metadata CHANGED
@@ -1,69 +1,75 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-ufw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Masuyama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-05 00:00:00.000000000 Z
11
+ date: 2018-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.12.21
19
+ version: 0.14.0
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - '>='
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 0.14.0
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: 0.12.21
32
+ version: '2'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rake
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - '>='
37
+ - - ">="
32
38
  - !ruby/object:Gem::Version
33
39
  version: 0.9.2
34
40
  type: :development
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - '>='
44
+ - - ">="
39
45
  - !ruby/object:Gem::Version
40
46
  version: 0.9.2
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: test-unit
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - '>='
51
+ - - ">="
46
52
  - !ruby/object:Gem::Version
47
53
  version: 1.2.3
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
- - - '>='
58
+ - - ">="
53
59
  - !ruby/object:Gem::Version
54
60
  version: 1.2.3
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: appraisal
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - '>='
65
+ - - ">="
60
66
  - !ruby/object:Gem::Version
61
67
  version: '0'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - '>='
72
+ - - ">="
67
73
  - !ruby/object:Gem::Version
68
74
  version: '0'
69
75
  description: Fluentd plugin to parse ufw log
@@ -73,8 +79,8 @@ executables: []
73
79
  extensions: []
74
80
  extra_rdoc_files: []
75
81
  files:
76
- - .gitignore
77
- - .travis.yml
82
+ - ".gitignore"
83
+ - ".travis.yml"
78
84
  - Appraisals
79
85
  - Dockerfile
80
86
  - Dockerfile.template
@@ -82,14 +88,16 @@ files:
82
88
  - LICENSE.txt
83
89
  - README.md
84
90
  - Rakefile
91
+ - TODO.md
92
+ - Vagrantfile
85
93
  - docker-compose.yml
86
94
  - docker/Dockerfile
87
95
  - docker/etc/fluent.conf
88
96
  - docker/var/log/ufw/ufw.log
89
97
  - fluent-plugin-ufw.gemspec
90
98
  - lib/fluent/plugin/parser_ufw.rb
91
- - run_docker_all_test.sh
92
- - run_docker_test.sh
99
+ - run_appraisal.sh
100
+ - run_test.sh
93
101
  - test/fluent/plugin/test_parser_ufw.rb
94
102
  - test/test_helper.rb
95
103
  homepage: https://github.com/mamewotoko/fluent-plugin-ufw
@@ -102,17 +110,17 @@ require_paths:
102
110
  - lib
103
111
  required_ruby_version: !ruby/object:Gem::Requirement
104
112
  requirements:
105
- - - '>='
113
+ - - ">="
106
114
  - !ruby/object:Gem::Version
107
115
  version: '0'
108
116
  required_rubygems_version: !ruby/object:Gem::Requirement
109
117
  requirements:
110
- - - '>='
118
+ - - ">="
111
119
  - !ruby/object:Gem::Version
112
120
  version: '0'
113
121
  requirements: []
114
122
  rubyforge_project:
115
- rubygems_version: 2.0.14.1
123
+ rubygems_version: 2.5.2.1
116
124
  signing_key:
117
125
  specification_version: 4
118
126
  summary: Fluentd plugin to parse ufw log
@@ -1,8 +0,0 @@
1
- #! /bin/bash
2
- IMAGE_VERSION="v0.12.39 v0.14.20"
3
-
4
- for v in $IMAGE_VERSION; do
5
- sed "s/%%IMAGE_VERSION%%/$v/" Dockerfile.template > Dockerfile
6
- sh run_docker_test.sh
7
- done
8
-
@@ -1,7 +0,0 @@
1
- #! /bin/sh
2
- set -e
3
- docker-compose up --build -d
4
- sleep 10
5
- docker-compose exec fluent-plugin-ufw sh -c "cat /home/fluent/ufw.output.*" | grep SRC && echo ok
6
- docker-compose logs
7
- docker-compose down