コード例 #1
0
def verify_whois(domain):
    whois_results = whois.get_results(domain)
    if not whois_results:
        return False
    else:
        creation_date = whois_results.get('creation_date')
        if creation_date and creation_date > datetime.utcnow() - timedelta(days=Const.LIFE_LEN_PHISHING_CERT) :
            return True
        elif not whois_results['name'] and not whois_results['org']:
            return True
        else:
            return False
コード例 #2
0
 def test_get_results(self):
     url = "google.com"
     info("Requested url - {}".format(url))
     r = get_results(url)
     info("URL returned: {}".format(r))
     assert_type(r, dict, "Check if proper dict is returned")
     field = "registrar"
     assert_dict_contains_key(r, field, "Check if registrar is present in results")
     field = "creation_date"
     assert_dict_contains_key(r, field, "Check if registrar is present in results")
     field = "name"
     assert_dict_contains_key(r, field, "Check if registrar is present in results")
     field = "org"
     assert_dict_contains_key(r, field, "Check if registrar is present in results")
     field = "country"
     assert_dict_contains_key(r, field, "Check if registrar is present in results")
コード例 #3
0
def get_whois_details(url_body):
    try:
        jsonschema.validate(url_body, details_url_schema)
    except jsonschema.exceptions.ValidationError as exc:
        raise BadRequest(exc.message)

    domain = url_to_domain(url_body.get('url'))
    results = whois_module.get_results(domain)
    if not results:
        return _no_data_response()

    response_text = {
        "details": results
    }
    return Response(json.dumps(
            response_text,
            default=_default_json_model
            ), 200, mimetype="application/json")
コード例 #4
0
 def test_get_results_by_invalid_domain(self):
     url = ".com"
     info("Requested url - {}".format(url))
     r = get_results(url)
     info("URL returned: {}".format(r))
     assert_none(r, "Check if None is returned")