Skip to content

Update geoip databases to include data about documentation ranges #2450

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
merged 11 commits into from
Mar 10, 2025

Conversation

mrodm
Copy link
Contributor

@mrodm mrodm commented Mar 4, 2025

Closes #2414
Follows #2408

This PR includes new GeoIP databases including some entries for the documentation prefixes.

Added entries for the following address blocks for documentation in the GeoLite2 JSON files:

  • RFC
    • 192.0.2.0/24
    • 198.51.100.0/24
    • 203.0.113.0/24
  • RFC3849
    • 2001:DB8::/32
  • ASN for documentation defined in RFC

I've tried to use other "real" cities here (Las Vegas, Amsterdam and Madrid) as well as Greenwich (as mentioned in this blog post), and get the data about them using https://www.geonames.org/

This data set in those JSON files is faked just for testing purposes in elastic-package. This could affect system and pipeline tests.

Data added to the databases can be reviewed in this commit: 906b3a6

Moreover, some tests have been added to the isAllowedIPValue function as well as it has been used an IP of the documentation range in the test package apache.

Author's checklist

  • Add documentation
  • Add documentation prefixes into GeoIP databases
    • This data can be reviewed at: 906b3a6

How to test this PR locally

# ensure there is no stack running before doing "stack up"
elastic-package stack down -v

elastic-package stack up -v -d

# test package "apache" includes now an IP from one of the documentation ranges.
cd test/packages/parallel/apache
elastic-package test -v

elastic-package stack down -v

@mrodm mrodm self-assigned this Mar 4, 2025
@mrodm
Copy link
Contributor Author

mrodm commented Mar 5, 2025

test integrations

@elastic-vault-github-plugin-prod

Created or updated PR in integrations repository to test this version. Check elastic/integrations#12962

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried to use "real" cities here in the new entries. And for that, I got the data about them (geo codes or latitute/longitude values) using https://www.geonames.org/

The assignation of this ranges to those cities is faked and it is just for testing purposes in elastic-package.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you see any issue of using that data here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here it can be checked the specific data added (Las Vegas, Amsterdam and Madrid) and the Greenwich entry from this blog post:
906b3a6

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is fine to use real cities.

@mrodm
Copy link
Contributor Author

mrodm commented Mar 5, 2025

test integrations

@elastic-vault-github-plugin-prod

Created or updated PR in integrations repository to test this version. Check elastic/integrations#12962

@mrodm
Copy link
Contributor Author

mrodm commented Mar 6, 2025

test integrations

@elastic-vault-github-plugin-prod

Created or updated PR in integrations repository to test this version. Check elastic/integrations#12983

mrodm added 2 commits March 6, 2025 13:59
Include documentation about these GeoLite2 databases and how they should
be generated.
@mrodm mrodm force-pushed the update_geoip_databases branch from 88211de to 906b3a6 Compare March 6, 2025 13:18
@mrodm mrodm changed the title [system tests] Update geoip databases to include data about documentation ranges - WIP [system tests] Update geoip databases to include data about documentation ranges Mar 6, 2025
@mrodm mrodm changed the title [system tests] Update geoip databases to include data about documentation ranges Update geoip databases to include data about documentation ranges Mar 6, 2025
@mrodm mrodm marked this pull request as ready for review March 6, 2025 16:56
@mrodm mrodm requested a review from a team March 6, 2025 16:56
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is fine to use real cities.


Once applied all these changes, you can build the `write-test-data` tool:
```shell
git clone https://github.com/maxmind/MaxMind-DB
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point the repository should have been already cloned, and patched.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the latest changes, this section has been updated and now it just refers to the new tool.

Copy link
Contributor Author

@mrodm mrodm Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In https://github.com/maxmind/MaxMind-DB, this file and geoip2.go are located in another module (pkg/writer).

I thought to keep it simple here and just locate everything in just one package main.

@@ -4,3 +4,4 @@
89.160.20.156 - - [26/Dec/2016:18:23:35 +0200] "GET / HTTP/1.1" 200 45
89.160.20.156 - - [26/Dec/2016:18:23:41 +0200] "GET /notfound HTTP/1.1" 404 206
89.160.20.156 - - [26/Dec/2016:18:23:45 +0200] "GET /hmm HTTP/1.1" 404 201
192.0.2.100 - - [26/Dec/2016:18:23:45 +0200] "GET /hmm HTTP/1.1" 404 201
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New ip from the address block of documentation (192.0.2.100/24)

@mrodm mrodm requested a review from jsoriano March 7, 2025 16:07
Copy link
Member

@jsoriano jsoriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines 17 to 18
source := flag.String("source", "", "Source data directory")
target := flag.String("target", "", "Destination directory for the generated mmdb files")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit. We could hard-code these paths to the paths we have.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f6799e4
and updated README accordingly.

@elasticmachine
Copy link
Collaborator

💚 Build Succeeded

History

cc @mrodm

@mrodm mrodm merged commit 3d15e20 into elastic:main Mar 10, 2025
3 checks passed
@mrodm mrodm deleted the update_geoip_databases branch March 10, 2025 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace Geo IP database used in testing with dummy data
3 participants