abuseipdb-rb 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +39 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/README.md +84 -0
- data/Rakefile +6 -0
- data/abuseipdb-rb.gemspec +42 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/abuseipdb.rb +26 -0
- data/lib/abuseipdb/client.rb +62 -0
- data/lib/abuseipdb/configuration.rb +25 -0
- data/lib/abuseipdb/endpoints/base.rb +20 -0
- data/lib/abuseipdb/endpoints/blacklist.rb +28 -0
- data/lib/abuseipdb/endpoints/check.rb +27 -0
- data/lib/abuseipdb/endpoints/check_block.rb +27 -0
- data/lib/abuseipdb/responses/base.rb +18 -0
- data/lib/abuseipdb/responses/blacklist.rb +7 -0
- data/lib/abuseipdb/responses/check.rb +7 -0
- data/lib/abuseipdb/responses/check_block.rb +7 -0
- data/lib/abuseipdb/version.rb +3 -0
- metadata +182 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bb09d7343787e2514429559e81bfe056219b4e44
|
4
|
+
data.tar.gz: a977cf1993936252b33b15d58f581aa16eb1dd9c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1f0325b0180925459fad0f82b00d25084b997769e3e04e95ff341024f907b578bfd2ddd192633047f6f8046c4438832b4db77fea70ca4f900bc9ef76e6f14060
|
7
|
+
data.tar.gz: e577b3e2dfae3de0d10bec32cd93ba255d7547dabb6e5313dad106d11bfd9337683b1a3ac002d7f3e57d219b2b50eeca11abef57ef572fd65d40539da0c88284
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Configurations: http://rubocop.readthedocs.io/en/latest/configuration/#configuration
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 2.5
|
5
|
+
|
6
|
+
Documentation:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Style/Encoding:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Style/AndOr:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Style/BracesAroundHashParameters:
|
16
|
+
EnforcedStyle: context_dependent
|
17
|
+
|
18
|
+
Metrics/LineLength:
|
19
|
+
Max: 120
|
20
|
+
|
21
|
+
Metrics/MethodLength:
|
22
|
+
Max: 20
|
23
|
+
|
24
|
+
Metrics/AbcSize:
|
25
|
+
Max: 20
|
26
|
+
|
27
|
+
TrailingBlankLines:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
FrozenStringLiteralComment:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
CaseIndentation:
|
34
|
+
# Valid values are: case, end
|
35
|
+
EnforcedStyle: case
|
36
|
+
IndentOneStep: true
|
37
|
+
|
38
|
+
#Metrics/CyclomaticComplexity:
|
39
|
+
# Severity: warning
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
abuseipdb-rb
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.5.1
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at falegk1@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Abuseipdb::Rb
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/abuseipdb-rb.svg)](https://badge.fury.io/rb/abuseipdb-rb)
|
4
|
+
[![Build Status](https://travis-ci.org/falegk/abuseipdb-rb.svg?branch=master)](https://travis-ci.org/falegk/abuseipdb-rb)
|
5
|
+
|
6
|
+
A Ruby client gem for the [AbuseIPDB](https://www.abuseipdb.com) service API
|
7
|
+
|
8
|
+
| Branch | AbuseIPDB API |
|
9
|
+
| ------ | ------ |
|
10
|
+
| _Master_ | [v2](https://docs.abuseipdb.com/#introduction) |
|
11
|
+
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'abuseipdb-rb'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install abuseipdb-rb
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
First set up configurations (Ex. for rails apps into config/initializers)
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
Abuseipdb.configure do |config|
|
35
|
+
config.api_key = "YOUR_ABUSEIPDB_API_KEY"
|
36
|
+
config.timeout = 20 # Default is 60s
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
Then just init a client an use it
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
client = Abuseipdb.client
|
44
|
+
|
45
|
+
# CHECK Endpoint
|
46
|
+
response = client.check.call(ipAddress: '8.8.8.8')
|
47
|
+
|
48
|
+
response.status
|
49
|
+
=> 200
|
50
|
+
response.body
|
51
|
+
=> {"data"=>{"ipAddress"=>"8.8.8.8", "isPublic"=>true,
|
52
|
+
"ipVersion"=>4, "isWhitelisted"=>true, "abuseConfidenceScore"=>0,
|
53
|
+
"countryCode"=>"US", "usageType"=>"Data Center/Web Hosting/Transit",
|
54
|
+
"isp"=>"Google LLC", "domain"=>"google.com", "totalReports"=>16,
|
55
|
+
"lastReportedAt"=>"2019-06-12T01:09:53+01:00"}}
|
56
|
+
|
57
|
+
```
|
58
|
+
|
59
|
+
## Current Endpoints
|
60
|
+
|
61
|
+
| Command | Endpoint |
|
62
|
+
| ------ | ------ |
|
63
|
+
| client = Abuseipdb.client | Init a client |
|
64
|
+
| client.check.call | https://api.abuseipdb.com/api/v2/check |
|
65
|
+
| client.blacklist.call | https://api.abuseipdb.com/api/v2/blacklist |
|
66
|
+
| client.check_block.call | https://api.abuseipdb.com/api/v2/check-block |
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
## Development
|
71
|
+
|
72
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
73
|
+
|
74
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
[Report issues / feature requests](https://github.com/falegk/abuseipdb-rb/issues) and [pull requests](https://github.com/falegk/abuseipdb-rb/pulls) are welcome.
|
79
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to
|
80
|
+
the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
81
|
+
|
82
|
+
## License
|
83
|
+
|
84
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "abuseipdb/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "abuseipdb-rb"
|
7
|
+
spec.version = Abuseipdb::VERSION
|
8
|
+
spec.authors = ["Antony Falegkos"]
|
9
|
+
spec.email = ["afalegk@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{A Ruby client gem for [AbuseIPDB](https://www.abuseipdb.com) service API}
|
12
|
+
spec.description = %q{AbuseIPDB is a project dedicated to helping combat the spread of hackers, spammers, and abusive activity on the internet.}
|
13
|
+
spec.homepage = "https://github.com/falegk/abuseipdb-rb"
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
if spec.respond_to?(:metadata)
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
20
|
+
spec.metadata["changelog_uri"] = "https://github.com/falegk/abuseipdb-rb/CHANGELOG.md"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
spec.bindir = "exe"
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
|
35
|
+
spec.add_development_dependency "bundler", "~> 2.0", ">= 1.16"
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
spec.add_development_dependency "vcr", '~> 4.0', '>= 4.0.0'
|
39
|
+
|
40
|
+
spec.add_runtime_dependency 'faraday', '~> 0.15', '>= 0.15.2'
|
41
|
+
spec.add_runtime_dependency 'faraday_middleware', '~> 0.13', '>= 0.12.2'
|
42
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "abuseipdb"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/abuseipdb.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require "abuseipdb/version"
|
2
|
+
require "abuseipdb/client"
|
3
|
+
|
4
|
+
module Abuseipdb
|
5
|
+
class Error < StandardError; end
|
6
|
+
|
7
|
+
class << self
|
8
|
+
attr_accessor :configuration
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.client
|
12
|
+
@client = Abuseipdb::Client.new(configuration)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.configuration
|
16
|
+
@configuration ||= Configuration.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.reset
|
20
|
+
@configuration = Configuration.new
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.configure
|
24
|
+
yield(configuration)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
|
4
|
+
require 'abuseipdb/configuration'
|
5
|
+
require 'abuseipdb/endpoints/base'
|
6
|
+
require 'abuseipdb/endpoints/check'
|
7
|
+
require 'abuseipdb/endpoints/blacklist'
|
8
|
+
require 'abuseipdb/endpoints/check_block'
|
9
|
+
|
10
|
+
module Abuseipdb
|
11
|
+
class Client
|
12
|
+
|
13
|
+
ENDPOINTS = [:check, :blacklist, :check_block].freeze
|
14
|
+
|
15
|
+
attr_reader :configuration
|
16
|
+
|
17
|
+
attr_accessor *ENDPOINTS
|
18
|
+
|
19
|
+
# options
|
20
|
+
# api_key Your API key
|
21
|
+
# api_version default v2
|
22
|
+
# timeout default 60 (seconds)
|
23
|
+
def initialize(configuration = Configuration.new)
|
24
|
+
@configuration = configuration
|
25
|
+
define_endpoint_methods
|
26
|
+
end
|
27
|
+
|
28
|
+
def api_connection(url = nil)
|
29
|
+
url ||= "https://api.abuseipdb.com/api/#{@configuration.api_version}/"
|
30
|
+
|
31
|
+
Faraday.new(url: url) do |faraday|
|
32
|
+
faraday.response :logger
|
33
|
+
faraday.request :json
|
34
|
+
faraday.ssl.verify = false
|
35
|
+
faraday.headers['Accept'] = 'application/json'
|
36
|
+
faraday.options.timeout = @configuration.timeout # open/read timeout in seconds
|
37
|
+
faraday.adapter Faraday.default_adapter
|
38
|
+
|
39
|
+
if @configuration.api_key
|
40
|
+
# faraday.set_authorization_header :Key, @configuration.api_key
|
41
|
+
faraday.headers['Key'] = @configuration.api_key
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def define_endpoint_methods
|
49
|
+
namespace = "Abuseipdb::Endpoints"
|
50
|
+
|
51
|
+
ENDPOINTS.each do |endpoint|
|
52
|
+
begin
|
53
|
+
endpoint_klass = Object.const_get("#{namespace}::#{endpoint.to_s.split('_').collect(&:capitalize).join}")
|
54
|
+
klass = endpoint_klass.new(self)
|
55
|
+
send("#{endpoint.to_s}=", klass)
|
56
|
+
rescue NameError => _ex
|
57
|
+
next
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Abuseipdb
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :api_version, :timeout, :api_key
|
4
|
+
|
5
|
+
def initialize(options = nil)
|
6
|
+
options = options ? default_options.merge(options) : default_options
|
7
|
+
|
8
|
+
return unless options.is_a?(Hash)
|
9
|
+
|
10
|
+
options.each do |config_name, config_value|
|
11
|
+
send("#{config_name}=", config_value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def default_options
|
18
|
+
{
|
19
|
+
api_version: 'v2',
|
20
|
+
timeout: 60,
|
21
|
+
api_key: nil
|
22
|
+
}
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'abuseipdb/responses/base'
|
3
|
+
|
4
|
+
module Abuseipdb
|
5
|
+
module Endpoints
|
6
|
+
class Base
|
7
|
+
attr_accessor :client, :config
|
8
|
+
attr_accessor :api, :api_version_path
|
9
|
+
|
10
|
+
def initialize(client)
|
11
|
+
@client = client
|
12
|
+
@config = @client.configuration
|
13
|
+
@api = @client.api_connection
|
14
|
+
|
15
|
+
@api_version_path = @client.configuration.api_version
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'abuseipdb/responses/blacklist'
|
2
|
+
|
3
|
+
module Abuseipdb
|
4
|
+
module Endpoints
|
5
|
+
class Blacklist < Base
|
6
|
+
PATH = 'blacklist'
|
7
|
+
|
8
|
+
def url_path
|
9
|
+
PATH
|
10
|
+
end
|
11
|
+
|
12
|
+
# params https://docs.abuseipdb.com/#blacklist-parameters
|
13
|
+
def call(params = {})
|
14
|
+
params = default_params(params)
|
15
|
+
response = @api.get(url_path, params)
|
16
|
+
Abuseipdb::Responses::Blacklist.new(response)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def default_params(params)
|
22
|
+
params.select do |key, _value| [:countMinimum, :maxAgeInDays, :confidenceMinimum,
|
23
|
+
:limit, :plaintext, :self].include?(key)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'abuseipdb/responses/check'
|
2
|
+
|
3
|
+
module Abuseipdb
|
4
|
+
module Endpoints
|
5
|
+
class Check < Base
|
6
|
+
PATH = 'check'
|
7
|
+
|
8
|
+
def url_path
|
9
|
+
PATH
|
10
|
+
end
|
11
|
+
|
12
|
+
# params https://docs.abuseipdb.com/#check-endpoint
|
13
|
+
def call(params = {})
|
14
|
+
params = default_params(params)
|
15
|
+
response = @api.get(url_path, params)
|
16
|
+
Abuseipdb::Responses::Check.new(response)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def default_params(params)
|
22
|
+
params.select do |key, _value| [:ipAddress, :maxAgeInDays, :verbose].include?(key)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'abuseipdb/responses/check_block'
|
2
|
+
|
3
|
+
module Abuseipdb
|
4
|
+
module Endpoints
|
5
|
+
class CheckBlock < Base
|
6
|
+
PATH = 'check-block'
|
7
|
+
|
8
|
+
def url_path
|
9
|
+
PATH
|
10
|
+
end
|
11
|
+
|
12
|
+
# params https://docs.abuseipdb.com/#check-block-endpoint
|
13
|
+
def call(params = {})
|
14
|
+
params = default_params(params)
|
15
|
+
response = @api.get(url_path, params)
|
16
|
+
Abuseipdb::Responses::CheckBlock.new(response)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def default_params(params)
|
22
|
+
params.select do |key, _value| [:network, :maxAgeInDays].include?(key)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Abuseipdb
|
4
|
+
module Responses
|
5
|
+
class Base
|
6
|
+
|
7
|
+
attr_accessor :body, :status
|
8
|
+
attr_accessor :raw_response
|
9
|
+
|
10
|
+
# @param response Faraday::Response
|
11
|
+
def initialize(response)
|
12
|
+
@raw_response = response
|
13
|
+
@body = JSON.parse(response.body)
|
14
|
+
@status = response.status
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,182 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: abuseipdb-rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Antony Falegkos
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-06-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.16'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.16'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '10.0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '10.0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: vcr
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '4.0'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 4.0.0
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '4.0'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 4.0.0
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: faraday
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0.15'
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 0.15.2
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0.15'
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 0.15.2
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: faraday_middleware
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - "~>"
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0.13'
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.12.2
|
111
|
+
type: :runtime
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.13'
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 0.12.2
|
121
|
+
description: AbuseIPDB is a project dedicated to helping combat the spread of hackers,
|
122
|
+
spammers, and abusive activity on the internet.
|
123
|
+
email:
|
124
|
+
- afalegk@gmail.com
|
125
|
+
executables: []
|
126
|
+
extensions: []
|
127
|
+
extra_rdoc_files: []
|
128
|
+
files:
|
129
|
+
- ".gitignore"
|
130
|
+
- ".idea/workspace.xml"
|
131
|
+
- ".rspec"
|
132
|
+
- ".rubocop.yml"
|
133
|
+
- ".ruby-gemset"
|
134
|
+
- ".ruby-version"
|
135
|
+
- ".travis.yml"
|
136
|
+
- CHANGELOG.md
|
137
|
+
- CODE_OF_CONDUCT.md
|
138
|
+
- Gemfile
|
139
|
+
- README.md
|
140
|
+
- Rakefile
|
141
|
+
- abuseipdb-rb.gemspec
|
142
|
+
- bin/console
|
143
|
+
- bin/setup
|
144
|
+
- lib/abuseipdb.rb
|
145
|
+
- lib/abuseipdb/client.rb
|
146
|
+
- lib/abuseipdb/configuration.rb
|
147
|
+
- lib/abuseipdb/endpoints/base.rb
|
148
|
+
- lib/abuseipdb/endpoints/blacklist.rb
|
149
|
+
- lib/abuseipdb/endpoints/check.rb
|
150
|
+
- lib/abuseipdb/endpoints/check_block.rb
|
151
|
+
- lib/abuseipdb/responses/base.rb
|
152
|
+
- lib/abuseipdb/responses/blacklist.rb
|
153
|
+
- lib/abuseipdb/responses/check.rb
|
154
|
+
- lib/abuseipdb/responses/check_block.rb
|
155
|
+
- lib/abuseipdb/version.rb
|
156
|
+
homepage: https://github.com/falegk/abuseipdb-rb
|
157
|
+
licenses: []
|
158
|
+
metadata:
|
159
|
+
homepage_uri: https://github.com/falegk/abuseipdb-rb
|
160
|
+
source_code_uri: https://github.com/falegk/abuseipdb-rb
|
161
|
+
changelog_uri: https://github.com/falegk/abuseipdb-rb/CHANGELOG.md
|
162
|
+
post_install_message:
|
163
|
+
rdoc_options: []
|
164
|
+
require_paths:
|
165
|
+
- lib
|
166
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
|
+
requirements:
|
173
|
+
- - ">="
|
174
|
+
- !ruby/object:Gem::Version
|
175
|
+
version: '0'
|
176
|
+
requirements: []
|
177
|
+
rubyforge_project:
|
178
|
+
rubygems_version: 2.5.2.1
|
179
|
+
signing_key:
|
180
|
+
specification_version: 4
|
181
|
+
summary: A Ruby client gem for [AbuseIPDB](https://www.abuseipdb.com) service API
|
182
|
+
test_files: []
|