chapinb / chickadee

Yet another IP address enrichment tool
https://chapinb.com/chickadee/
MIT License
8 stars 0 forks source link

Certain fields not working via config file #71

Open rj-chap opened 3 years ago

rj-chap commented 3 years ago

In previous versions of the chickadee, the mobile, proxy, & hosting fields displayed by default. These bad boys have since gone away since version 20201125.0. I decided to create a config file with the fields I'd like, and while the file is being picked up and parsed correctly, the fields within are not showing. The fields will show if I add them using the -f parameter.

To Reproduce

Showing fields config in chickadee.ini file, attempting to lookup 1.1.1[.]1 using this config file. Fields don't show. Forcing the fields via -f, works:

fields = status,message,continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,timezone,currency,isp,org,as,asname,reverse,mobile,proxy,hosting,query
$ chickadee -c ~/.chickadee.log 1.1.1.1 | jq
2020-12-05 13:34:52,631 chickadee.py INFO chickadee run:259 - Extracted 1 distinct IPs
{
  "status": "success",
  "country": "Australia",
  "countryCode": "AU",
  "region": "QLD",
  "regionName": "Queensland",
  "city": "South Brisbane",
  "zip": "4101",
  "lat": -27.4766,
  "lon": 153.0166,
  "timezone": "Australia/Brisbane",
  "isp": "Cloudflare, Inc",
  "org": "APNIC and Cloudflare DNS Resolver project",
  "as": "AS13335 Cloudflare, Inc.",
  "query": "1.1.1.1",
  "count": 1
}
$ chickadee -c ~/.chickadee.log -f status,message,continent,continentCode,country,countryCode,region,regionName,city,district,zip,lat,lon,timezone,currency,isp,org,as,asname,reverse,mobile,proxy,hosting,query 1.1.1.1 | jq
2020-12-05 13:35:14,644 chickadee.py INFO chickadee run:259 - Extracted 1 distinct IPs
{
  "status": "success",
  "continent": "Oceania",
  "continentCode": "OC",
  "country": "Australia",
  "countryCode": "AU",
  "region": "QLD",
  "regionName": "Queensland",
  "city": "South Brisbane",
  "district": "",
  "zip": "4101",
  "lat": -27.4766,
  "lon": 153.0166,
  "timezone": "Australia/Brisbane",
  "currency": "AUD",
  "isp": "Cloudflare, Inc",
  "org": "APNIC and Cloudflare DNS Resolver project",
  "as": "AS13335 Cloudflare, Inc.",
  "asname": "CLOUDFLARENET",
  "mobile": false,
  "proxy": false,
  "hosting": true,
  "query": "1.1.1.1",
  "message": null,
  "reverse": null
}

Another example with the fields I personally want in each run (versus all fields as shown above):

fields = query,count,status,country,countryCode,region,regionName,city,zip,lat,lon,timezone,isp,org,as,mobile,proxy,hosting
$ chickadee -c ~/.chickadee.log 1.1.1.1 | jq
2020-12-05 13:37:05,946 chickadee.py INFO chickadee run:259 - Extracted 1 distinct IPs
{
  "status": "success",
  "country": "Australia",
  "countryCode": "AU",
  "region": "QLD",
  "regionName": "Queensland",
  "city": "South Brisbane",
  "zip": "4101",
  "lat": -27.4766,
  "lon": 153.0166,
  "timezone": "Australia/Brisbane",
  "isp": "Cloudflare, Inc",
  "org": "APNIC and Cloudflare DNS Resolver project",
  "as": "AS13335 Cloudflare, Inc.",
  "query": "1.1.1.1",
  "count": 1
}
$ chickadee -c ~/.chickadee.log -f query,count,status,country,countryCode,region,regionName,city,zip,lat,lon,timezone,isp,org,as,mobile,proxy,hosting 1.1.1.1 | jq
2020-12-05 13:37:47,858 chickadee.py INFO chickadee run:259 - Extracted 1 distinct IPs
{
  "status": "success",
  "country": "Australia",
  "countryCode": "AU",
  "region": "QLD",
  "regionName": "Queensland",
  "city": "South Brisbane",
  "zip": "4101",
  "lat": -27.4766,
  "lon": 153.0166,
  "timezone": "Australia/Brisbane",
  "isp": "Cloudflare, Inc",
  "org": "APNIC and Cloudflare DNS Resolver project",
  "as": "AS13335 Cloudflare, Inc.",
  "mobile": false,
  "proxy": false,
  "hosting": true,
  "query": "1.1.1.1",
  "count": 1
}

And finally a default run with no config file provided (or available within the lookup path structure), showing that mobile, proxy, and hosting do not display:

2020-12-05 13:38:49,706 chickadee.py INFO chickadee run:259 - Extracted 1 distinct IPs
{
  "status": "success",
  "country": "Australia",
  "countryCode": "AU",
  "region": "QLD",
  "regionName": "Queensland",
  "city": "South Brisbane",
  "zip": "4101",
  "lat": -27.4766,
  "lon": 153.0166,
  "timezone": "Australia/Brisbane",
  "isp": "Cloudflare, Inc",
  "org": "APNIC and Cloudflare DNS Resolver project",
  "as": "AS13335 Cloudflare, Inc.",
  "query": "1.1.1.1",
  "count": 1
}

Version (please complete the following information):

Additional context none :)

chapinb commented 3 years ago

Thanks for the report Ryan! Sorry for the delay. I am looking at it, and what is strange is that in my debugger the fields from a config file show properly, but in the terminal they do not. I'll give an update when I iron out the issue.

In the meantime, I want to confirm that -c ~/.chickadee.log is pointing to a config file, not a log file, correct?

chapinb commented 3 years ago

Hey @rj-chap - can you do the following and share the output with me? Please be sure to omit sensitive data or send it directly to me if you'd prefer :)

  1. Uninstall chickadee with pip uninstall chickadee
  2. Re-install it using the git clone option specified on https://chapinb.com/chickadee/#installation
  3. Run chickadee -v 1.1.1.1 and share this output. This may contain API keys, so please remove those if you'd like to post it here.

My guess is that you're experiencing the same thing I just did, where I had a config file in a default location that took search order preference to the config file that I preferred. The unexpected config file did not have any fields specified (leading me to see defaults) instead of using the fields I specified in my intended config file. I have added a debug log message that shows the path to the config file used for parsing, hopefully that helps to identify if you have the same issue I encountered!