Skip to content
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

Can't extract the ASN database from its tar.gz file #71

Open
pmontrasio opened this issue Jun 21, 2017 · 0 comments
Open

Can't extract the ASN database from its tar.gz file #71

pmontrasio opened this issue Jun 21, 2017 · 0 comments

Comments

@pmontrasio
Copy link

pmontrasio commented Jun 21, 2017

The gem can't extract the ASN database defined in this vendor.json (I hope I got the semantic of files right)

[
    {
        "url": "http://geolite.maxmind.com/download/geoip/database/GeoLite2-ASN.tar.gz",
        "files": "GeoLite2-ASN.mmdb",
        "sha1": "ce70f043bf71602a211cef3565560e17d3543609"
     }
 ]

It's because of these lines in lib/logstash/devutils/rake/vendor.rake.

    161    if download =~ /.tar.gz/
    162      prefix = download.gsub('.tar.gz', '').gsub('vendor/', '')
    163      # prefix GeoLite2-ASN
    164      untar(download) do |entry|
    165        if !file['files'].nil?
    166          next unless file['files'].include?(entry.full_name.gsub(prefix, ''))
    167          out = entry.full_name.split("/").last
    168        end
    169        File.join('vendor', out)
    170      end
        ...

Two problems here:

  • the gsub at 166 turns GeoLite2-ASN_20170620/GeoLite2-ASN.mmdb into _20170620/.mmdb which won't match anything. A sub would do but it's not a general solution.
  • the order or the include? is wrong and should be reversed (the entry includes the files)

Fix: replace lines 166 and 167 with

              candidate = entry.full_name.split("/").last
              next unless candidate.include?(file['files'])
              out = candidate
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

No branches or pull requests

1 participant