Skip to content

Commit

Permalink
add test for Cisco 106100 message
Browse files Browse the repository at this point in the history
Add test for the Cisco 106100 message type.
This commit relates to PR logstash-plugins#51 as that fixes a bug in parsing
policies with a naming containing a dash (-).
  • Loading branch information
frennkie authored and Pere Urbon-Bayes committed Jul 10, 2015
1 parent e93192e commit a6f7f2f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
4 changes: 2 additions & 2 deletions patterns/firewalls
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ CISCOFW106015 %{CISCO_ACTION:action} %{WORD:protocol} \(%{DATA:policy_id}\) from
# ASA-1-106021
CISCOFW106021 %{CISCO_ACTION:action} %{WORD:protocol} reverse path check from %{IP:src_ip} to %{IP:dst_ip} on interface %{GREEDYDATA:interface}
# ASA-4-106023
CISCOFW106023 %{CISCO_ACTION:action} %{WORD:protocol} src %{DATA:src_interface}:%{IP:src_ip}(/%{INT:src_port})?(\(%{DATA:src_fwuser}\))? dst %{DATA:dst_interface}:%{IP:dst_ip}(/%{INT:dst_port})?(\(%{DATA:dst_fwuser}\))?( \(type %{INT:icmp_type}, code %{INT:icmp_code}\))? by access-group %{DATA:policy_id} \[%{DATA:hashcode1}, %{DATA:hashcode2}\]
CISCOFW106023 %{CISCO_ACTION:action} %{WORD:protocol} src %{DATA:src_interface}:%{IP:src_ip}(/%{INT:src_port})?(\(%{DATA:src_fwuser}\))? dst %{DATA:dst_interface}:%{IP:dst_ip}(/%{INT:dst_port})?(\(%{DATA:dst_fwuser}\))?( \(type %{INT:icmp_type}, code %{INT:icmp_code}\))? by access-group %{NOTSPACE:policy_id} \[%{DATA:hashcode1}, %{DATA:hashcode2}\]
# ASA-5-106100
CISCOFW106100 access-list %{WORD:policy_id} %{CISCO_ACTION:action} %{WORD:protocol} %{DATA:src_interface}/%{IP:src_ip}\(%{INT:src_port}\)(\(%{DATA:src_fwuser}\))? -> %{DATA:dst_interface}/%{IP:dst_ip}\(%{INT:dst_port}\)(\(%{DATA:src_fwuser}\))? hit-cnt %{INT:hit_count} %{CISCO_INTERVAL:interval} \[%{DATA:hashcode1}, %{DATA:hashcode2}\]
CISCOFW106100 access-list %{NOTSPACE:policy_id} %{CISCO_ACTION:action} %{WORD:protocol} %{DATA:src_interface}/%{IP:src_ip}\(%{INT:src_port}\)(\(%{DATA:src_fwuser}\))? -> %{DATA:dst_interface}/%{IP:dst_ip}\(%{INT:dst_port}\)(\(%{DATA:src_fwuser}\))? hit-cnt %{INT:hit_count} %{CISCO_INTERVAL:interval} \[%{DATA:hashcode1}, %{DATA:hashcode2}\]
# ASA-6-110002
CISCOFW110002 %{CISCO_REASON:reason} for %{WORD:protocol} from %{DATA:src_interface}:%{IP:src_ip}/%{INT:src_port} to %{IP:dst_ip}/%{INT:dst_port}
# ASA-6-302010
Expand Down
35 changes: 33 additions & 2 deletions spec/patterns/firewalls_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

describe "FIREWALLS" do

let(:pattern) { "CISCOFW104001" }

let(:pattern104001) { "CISCOFW104001" }

context "parsing a 104001 message" do

let(:value) { "(Secondary) Switching to ACTIVE - Service card in other unit has failed" }

subject { grok_match(pattern, value) }
subject { grok_match(pattern104001, value) }

it { should include("switch_reason" => "Service card in other unit has failed") }

Expand All @@ -19,4 +20,34 @@
end
end

let(:pattern106100) { "CISCOFW106100" }

context "parsing a 106100 message" do

let(:value) { "access-list inside permitted tcp inside/10.10.123.45(51763) -> outside/192.168.67.89(80) hit-cnt 1 first hit [0x62c4905, 0x0]" }

subject { grok_match(pattern106100, value) }

it { should include("policy_id" => "inside") }

it "generates a message field" do
expect(subject["message"]).to include("access-list inside permitted tcp inside/10.10.123.45(51763) -> outside/192.168.67.89(80) hit-cnt 1 first hit [0x62c4905, 0x0]")
end
end

let(:pattern106100) { "CISCOFW106100" }

context "parsing a 106100 message with hypen in acl name" do

let(:value) { "access-list outside-entry permitted tcp outside/10.11.12.13(54726) -> inside/192.168.17.18(80) hit-cnt 1 300-second interval [0x32b3835, 0x0]" }

subject { grok_match(pattern106100, value) }

it { should include("policy_id" => "outside-entry") }

it "generates a message field" do
expect(subject["message"]).to include("access-list outside-entry permitted tcp outside/10.11.12.13(54726) -> inside/192.168.17.18(80) hit-cnt 1 300-second interval [0x32b3835, 0x0]")
end
end

end

0 comments on commit a6f7f2f

Please sign in to comment.