dap 1.2.5 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dap/filter/geoip2.rb +14 -5
- data/lib/dap/version.rb +1 -1
- data/test/filters.bats +13 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc89b6c18e84edad0cd26e060a2f398dc2e92593
|
4
|
+
data.tar.gz: 870aa9dc76ace284294e5594d5c260722beed4d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43e447d2885b368ecfe3e0c2a79591d7e24f6d35f4815ce560e1f4e25684aa99a63fb5d729bb60e3224d4ad31da43f027ee2e0fbe3c433cb88b09e6e4081cd13
|
7
|
+
data.tar.gz: ca4913ec986081556e90cbe9d330926da25cc00e5d0b4367285ca46ac31105f0da869181c4fe024bd20f40d3bd10ce8486a7f3b5f32924bb823b9b69430ea7b0
|
data/lib/dap/filter/geoip2.rb
CHANGED
@@ -33,6 +33,13 @@ module GeoIP2Library
|
|
33
33
|
nil
|
34
34
|
end
|
35
35
|
|
36
|
+
def get_maxmind_data(db, ip)
|
37
|
+
begin
|
38
|
+
db.get(ip)
|
39
|
+
rescue IPAddr::InvalidAddressError
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
36
43
|
def remove_empties(hash)
|
37
44
|
hash.each_pair do |k,v|
|
38
45
|
if v.empty?
|
@@ -78,8 +85,10 @@ class FilterGeoIP2City
|
|
78
85
|
unless @@geo_city
|
79
86
|
raise "No MaxMind GeoIP2::City data found"
|
80
87
|
end
|
81
|
-
|
88
|
+
|
82
89
|
ret = defaults
|
90
|
+
geo_hash = get_maxmind_data(@@geo_city, ip)
|
91
|
+
return unless geo_hash
|
83
92
|
|
84
93
|
if geo_hash.include?("subdivisions")
|
85
94
|
# handle countries that are divided into various subdivisions. generally 1, sometimes 2
|
@@ -143,9 +152,9 @@ class FilterGeoIP2Asn
|
|
143
152
|
unless @@geo_asn
|
144
153
|
raise "No MaxMind GeoIP2::ASN data found"
|
145
154
|
end
|
146
|
-
geo_hash = @@geo_asn.get(ip)
|
147
|
-
return unless geo_hash
|
148
155
|
|
156
|
+
geo_hash = get_maxmind_data(@@geo_asn, ip)
|
157
|
+
return unless geo_hash
|
149
158
|
ret = {}
|
150
159
|
|
151
160
|
if geo_hash.include?("autonomous_system_number")
|
@@ -174,9 +183,9 @@ class FilterGeoIP2Isp
|
|
174
183
|
unless @@geo_isp
|
175
184
|
raise "No MaxMind GeoIP2::ISP data found"
|
176
185
|
end
|
177
|
-
geo_hash = @@geo_isp.get(ip)
|
178
|
-
return unless geo_hash
|
179
186
|
|
187
|
+
geo_hash = get_maxmind_data(@@geo_isp, ip)
|
188
|
+
return unless geo_hash
|
180
189
|
ret = {}
|
181
190
|
|
182
191
|
if geo_hash.include?("autonomous_system_number")
|
data/lib/dap/version.rb
CHANGED
data/test/filters.bats
CHANGED
@@ -160,6 +160,11 @@ load ./test_common
|
|
160
160
|
run bash -c "echo 2a02:d9c0:: | GEOIP2_CITY_DATABASE_PATH=test/test_data/geoip2/GeoIP2-City-Test.mmdb $DAP_EXECUTABLE lines + geo_ip2_city line + json | jq -Sc -r ."
|
161
161
|
assert_success
|
162
162
|
assert_output '{"line":"2a02:d9c0::","line.geoip2.city.city.geoname_id":"0","line.geoip2.city.continent.code":"AS","line.geoip2.city.continent.geoname_id":"6255147","line.geoip2.city.continent.name":"Asia","line.geoip2.city.country.geoname_id":"298795","line.geoip2.city.country.is_in_european_union":"false","line.geoip2.city.country.iso_code":"TR","line.geoip2.city.country.name":"Turkey","line.geoip2.city.location.accuracy_radius":"100","line.geoip2.city.location.latitude":"39.05901","line.geoip2.city.location.longitude":"34.91155","line.geoip2.city.location.metro_code":"0","line.geoip2.city.location.time_zone":"Europe/Istanbul","line.geoip2.city.registered_country.geoname_id":"298795","line.geoip2.city.registered_country.is_in_european_union":"false","line.geoip2.city.registered_country.iso_code":"TR","line.geoip2.city.registered_country.name":"Turkey","line.geoip2.city.represented_country.geoname_id":"0","line.geoip2.city.represented_country.is_in_european_union":"false","line.geoip2.city.traits.is_anonymous_proxy":"false","line.geoip2.city.traits.is_satellite_provider":"false"}'
|
163
|
+
|
164
|
+
# test invalid IP
|
165
|
+
run bash -c "echo test | GEOIP2_CITY_DATABASE_PATH=test/test_data/geoip2/GeoIP2-City-Test.mmdb $DAP_EXECUTABLE lines + geo_ip2_city line + json | jq -Sc -r ."
|
166
|
+
assert_success
|
167
|
+
assert_output '{"line":"test"}'
|
163
168
|
}
|
164
169
|
|
165
170
|
@test "geo_ip2_asn" {
|
@@ -171,13 +176,20 @@ load ./test_common
|
|
171
176
|
run bash -c "echo 2600:7000:: | GEOIP2_ASN_DATABASE_PATH=test/test_data/geoip2/GeoLite2-ASN-Test.mmdb $DAP_EXECUTABLE lines + geo_ip2_asn line + json | jq -Sc -r ."
|
172
177
|
assert_success
|
173
178
|
assert_output '{"line":"2600:7000::","line.geoip2.asn.asn":"AS6939","line.geoip2.asn.asn_org":"Hurricane Electric, Inc."}'
|
179
|
+
|
180
|
+
# test invalid IP
|
181
|
+
run bash -c "echo test | GEOIP2_ASN_DATABASE_PATH=test/test_data/geoip2/GeoLite2-ASN-Test.mmdb $DAP_EXECUTABLE lines + geo_ip2_asn line + json | jq -Sc -r ."
|
182
|
+
assert_success
|
183
|
+
assert_output '{"line":"test"}'
|
174
184
|
}
|
175
185
|
|
176
186
|
@test "geo_ip2_isp" {
|
177
|
-
run bash -c "echo -e '12.81.92.0\n2600:7000
|
187
|
+
run bash -c "echo -e '12.81.92.0\n2600:7000::\ntest' | GEOIP2_ISP_DATABASE_PATH=test/test_data/geoip2/GeoIP2-ISP-Test.mmdb $DAP_EXECUTABLE lines + geo_ip2_isp line + json | jq -Sc -r ."
|
178
188
|
assert_line --index 0 '{"line":"12.81.92.0","line.geoip2.isp.asn":"AS7018","line.geoip2.isp.isp":"AT&T Services","line.geoip2.isp.org":"AT&T Services"}'
|
179
189
|
# test IPv6
|
180
190
|
assert_line --index 1 '{"line":"2600:7000::","line.geoip2.isp.asn":"AS6939","line.geoip2.isp.asn_org":"Hurricane Electric, Inc."}'
|
191
|
+
# test invalid IP
|
192
|
+
assert_line --index 2 '{"line":"test"}'
|
181
193
|
}
|
182
194
|
|
183
195
|
@test "geo_ip2_legacy_compat" {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rapid7 Research
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|