Class: Aoandon::Syntax
- Defined in:
- lib/aoandon/analysis/syntax.rb
Instance Method Summary collapse
-
#initialize(logger, options = {}) ⇒ Syntax
constructor
A new instance of Syntax.
- #test(packet) ⇒ Object
Methods inherited from Analysis
Constructor Details
#initialize(logger, options = {}) ⇒ Syntax
Returns a new instance of Syntax.
3 4 5 6 7 8 9 10 |
# File 'lib/aoandon/analysis/syntax.rb', line 3 def initialize(logger, = {}) super(logger, ) abort("Configuration file not found: #{[:file]}") unless File.exist?([:file]) @rules = Array(YAML::load_file([:file])['rules']).map {|rule| StaticRule.new(*rule) } puts "Ruleset: #{File.([:file])}" end |
Instance Method Details
#test(packet) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/aoandon/analysis/syntax.rb', line 12 def test(packet) @rules.each do |rule| if match?(packet, rule.context) break if (@last_rule = rule).['quick'] end end if @last_rule && @last_rule.action != 'pass' = @last_rule.['msg'] || 'Bad packet detected!' dump = @last_rule.['log'] ? packet : nil @logger.(packet.time.iso8601, 'SYNTAX', @last_rule.action, , dump) end end |