Code Monkey home page Code Monkey logo

gman's Introduction

Gman

Build Status Gem Version PRs Welcome

A ruby gem to check if the owner of a given email address or website is working for THE MAN (a.k.a verifies government domains). It will also provide you with metadata about the domain, such as the country, state, city, or agency, where applicable. It does this by leveraging the power of Naughty or Nice, the Public Suffix List, and the associated Ruby Gem.

You could theoretically use regex, but either you'll get a bunch of false positives, or your regex will be insanely complicated. gov.uk, may be valid, for example, but gov.fr is not (it's gouv.fr, for what it's worth). The solution? Use Public Suffix to verify that it's a valid public domain, then maintain a crowd-sourced sub-list of known global government and military domains. It should cover all US and international, government and military domains for both email and website verification.

See a domains that's missing or one that shouldn't be there? We'd love you to contribute.

Installation

Gman is a Ruby gem, so you'll need a little Ruby-fu to get it working. Simply

gem install gman

Or add this to your Gemfile before doing a bundle install:

gem 'gman'

Usage

In general

Verify email addresses

Gman.valid? "[email protected]" #=> true
Gman.valid? "[email protected]" #=> false

Verify domain

Gman.valid? "http://foo.bar.gov" #=> true
Gman.valid? "foo.bar.gov"        #=> true
Gman.valid? "foo.gov"            #=> true
Gman.valid? "foo.biz"            #=> false

Determine the type of domain

domain = Gman.new "whitehouse.gov"
domain.type     #=> :federal
domain.federal? #=> true
domain.state?   #=> false
domain.city?    #=> false
domain.county?  #=> false

Get information about the domain's geographic location (.gov and .us only)

domain = Gman.new "illinois.gov"
domain.state #=> "IL"
domain.city  #=> "springfield"

Get information about a .gov domain's owner

domain = Gman.new "whitehouse.gov"
domain.agency   #=> "Executive Office of the President"

Get the ISO Country Code information represented by a government domain

domain = Gman.new "whitehouse.gov" #=> #<Gman domain="whitehouse.gov" valid=true>
domain.country.name                #=> "United States"
domain.country.alpha2              #=> "US"
domain.country.alpha3              #=> "USA"
domain.country.currency            #=> "USD"
domain.country.calling_code        #=> "+1"

Check if a country is on the US Sanctions list

Gman.new("foo.gov.kp").sanctioned? #=> true

Command line

Getting information about a given domain

$ gman whitehouse.gov
Domain  : whitehouse.gov
Valid government domain
Type    : federal
Country : United States
State   : DC
City    : Washington
Agency  : Executive Office of the President

The command line tool will accept any domain-like string (email, url, etc.)

$ gman [email protected]
Domain  : illinois.gov
Valid government domain
Type    : state
Country : United States
State   : IL
City    : Springfield

Filter

Filters newline-separated email addresses from stdin. Example usage:

$ gman_filter < path/to/list/of/addresses.txt

Contributing

Contributions welcome! Please see the contribution guidelines for code contributions or for details on how to add, update, or delete government domains.

Credits

Heavily inspired by swot. Thanks @leereilly!

gman's People

Contributors

0xflotus avatar atvirasvilnius avatar benbalter avatar bjornarneson avatar brntbeer avatar dependabot[bot] avatar devscott avatar gildegoma avatar ianlee1521 avatar icetee avatar jbjonesjr avatar jsta avatar jsvine avatar konklone avatar leereilly avatar martinpaljak avatar marvinschopf avatar mikeee avatar mitio avatar nschonni avatar parkr avatar pborreli avatar seiteta avatar sfirke avatar sitle avatar smathermather-cm avatar spinnernicholas avatar stephenott avatar technima avatar willem640 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gman's Issues

Gov employee email requirements

So some considerations for government email proof requirements.

  1. Private contractors are often given government emails on a temp basis for contract work.
  2. What falls outside of the government employee definition?
    • Teachers with a public school board
    • Firefighter, police officer
    • nurse that works at a veterans hospital or nurse that works for the municipal public health clinic
    • An organization such as a Canadian crown corporation such as viarail.ca. It is listed as a government department/agency: http://gc.ca/depts/major/depind-eng.html, but I bet you would have a hard time finding someone who would say that a Via-Rail employee would be considered a "government employee". But another example of a crown corporation would be the Canadian Postal Service (canadapost.ca

Thoughts?

Identify type of government domain

Would be awesome if, given a domain, GMAn were able to return the type of government entity it belongs to.

At the very least, perhaps the rule group from domains.txt, but ideally, the country / state / city locality, even in a human-readable format.

Employees at State Universites

I noticed that Gman doesn't validate .edu email addresses for state universities. Is this because of the potential for students to sign up?

A number of universities, mine included, have different domains for employee versus student emails. For example, at George Mason University employee emails are @gmu.edu and student emails are @masonlive.gmu.edu. I haven't dug into the gem to see if this type of stratification is possible but before I go about submitting a PR I wanted make sure there wasn't another reason that .edu was being excluded so I don't do some unwanted work. :)

Domain Takedown Request

I am part of the IT Security Team for Forest County Potawatomi Tribe operating as Potawatomi Bingo Casino. You have 1 of our domains listed through your repositories. Please remove all instances of the following: fcpotwatomi.com.

Please let me know if you need more information to expediate this removal. Thank you!

Integrating gman with the Italian index of public administrations (IPA)

In Italy there are more than 20,000 public bodies, and only a few of them have a domain under the .gov.it hierarchy. This is due to a decision by AGID, whereby the .gov.it hierarchy is reserved for central public administrations only.

However, there do exist an official public API which returns the website for each public entity, the so-called IPA (Indice dei domicili digitali delle pubbliche amministrazioni e dei gestori di pubblici servizi).

IPA is mandated by the Italian law and managed by AGID. It can be queried by requesting a free-of-charge Authorization ID.

Thus, my proposal is to integrate gman with IPA so as to dynamically query the API and return an up-to-date response.

Other Countries might implement similar solutions as well.

@eutopian-eu

Ignore this issue

The non-US government tld for south africa is missing from the list.

It is gov.za

Also, their military tld is mil.za

Add US Military emails to github government

Is your feature request related to a problem? Please describe the problem you're trying to solve.

I dont see mail.mil as an approved domain for granting access to github government

Describe the solution you'd like

Id like to add mail.mil and dds.mil to the list of domains here https://github.com/benbalter/gman/blob/master/config/domains.txt

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.