waffle-maker 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86c85b0b4e8cf81b733e453d8b3f16f4536af97254fbb62976b1446547c94b55
4
- data.tar.gz: 4ee930d2a91365027f3ace92c1f6db686cf517d3261b71fbf6ba7729881719f1
3
+ metadata.gz: 71db571599237aa72ae48350e7d1d6436b4d695d915ec0a65c1aa1af0eefe6d9
4
+ data.tar.gz: 488435761c228e78e9aa713af706f7c650310c042501a769bb59abb1167cc86c
5
5
  SHA512:
6
- metadata.gz: 2972e67aba86c9451e432d1e798268e82dd17a9e0ff18a334d903da00467e2e90d3cae5a1dc79c214978f0c86ae3ecc6b747cf4ec205cc38d12a6a3afd2f17a6
7
- data.tar.gz: d03d5b3a4955eccd92158148a0aefdaee4d96950b59a1218208ab422566b8791d4449f02043908d13c5aeaf36a6cd6fbe01c3525802ec487c424efcc29b17be1
6
+ metadata.gz: ba73930d703b1725ec8fe204b4c8d77b2b8223b38afda57006c2f1290ff62f50c97b740366cf04d4f5294e4107061286b8dc4037aba6b7568d4474895e1f1e0a
7
+ data.tar.gz: f3174679237267adc0b8d0344bf45164250be567f5372d232955036f9e1fcf0df35fbe62ac11c1148253caa521fe7d13e28c01eb968791242ffa8b9c61400882
data/README.md CHANGED
@@ -24,16 +24,22 @@ Or install it yourself as:
24
24
 
25
25
  ## Usage
26
26
 
27
- ```ruby
28
- $ iconv -f cp932 -t utf-8 < alert-201912.txt | bundle exec rake waffle:filter
27
+ By passing the WAF log from the standard input, the log that matches the route is written to the standard output.
28
+
29
+ ```sh
30
+ $ bundle exec rake waffle:filter < alert-201912.txt
29
31
  ```
30
32
 
31
- with options
33
+ Depending on the execution environment, you may need to pre-convert the character encoding of the log.
32
34
 
33
- ```ruby
34
- $ iconv -f cp932 -t utf-8 < alert-201912.txt | bundle exec rake waffle:filter -f 2 -w 2
35
+ ```sh
36
+ $ iconv -f CP932 -t UTF-8 < alert-201912.txt | bundle exec rake waffle:filter
35
37
  ```
36
38
 
39
+ with options
40
+ - `-f`: Specify the column number (offset) that contains the Rails route path. default is `2`.
41
+ - `-w`: Specify the column number (offset) that contains the path in the WAF log. default is `2`.
42
+
37
43
  ## Contributing
38
44
 
39
45
  Bug reports and pull requests are welcome on GitHub at https://github.com/chibicco/waffle-maker.
data/lib/waffle/maker.rb CHANGED
@@ -46,7 +46,7 @@ module Waffle
46
46
  end
47
47
 
48
48
  def wafs
49
- @wafs ||= Waffle::Maker::Waf.new(options[:w]).all
49
+ @wafs ||= Waffle::Maker::Waf.new(options[:w])
50
50
  end
51
51
  end
52
52
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Waffle
4
4
  module Maker
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
@@ -16,14 +16,13 @@ module Waffle
16
16
  # { raw: "2019/01/01 01:01:01\t8.8.8.8\t/users\t攻撃\t○", path: "/users" },
17
17
  # ...
18
18
  # ]
19
- def all
20
- readlines.each.with_object([]) do |line, o|
21
- line.chomp.tap do |line|
22
- o << {
23
- raw: line,
24
- path: line.split(/#{parse_symbol}/)[path_position]
25
- }
26
- end
19
+ def each(&_block)
20
+ $stdin.each(chomp: true) do |line|
21
+ o = {
22
+ raw: line,
23
+ path: line.split(/#{parse_symbol}/)[path_position]
24
+ }
25
+ yield o
27
26
  end
28
27
  end
29
28
 
@@ -31,12 +30,6 @@ module Waffle
31
30
  def parse_symbol
32
31
  ENV.fetch("IFS", "\t")
33
32
  end
34
-
35
- private
36
-
37
- def readlines
38
- @readlines ||= $stdin.readlines
39
- end
40
33
  end
41
34
  end
42
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waffle-maker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - chibicco
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-20 00:00:00.000000000 Z
11
+ date: 2019-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler