rbl_mcafee 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +40 -0
- data/Rakefile +2 -0
- data/lib/rbl_mcafee.rb +26 -0
- data/lib/rbl_mcafee/version.rb +3 -0
- data/rbl_mcafee.gemspec +26 -0
- data/spec/rbl_mcafee_spec.rb +54 -0
- metadata +98 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: e88ee68265e7f5059b939a0a80b0384cf98722de
|
|
4
|
+
data.tar.gz: a4831171bbb5b21a1b6479a3b149e9475900f021
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a75b29e0171a8571fe0a00746eb528f1db6a1ee8b94a08d685d1b851c2145ef892ce02ef485258620e283c3a301c729fb52f301fc279aac3b2a6ec953d511213
|
|
7
|
+
data.tar.gz: 66990e44659aac9267640b85f7504f48359cd1b68c2392c59e8523292bc8a15e0b8e6a7839c0c748e5e99f11d49f76ad1ff227617f4f40d7749af605f3fd72c2
|
data/.gitignore
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
.bundle
|
|
4
|
+
.config
|
|
5
|
+
.yardoc
|
|
6
|
+
Gemfile.lock
|
|
7
|
+
InstalledFiles
|
|
8
|
+
_yardoc
|
|
9
|
+
coverage
|
|
10
|
+
doc/
|
|
11
|
+
lib/bundler/man
|
|
12
|
+
pkg
|
|
13
|
+
rdoc
|
|
14
|
+
spec/reports
|
|
15
|
+
test/tmp
|
|
16
|
+
test/version_tmp
|
|
17
|
+
tmp
|
|
18
|
+
*.bundle
|
|
19
|
+
*.so
|
|
20
|
+
*.o
|
|
21
|
+
*.a
|
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2016 romainsalles
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# RblMcafee
|
|
2
|
+
|
|
3
|
+
Solution to test if an IP address is listed in the McAfee RBL.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'rbl_mcafee'
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install rbl_mcafee
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
To verify if an IP address is listed in the McAfee RBL:
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
RblMcafee.blacklisted?('127.0.0.1')
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Expected returned values are the following:
|
|
28
|
+
|
|
29
|
+
* `true` when the IP address **is listed** in the McAfee RBL
|
|
30
|
+
* `false` when the IP address **isn't listed** in the McAfee RBL
|
|
31
|
+
|
|
32
|
+
When a **timeout** occurs, a `RblMcafee::Timeout` exception is raised.
|
|
33
|
+
|
|
34
|
+
## Contributing
|
|
35
|
+
|
|
36
|
+
1. Fork it ( https://github.com/romainsalles/rbl_mcafee/fork )
|
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
40
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/rbl_mcafee.rb
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require "rbl_mcafee/version"
|
|
2
|
+
require 'resolv'
|
|
3
|
+
|
|
4
|
+
module RblMcafee
|
|
5
|
+
# Indicates a timeout checking an IP address
|
|
6
|
+
class Timeout < TimeoutError; end
|
|
7
|
+
|
|
8
|
+
# @see https://kc.mcafee.com/corporate/index?page=content&id=KB53783
|
|
9
|
+
# If the reply is in the format 127.0.0.XXX, the host is listed in the McAfee
|
|
10
|
+
# RBL
|
|
11
|
+
MC_AFEE_RBL_LISTED_REGEX = /^127\.0\.0\.\d{1,3}$/
|
|
12
|
+
|
|
13
|
+
def self.blacklisted?(ip)
|
|
14
|
+
if !ip.match(Resolv::IPv6::Regex) && !ip.match(Resolv::IPv4::Regex)
|
|
15
|
+
raise ArgumentError, 'Invalid IP'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
resolved_ip = Resolv::getaddress("#{ip}.cidr.bl.mcafee.com")
|
|
19
|
+
return !!resolved_ip.match(MC_AFEE_RBL_LISTED_REGEX)
|
|
20
|
+
|
|
21
|
+
rescue Resolv::ResolvError
|
|
22
|
+
false
|
|
23
|
+
rescue Resolv::ResolvTimeout
|
|
24
|
+
raise RblMcafee::Timeout
|
|
25
|
+
end
|
|
26
|
+
end
|
data/rbl_mcafee.gemspec
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'rbl_mcafee/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "rbl_mcafee"
|
|
8
|
+
spec.version = RblMcafee::VERSION
|
|
9
|
+
spec.authors = ["Romain Salles"]
|
|
10
|
+
spec.email = ["romainsalles@users.noreply.github.com"]
|
|
11
|
+
spec.summary = %q{Solution to test if an IP address is listed in the
|
|
12
|
+
McAfee RBL}
|
|
13
|
+
spec.description = %q{Solution to test if an IP address is listed in the
|
|
14
|
+
McAfee RBL}
|
|
15
|
+
spec.homepage = "https://github.com/romainsalles/rbl_mcafee"
|
|
16
|
+
spec.license = "MIT"
|
|
17
|
+
|
|
18
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
21
|
+
spec.require_paths = ["lib"]
|
|
22
|
+
|
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
|
24
|
+
spec.add_development_dependency "rake"
|
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.4"
|
|
26
|
+
end
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require 'rbl_mcafee'
|
|
2
|
+
|
|
3
|
+
describe RblMcafee do
|
|
4
|
+
subject { RblMcafee.blacklisted?(ip_address) }
|
|
5
|
+
let(:ip_address) { '127.0.0.1' }
|
|
6
|
+
|
|
7
|
+
context 'with a non listed IP address' do
|
|
8
|
+
it 'returns false' do
|
|
9
|
+
Resolv.stub(:getaddress) { raise Resolv::ResolvError.new('whatever') }
|
|
10
|
+
|
|
11
|
+
expect(subject).to be false
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
context 'with a listed IP address' do
|
|
16
|
+
it 'returns true' do
|
|
17
|
+
Resolv.stub(:getaddress) { '127.0.0.11' }
|
|
18
|
+
|
|
19
|
+
expect(subject).to be true
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
context 'when a timeout error is raised by Resolv' do
|
|
24
|
+
it 'raises a RblMcafee::Timeout error' do
|
|
25
|
+
Resolv.stub(:getaddress) { raise Resolv::ResolvTimeout }
|
|
26
|
+
|
|
27
|
+
expect{subject}.to raise_error(RblMcafee::Timeout)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
context 'when an unknown exception is raised by Resolv' do
|
|
32
|
+
it 'is re-raised by .blacklisted?' do
|
|
33
|
+
Resolv.stub(:getaddress) { raise 'oops' }
|
|
34
|
+
|
|
35
|
+
expect{subject}.to raise_error('oops')
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
context 'when an invalid IP address is passed as argument' do
|
|
40
|
+
let(:ip_address) { '001.8.9.10' }
|
|
41
|
+
|
|
42
|
+
it 'raises an ArgumentError' do
|
|
43
|
+
expect{subject}.to raise_error(ArgumentError)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context 'when a valid website address is passed as argument' do
|
|
48
|
+
let(:ip_address) { 'www.mcafee.com' }
|
|
49
|
+
|
|
50
|
+
it 'raises an ArgumentError' do
|
|
51
|
+
expect{subject}.to raise_error(ArgumentError)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rbl_mcafee
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Romain Salles
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-03-30 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: '1.6'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.6'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.4'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.4'
|
|
55
|
+
description: |-
|
|
56
|
+
Solution to test if an IP address is listed in the
|
|
57
|
+
McAfee RBL
|
|
58
|
+
email:
|
|
59
|
+
- romainsalles@users.noreply.github.com
|
|
60
|
+
executables: []
|
|
61
|
+
extensions: []
|
|
62
|
+
extra_rdoc_files: []
|
|
63
|
+
files:
|
|
64
|
+
- ".gitignore"
|
|
65
|
+
- Gemfile
|
|
66
|
+
- LICENSE.txt
|
|
67
|
+
- README.md
|
|
68
|
+
- Rakefile
|
|
69
|
+
- lib/rbl_mcafee.rb
|
|
70
|
+
- lib/rbl_mcafee/version.rb
|
|
71
|
+
- rbl_mcafee.gemspec
|
|
72
|
+
- spec/rbl_mcafee_spec.rb
|
|
73
|
+
homepage: https://github.com/romainsalles/rbl_mcafee
|
|
74
|
+
licenses:
|
|
75
|
+
- MIT
|
|
76
|
+
metadata: {}
|
|
77
|
+
post_install_message:
|
|
78
|
+
rdoc_options: []
|
|
79
|
+
require_paths:
|
|
80
|
+
- lib
|
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
|
+
requirements:
|
|
83
|
+
- - ">="
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: '0'
|
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
|
+
requirements:
|
|
88
|
+
- - ">="
|
|
89
|
+
- !ruby/object:Gem::Version
|
|
90
|
+
version: '0'
|
|
91
|
+
requirements: []
|
|
92
|
+
rubyforge_project:
|
|
93
|
+
rubygems_version: 2.2.2
|
|
94
|
+
signing_key:
|
|
95
|
+
specification_version: 4
|
|
96
|
+
summary: Solution to test if an IP address is listed in the McAfee RBL
|
|
97
|
+
test_files:
|
|
98
|
+
- spec/rbl_mcafee_spec.rb
|