snort-rule 1.5.4 → 1.5.5

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: 2edb46ba49f19aed8a02939baca0f4fcc36f1513
4
- data.tar.gz: 50fc0ba0b7bda87b7b48da6f9e17f9e8b46ee8b2
3
+ metadata.gz: dc4abe51bf78ce86a278a1dfc65d3381364dc4b7
4
+ data.tar.gz: 6b73e841276f7afdc8bf92abfe8cedb4a8ba1258
5
5
  SHA512:
6
- metadata.gz: 4518b8425bc07539da1c942024fbc82ff05e87c55777bc2736a7c77752abdeabf4c84f836e0f1c43552b2f85e9cf719e9a9bff12b4482062aa93ac11dd2841e9
7
- data.tar.gz: b9e67ac011c246d1322c42aaf724c5990ee372456e35740603558df8a41516fb80b729d8e2b2e63b9d848ce0d12003a7661b624dda1714416d7ea45782af006f
6
+ metadata.gz: 15c7248b6abc41ad804a0f2642319004511b278e0e0c59c40950a4af87c09d995d7fa75fd647cb9d7840ecc6901f796132492ae7da021066904c9e1be5248255
7
+ data.tar.gz: d22ab9ddf0180e75880db08ce1453dd4b3ab776b1c924ed00edd31fa8bb2256fe0c0b2abc493d57d027d7041aa067db25067c7f795e96bae5912d870dbf0ca49
@@ -67,6 +67,24 @@ module Snort
67
67
  rule
68
68
  end
69
69
 
70
+ def to_json(options_only=false)
71
+ if options_only
72
+ @options.to_json
73
+ else
74
+ {
75
+ :enabled => @enabled,
76
+ :action => @action,
77
+ :proto => @proto,
78
+ :src => @src,
79
+ :sport => @sport,
80
+ :dir => @dir,
81
+ :dst => @dst,
82
+ :dport => @dport,
83
+ :options => @options
84
+ }.to_json
85
+ end
86
+ end
87
+
70
88
  def enable
71
89
  @enabled = true
72
90
  end
@@ -1,5 +1,5 @@
1
1
  module Snort
2
2
  class Rule
3
- VERSION = "1.5.4"
3
+ VERSION = "1.5.5"
4
4
  end
5
5
  end
@@ -88,6 +88,10 @@ module Snort
88
88
  @ruleset.length
89
89
  end
90
90
 
91
+ def each(&block)
92
+ @ruleset.each(&block)
93
+ end
94
+
91
95
  def count(&block)
92
96
  @ruleset.count(&block)
93
97
  end
@@ -51,6 +51,11 @@ class TestSnortCommunityRules < Minitest::Test
51
51
  assert_equal 2522, rules.count{|r| ! r.enabled}
52
52
  assert_equal 605, rules.count{|r| r.enabled}
53
53
  rules.disable_all
54
+ count = 0
55
+ rules.each do |rule|
56
+ count += 1
57
+ end
58
+ assert_equal 3127, count
54
59
  assert_equal 0, rules.count{|r| r.enabled}
55
60
  assert_equal 3127, rules.count{|r| ! r.enabled}
56
61
  rules.enable_all
@@ -94,5 +94,11 @@ class TestSnortRule < Minitest::Test
94
94
  Snort::Rule.parse("pass udp 192.168.0.1 bla bla bla 53 ( sid:48; threshold:type limit,track by_src,count 1,seconds 3600; )")
95
95
  end
96
96
  end
97
+
98
+ def test_dump_rule_to_json
99
+ require 'json'
100
+ rule = Snort::Rule.parse(" ### pass udp 192.168.0.1 any <> any 53 ( sid:48; threshold:type limit,track by_src,count 1,seconds 3600; )")
101
+ puts rule.to_json
102
+ end
97
103
 
98
104
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snort-rule
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - chrislee35
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-26 00:00:00.000000000 Z
11
+ date: 2014-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler