|
662 | 662 | } |
663 | 663 | END |
664 | 664 |
|
| 665 | + events << <<-END |
| 666 | + { |
| 667 | + "@timestamp" : "2015-05-13T11:20:26.000Z", |
| 668 | + "netflow" : { |
| 669 | + "destinationIPv4Address" : "10.4.36.64", |
| 670 | + "destinationTransportPort" : 9200, |
| 671 | + "egressInterface" : 0, |
| 672 | + "flowEndSysUpTime" : 1356, |
| 673 | + "flowStartSysUpTime" : 1356, |
| 674 | + "icmpTypeCodeIPv4" : 0, |
| 675 | + "ingressInterface" : 0, |
| 676 | + "ipClassOfService" : 0, |
| 677 | + "ipVersion" : 4, |
| 678 | + "octetDeltaCount" : 60, |
| 679 | + "packetDeltaCount" : 1, |
| 680 | + "protocolIdentifier" : 6, |
| 681 | + "sourceIPv4Address" : "192.168.253.130", |
| 682 | + "sourceTransportPort" : 38254, |
| 683 | + "tcpControlBits" : 2, |
| 684 | + "version" : 10, |
| 685 | + "vlanId" : 0 |
| 686 | + }, |
| 687 | + "@version" : "1" |
| 688 | + } |
| 689 | + END |
| 690 | + |
| 691 | + events << <<-END |
| 692 | + { |
| 693 | + "@timestamp" : "2015-05-13T11:20:28.000Z", |
| 694 | + "netflow" : { |
| 695 | + "destinationIPv4Address" : "192.168.253.128", |
| 696 | + "destinationTransportPort" : 22, |
| 697 | + "egressInterface" : 0, |
| 698 | + "flowEndSysUpTime" : 14611, |
| 699 | + "flowStartSysUpTime" : 12727, |
| 700 | + "icmpTypeCodeIPv4" : 0, |
| 701 | + "ingressInterface" : 0, |
| 702 | + "ipClassOfService" : 0, |
| 703 | + "ipVersion" : 4, |
| 704 | + "octetDeltaCount" : 256, |
| 705 | + "packetDeltaCount" : 4, |
| 706 | + "protocolIdentifier" : 6, |
| 707 | + "sourceIPv4Address" : "192.168.253.1", |
| 708 | + "sourceTransportPort" : 60560, |
| 709 | + "tcpControlBits" : 24, |
| 710 | + "version" : 10, |
| 711 | + "vlanId" : 0 |
| 712 | + }, |
| 713 | + "@version" : "1" |
| 714 | + } |
| 715 | + END |
| 716 | + |
| 717 | + events << <<-END |
| 718 | + { |
| 719 | + "@timestamp" : "2015-05-13T11:20:28.000Z", |
| 720 | + "netflow" : { |
| 721 | + "destinationIPv4Address" : "192.168.253.1", |
| 722 | + "destinationTransportPort" : 60560, |
| 723 | + "egressInterface" : 0, |
| 724 | + "flowEndSysUpTime" : 14611, |
| 725 | + "flowStartSysUpTime" : 12727, |
| 726 | + "icmpTypeCodeIPv4" : 0, |
| 727 | + "ingressInterface" : 0, |
| 728 | + "ipClassOfService" : 0, |
| 729 | + "ipVersion" : 4, |
| 730 | + "octetDeltaCount" : 1916, |
| 731 | + "packetDeltaCount" : 3, |
| 732 | + "protocolIdentifier" : 6, |
| 733 | + "sourceIPv4Address" : "192.168.253.128", |
| 734 | + "sourceTransportPort" : 22, |
| 735 | + "tcpControlBits" : 24, |
| 736 | + "version" : 10, |
| 737 | + "vlanId" : 0 |
| 738 | + }, |
| 739 | + "@version" : "1" |
| 740 | + } |
| 741 | + END |
| 742 | + |
| 743 | + events << <<-END |
| 744 | + { |
| 745 | + "@timestamp" : "2015-05-13T11:20:28.000Z", |
| 746 | + "netflow" : { |
| 747 | + "destinationIPv4Address" : "192.168.253.128", |
| 748 | + "destinationTransportPort" : 22, |
| 749 | + "egressInterface" : 0, |
| 750 | + "flowEndSysUpTime" : 12726, |
| 751 | + "flowStartSysUpTime" : 12725, |
| 752 | + "icmpTypeCodeIPv4" : 0, |
| 753 | + "ingressInterface" : 0, |
| 754 | + "ipClassOfService" : 0, |
| 755 | + "ipVersion" : 4, |
| 756 | + "octetDeltaCount" : 168, |
| 757 | + "packetDeltaCount" : 2, |
| 758 | + "protocolIdentifier" : 6, |
| 759 | + "sourceIPv4Address" : "192.168.253.1", |
| 760 | + "sourceTransportPort" : 65308, |
| 761 | + "tcpControlBits" : 24, |
| 762 | + "version" : 10, |
| 763 | + "vlanId" : 0 |
| 764 | + }, |
| 765 | + "@version" : "1" |
| 766 | + } |
| 767 | + END |
| 768 | + |
| 769 | + |
| 770 | + events << <<-END |
| 771 | + { |
| 772 | + "@timestamp" : "2015-05-13T11:20:28.000Z", |
| 773 | + "netflow" : { |
| 774 | + "destinationIPv4Address" : "192.168.253.1", |
| 775 | + "destinationTransportPort" : 65308, |
| 776 | + "egressInterface" : 0, |
| 777 | + "flowEndSysUpTime" : 12726, |
| 778 | + "flowStartSysUpTime" : 12725, |
| 779 | + "icmpTypeCodeIPv4" : 0, |
| 780 | + "ingressInterface" : 0, |
| 781 | + "ipClassOfService" : 0, |
| 782 | + "ipVersion" : 4, |
| 783 | + "octetDeltaCount" : 84, |
| 784 | + "packetDeltaCount" : 1, |
| 785 | + "protocolIdentifier" : 6, |
| 786 | + "sourceIPv4Address" : "192.168.253.128", |
| 787 | + "sourceTransportPort" : 22, |
| 788 | + "tcpControlBits" : 24, |
| 789 | + "version" : 10, |
| 790 | + "vlanId" : 0 |
| 791 | + }, |
| 792 | + "@version" : "1" |
| 793 | + } |
| 794 | + END |
| 795 | + |
| 796 | + events << <<-END |
| 797 | + { |
| 798 | + "@timestamp" : "2015-05-13T11:20:28.000Z", |
| 799 | + "netflow" : { |
| 800 | + "destinationIPv4Address" : "224.0.0.251", |
| 801 | + "destinationTransportPort" : 5353, |
| 802 | + "egressInterface" : 0, |
| 803 | + "flowEndSysUpTime" : 12741, |
| 804 | + "flowStartSysUpTime" : 12741, |
| 805 | + "icmpTypeCodeIPv4" : 0, |
| 806 | + "ingressInterface" : 0, |
| 807 | + "ipClassOfService" : 0, |
| 808 | + "ipVersion" : 4, |
| 809 | + "octetDeltaCount" : 232, |
| 810 | + "packetDeltaCount" : 1, |
| 811 | + "protocolIdentifier" : 17, |
| 812 | + "sourceIPv4Address" : "192.168.253.1", |
| 813 | + "sourceTransportPort" : 5353, |
| 814 | + "tcpControlBits" : 0, |
| 815 | + "version" : 10, |
| 816 | + "vlanId" : 0 |
| 817 | + }, |
| 818 | + "@version" : "1" |
| 819 | + } |
| 820 | + END |
| 821 | + |
665 | 822 | end |
666 | 823 |
|
667 | 824 | it "should decode raw data" do |
668 | | - expect(decode.size).to eq(7) |
| 825 | + expect(decode.size).to eq(13) |
669 | 826 |
|
670 | 827 | expect(decode[0].get("[netflow][version]")).to eq(10) |
671 | 828 | expect(decode[0].get("[netflow][systemInitTimeMilliseconds]")).to eq(1431516013506) |
|
711 | 868 | expect(decode[6].get("[netflow][destinationTransportPort]")).to eq(443) |
712 | 869 | expect(decode[6].get("[netflow][protocolIdentifier]")).to eq(6) |
713 | 870 | expect(decode[6].get("[netflow][tcpControlBits]")).to eq(26) |
| 871 | + |
| 872 | + expect(decode[7].get("[netflow][sourceIPv4Address]")).to eq("192.168.253.130") |
| 873 | + expect(decode[7].get("[netflow][destinationIPv4Address]")).to eq("10.4.36.64") |
| 874 | + expect(decode[7].get("[netflow][sourceTransportPort]")).to eq(38254) |
| 875 | + expect(decode[7].get("[netflow][destinationTransportPort]")).to eq(9200) |
| 876 | + expect(decode[7].get("[netflow][protocolIdentifier]")).to eq(6) |
| 877 | + expect(decode[7].get("[netflow][tcpControlBits]")).to eq(2) |
| 878 | + |
| 879 | + expect(decode[8].get("[netflow][sourceIPv4Address]")).to eq("192.168.253.1") |
| 880 | + expect(decode[8].get("[netflow][destinationIPv4Address]")).to eq("192.168.253.128") |
| 881 | + expect(decode[8].get("[netflow][sourceTransportPort]")).to eq(60560) |
| 882 | + expect(decode[8].get("[netflow][destinationTransportPort]")).to eq(22) |
| 883 | + expect(decode[8].get("[netflow][protocolIdentifier]")).to eq(6) |
| 884 | + expect(decode[8].get("[netflow][tcpControlBits]")).to eq(24) |
| 885 | + |
| 886 | + expect(decode[9].get("[netflow][sourceIPv4Address]")).to eq("192.168.253.128") |
| 887 | + expect(decode[9].get("[netflow][destinationIPv4Address]")).to eq("192.168.253.1") |
| 888 | + expect(decode[9].get("[netflow][sourceTransportPort]")).to eq(22) |
| 889 | + expect(decode[9].get("[netflow][destinationTransportPort]")).to eq(60560) |
| 890 | + expect(decode[9].get("[netflow][protocolIdentifier]")).to eq(6) |
| 891 | + expect(decode[9].get("[netflow][tcpControlBits]")).to eq(24) |
| 892 | + |
| 893 | + expect(decode[10].get("[netflow][sourceIPv4Address]")).to eq("192.168.253.1") |
| 894 | + expect(decode[10].get("[netflow][destinationIPv4Address]")).to eq("192.168.253.128") |
| 895 | + expect(decode[10].get("[netflow][sourceTransportPort]")).to eq(65308) |
| 896 | + expect(decode[10].get("[netflow][destinationTransportPort]")).to eq(22) |
| 897 | + expect(decode[10].get("[netflow][protocolIdentifier]")).to eq(6) |
| 898 | + expect(decode[10].get("[netflow][tcpControlBits]")).to eq(24) |
| 899 | + |
| 900 | + expect(decode[11].get("[netflow][sourceIPv4Address]")).to eq("192.168.253.128") |
| 901 | + expect(decode[11].get("[netflow][destinationIPv4Address]")).to eq("192.168.253.1") |
| 902 | + expect(decode[11].get("[netflow][sourceTransportPort]")).to eq(22) |
| 903 | + expect(decode[11].get("[netflow][destinationTransportPort]")).to eq(65308) |
| 904 | + expect(decode[11].get("[netflow][protocolIdentifier]")).to eq(6) |
| 905 | + expect(decode[11].get("[netflow][tcpControlBits]")).to eq(24) |
| 906 | + |
| 907 | + expect(decode[12].get("[netflow][sourceIPv4Address]")).to eq("192.168.253.1") |
| 908 | + expect(decode[12].get("[netflow][destinationIPv4Address]")).to eq("224.0.0.251") |
| 909 | + expect(decode[12].get("[netflow][sourceTransportPort]")).to eq(5353) |
| 910 | + expect(decode[12].get("[netflow][destinationTransportPort]")).to eq(5353) |
| 911 | + expect(decode[12].get("[netflow][protocolIdentifier]")).to eq(17) |
| 912 | + expect(decode[12].get("[netflow][tcpControlBits]")).to eq(0) |
714 | 913 | end |
715 | 914 |
|
716 | 915 | it "should serialize to json" do |
|
721 | 920 | expect(JSON.parse(decode[4].to_json)).to eq(JSON.parse(json_events[4])) |
722 | 921 | expect(JSON.parse(decode[5].to_json)).to eq(JSON.parse(json_events[5])) |
723 | 922 | expect(JSON.parse(decode[6].to_json)).to eq(JSON.parse(json_events[6])) |
| 923 | + expect(JSON.parse(decode[7].to_json)).to eq(JSON.parse(json_events[7])) |
| 924 | + expect(JSON.parse(decode[8].to_json)).to eq(JSON.parse(json_events[8])) |
| 925 | + expect(JSON.parse(decode[9].to_json)).to eq(JSON.parse(json_events[9])) |
| 926 | + expect(JSON.parse(decode[10].to_json)).to eq(JSON.parse(json_events[10])) |
| 927 | + expect(JSON.parse(decode[11].to_json)).to eq(JSON.parse(json_events[11])) |
| 928 | + expect(JSON.parse(decode[12].to_json)).to eq(JSON.parse(json_events[12])) |
724 | 929 | end |
725 | 930 |
|
726 | 931 | end |
|
0 commit comments