-
Notifications
You must be signed in to change notification settings - Fork 80
Add support for MaxMind GeoIP2 Enterprise and Anonymous-IP databases #223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
edmocosta
merged 6 commits into
logstash-plugins:main
from
edmocosta:add-enterprise-anonymous-ip-dbs-support
May 22, 2024
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7dfef78
Added support for MaxMind GeoIP2 Enterprise and Anonymous IP databases
edmocosta b7a1487
Renamed classes to use singular and added UNKNOWN database warning
edmocosta 5a2c7b9
Add PR number to CHANGELOG.md
edmocosta 5b1a400
Downgraded MaxMind, Mockito libraries to keep it compatible with Java 8
edmocosta 75a85bc
Renamed ECS prefixes to ip_traits
edmocosta 9eac8ed
Update CHANGELOG.md and logstash-filter-geoip_jars.rb
edmocosta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
7.3.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# AUTOGENERATED BY THE GRADLE SCRIPT. DO NOT EDIT. | ||
|
||
require 'jar_dependencies' | ||
require_jar('com.maxmind.geoip2', 'geoip2', '2.9.0') | ||
require_jar('com.maxmind.db', 'maxmind-db', '1.2.2') | ||
require_jar('org.logstash.filters', 'logstash-filter-geoip', '6.0.0') | ||
require_jar('com.maxmind.geoip2', 'geoip2', '4.2.0') | ||
require_jar('com.maxmind.db', 'maxmind-db', '3.1.0') | ||
require_jar('org.logstash.filters', 'logstash-filter-geoip', '7.3.0') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
package org.logstash.filters.geoip; | ||
|
||
import java.util.Collections; | ||
import java.util.EnumSet; | ||
import java.util.Set; | ||
|
||
enum Database { | ||
|
||
CITY( | ||
"City", | ||
EnumSet.of( | ||
Field.IP, | ||
Field.CITY_NAME, | ||
Field.CONTINENT_CODE, | ||
Field.COUNTRY_NAME, | ||
Field.COUNTRY_CODE2, | ||
Field.COUNTRY_CODE3, | ||
Field.POSTAL_CODE, | ||
Field.DMA_CODE, | ||
Field.REGION_NAME, | ||
Field.REGION_ISO_CODE, | ||
Field.TIMEZONE, | ||
Field.LOCATION, | ||
Field.LATITUDE, | ||
Field.LONGITUDE | ||
) | ||
), | ||
COUNTRY( | ||
"Country", | ||
EnumSet.of( | ||
Field.IP, | ||
Field.COUNTRY_CODE2, | ||
Field.COUNTRY_NAME, | ||
Field.CONTINENT_NAME | ||
) | ||
), | ||
DOMAIN( | ||
"GeoIP2-Domain", | ||
EnumSet.of( | ||
Field.DOMAIN | ||
) | ||
), | ||
ASN( | ||
"GeoLite2-ASN", | ||
EnumSet.of( | ||
Field.IP, | ||
Field.AUTONOMOUS_SYSTEM_NUMBER, | ||
Field.AUTONOMOUS_SYSTEM_ORGANIZATION | ||
) | ||
), | ||
ISP( | ||
"GeoIP2-ISP", | ||
EnumSet.of( | ||
Field.IP, | ||
Field.AUTONOMOUS_SYSTEM_NUMBER, | ||
Field.AUTONOMOUS_SYSTEM_ORGANIZATION, | ||
Field.ISP, | ||
Field.ORGANIZATION | ||
) | ||
), | ||
ANONYMOUS_IP( | ||
"GeoIP2-Anonymous-IP", | ||
EnumSet.of( | ||
Field.HOSTING_PROVIDER, | ||
Field.TOR_EXIT_NODE, | ||
Field.ANONYMOUS_VPN, | ||
Field.ANONYMOUS, | ||
Field.PUBLIC_PROXY, | ||
Field.RESIDENTIAL_PROXY | ||
) | ||
), | ||
ENTERPRISE( | ||
"Enterprise", | ||
EnumSet.of( | ||
Field.IP, | ||
Field.COUNTRY_CODE2, | ||
Field.COUNTRY_NAME, | ||
Field.CONTINENT_NAME, | ||
Field.REGION_ISO_CODE, | ||
Field.REGION_NAME, | ||
Field.CITY_NAME, | ||
Field.LOCATION | ||
) | ||
), | ||
UNKNOWN( | ||
"Unknown", | ||
EnumSet.noneOf(Field.class) | ||
); | ||
|
||
private final String databaseType; | ||
private final Set<Field> defaultFields; | ||
|
||
Database(String databaseType, final Set<Field> defaultFields) { | ||
this.databaseType = databaseType; | ||
this.defaultFields = defaultFields; | ||
} | ||
|
||
public Set<Field> getDefaultFields() { | ||
return Collections.unmodifiableSet(defaultFields); | ||
} | ||
|
||
public static Database fromDatabaseType(final String type) { | ||
// It follows the same com.maxmind.geoip2.DatabaseReader#getDatabaseType logic | ||
if (type.contains(CITY.databaseType)) { | ||
return Database.CITY; | ||
} else if (type.contains(COUNTRY.databaseType)) { | ||
return Database.COUNTRY; | ||
} else if (type.contains(DOMAIN.databaseType)) { | ||
return Database.DOMAIN; | ||
} else if (type.contains(ASN.databaseType)) { | ||
return Database.ASN; | ||
} else if (type.contains(ISP.databaseType)) { | ||
return Database.ISP; | ||
} else if (type.contains(ENTERPRISE.databaseType)) { | ||
return Database.ENTERPRISE; | ||
} else if (type.contains(ANONYMOUS_IP.databaseType)) { | ||
return Database.ANONYMOUS_IP; | ||
} | ||
|
||
// The reason why we have this UNKNOWN type here, is to keep it backward compatible, | ||
// allowing the pipeline to start, even if the plugin is configured to a non supported | ||
// database type. | ||
return Database.UNKNOWN; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.