coppertone 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/.travis.yml +8 -5
- data/Gemfile +1 -1
- data/circle.yml +3 -0
- data/lib/coppertone/mechanism/domain_spec_mechanism.rb +4 -2
- data/lib/coppertone/mechanism/ip_mechanism.rb +12 -7
- data/lib/coppertone/modifier/base.rb +4 -2
- data/lib/coppertone/version.rb +1 -1
- data/spec/mechanism/ip4_spec.rb +3 -0
- data/spec/mechanism/ip6_spec.rb +3 -0
- data/spec/spec_helper.rb +8 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b252230ab963c880a9621e06ccab4e80228df66
|
4
|
+
data.tar.gz: 4429d3c99f23114ee76ae1a3ebb9e8523fabcac2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a81f77d79f3f6892093d051db6056412fd1b11906e15a923e7dfb0ab8e027be83aedfd0a680d0b794cee045acf940717cc9695747d0607cab7fae560da34b9ce
|
7
|
+
data.tar.gz: f539aa4c5f74a5469cafb28a66aa58b056e6cd4a4c071f0e14dd8be1e780dd4f8df20997d5b1948e4230469e11d8381ddfa5f2a28c59a12be02d1e1b3f3ea98a
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
sudo: false
|
2
2
|
language: ruby
|
3
|
-
env:
|
4
|
-
- CODECLIMATE_REPO_TOKEN=437199ed4348853fa1dd6561b2e17a5668a7a6e78485d7ac3a21d12670fb6f2f
|
5
3
|
rvm:
|
6
|
-
- 2.2.
|
7
|
-
- 2.3.
|
4
|
+
- 2.2.6
|
5
|
+
- 2.3.3
|
6
|
+
- 2.4.0
|
8
7
|
- jruby-9.1.5.0
|
9
|
-
|
8
|
+
addons:
|
9
|
+
code_climate:
|
10
|
+
repo_token: 437199ed4348853fa1dd6561b2e17a5668a7a6e78485d7ac3a21d12670fb6f2f
|
11
|
+
after_success:
|
12
|
+
- bundle exec codeclimate-test-reporter
|
data/Gemfile
CHANGED
data/circle.yml
ADDED
@@ -5,8 +5,10 @@ module Coppertone
|
|
5
5
|
attr_reader :domain_spec
|
6
6
|
|
7
7
|
def target_name_from_domain_spec(macro_context, request_context)
|
8
|
-
|
9
|
-
|
8
|
+
if domain_spec
|
9
|
+
domain =
|
10
|
+
domain_spec.expand(macro_context, request_context)
|
11
|
+
end
|
10
12
|
Coppertone::Utils::DomainUtils.macro_expanded_domain(domain)
|
11
13
|
end
|
12
14
|
|
@@ -2,7 +2,7 @@ module Coppertone
|
|
2
2
|
class Mechanism
|
3
3
|
# Implements the ip4 mechanism.
|
4
4
|
class IPMechanism < Mechanism
|
5
|
-
attr_reader :netblock
|
5
|
+
attr_reader :netblock, :cidr_length
|
6
6
|
def self.create(attributes)
|
7
7
|
new(attributes)
|
8
8
|
end
|
@@ -11,7 +11,7 @@ module Coppertone
|
|
11
11
|
super(attributes)
|
12
12
|
unless attributes.blank?
|
13
13
|
attributes = attributes[1..-1] if attributes[0] == ':'
|
14
|
-
@netblock = parse_netblock(attributes)
|
14
|
+
@netblock, @cidr_length = parse_netblock(attributes)
|
15
15
|
end
|
16
16
|
raise Coppertone::InvalidMechanismError if @netblock.nil?
|
17
17
|
end
|
@@ -31,13 +31,18 @@ module Coppertone
|
|
31
31
|
|
32
32
|
def parse_netblock(ip_as_s)
|
33
33
|
validate_no_leading_zeroes_in_cidr(ip_as_s)
|
34
|
-
addr,
|
35
|
-
return nil if dual
|
34
|
+
addr, cidr_length_as_s, dual = ip_as_s.split('/')
|
35
|
+
return [nil, nil] if dual
|
36
36
|
network = IPAddr.new(addr)
|
37
|
-
network = network.mask(
|
38
|
-
network
|
37
|
+
network = network.mask(cidr_length_as_s.to_i) unless cidr_length_as_s.blank?
|
38
|
+
cidr_length = cidr_length_as_s.blank? ? default_cidr(network) : cidr_length_as_s.to_i
|
39
|
+
[network, cidr_length]
|
39
40
|
rescue IP_PARSE_ERROR
|
40
|
-
nil
|
41
|
+
[nil, nil]
|
42
|
+
end
|
43
|
+
|
44
|
+
def default_cidr(network)
|
45
|
+
network.ipv6? ? 128 : 32
|
41
46
|
end
|
42
47
|
|
43
48
|
def match?(macro_context, _request_context)
|
@@ -12,8 +12,10 @@ module Coppertone
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def target_name_from_domain_spec(macro_context, request_context)
|
15
|
-
|
16
|
-
|
15
|
+
if domain_spec
|
16
|
+
domain =
|
17
|
+
domain_spec.expand(macro_context, request_context)
|
18
|
+
end
|
17
19
|
Coppertone::Utils::DomainUtils.macro_expanded_domain(domain)
|
18
20
|
end
|
19
21
|
|
data/lib/coppertone/version.rb
CHANGED
data/spec/mechanism/ip4_spec.rb
CHANGED
@@ -23,6 +23,7 @@ describe Coppertone::Mechanism::IP4 do
|
|
23
23
|
it 'should not fail if called with an IP v6' do
|
24
24
|
mech = Coppertone::Mechanism::IP4.new(':fe80::202:b3ff:fe1e:8329')
|
25
25
|
expect(mech.netblock).to eq(IPAddr.new('fe80::202:b3ff:fe1e:8329'))
|
26
|
+
expect(mech.cidr_length).to eq(128)
|
26
27
|
expect(mech.to_s).to eq('ip4:fe80::202:b3ff:fe1e:8329')
|
27
28
|
expect(mech).not_to be_includes_ptr
|
28
29
|
expect(mech).not_to be_context_dependent
|
@@ -32,6 +33,7 @@ describe Coppertone::Mechanism::IP4 do
|
|
32
33
|
it 'should work if called with an IP4' do
|
33
34
|
mech = Coppertone::Mechanism::IP4.new(':1.2.3.4')
|
34
35
|
expect(mech.netblock).to eq(IPAddr.new('1.2.3.4'))
|
36
|
+
expect(mech.cidr_length).to eq(32)
|
35
37
|
expect(mech.to_s).to eq('ip4:1.2.3.4')
|
36
38
|
expect(mech).not_to be_includes_ptr
|
37
39
|
expect(mech).not_to be_context_dependent
|
@@ -41,6 +43,7 @@ describe Coppertone::Mechanism::IP4 do
|
|
41
43
|
it 'should work if called with an IP4 with a pfxlen' do
|
42
44
|
mech = Coppertone::Mechanism::IP4.new(':1.2.3.4/4')
|
43
45
|
expect(mech.netblock).to eq(IPAddr.new('1.2.3.4/4'))
|
46
|
+
expect(mech.cidr_length).to eq(4)
|
44
47
|
expect(mech.to_s).to eq('ip4:1.2.3.4/4')
|
45
48
|
expect(mech).not_to be_includes_ptr
|
46
49
|
expect(mech).not_to be_context_dependent
|
data/spec/mechanism/ip6_spec.rb
CHANGED
@@ -23,6 +23,7 @@ describe Coppertone::Mechanism::IP6 do
|
|
23
23
|
it 'should not fail if called with an IP v4' do
|
24
24
|
mech = Coppertone::Mechanism::IP6.new(':1.2.3.4')
|
25
25
|
expect(mech.netblock).to eq(IPAddr.new('1.2.3.4'))
|
26
|
+
expect(mech.cidr_length).to eq(32)
|
26
27
|
expect(mech).not_to be_dns_lookup_term
|
27
28
|
end
|
28
29
|
|
@@ -30,6 +31,7 @@ describe Coppertone::Mechanism::IP6 do
|
|
30
31
|
mech = Coppertone::Mechanism::IP6.new(':fe80::202:b3ff:fe1e:8329')
|
31
32
|
expect(mech.netblock)
|
32
33
|
.to eq(IPAddr.new('fe80::202:b3ff:fe1e:8329'))
|
34
|
+
expect(mech.cidr_length).to eq(128)
|
33
35
|
expect(mech).not_to be_dns_lookup_term
|
34
36
|
end
|
35
37
|
|
@@ -37,6 +39,7 @@ describe Coppertone::Mechanism::IP6 do
|
|
37
39
|
mech = Coppertone::Mechanism::IP6.new(':fe80::202:b3ff:fe1e:8329/64')
|
38
40
|
expect(mech.netblock)
|
39
41
|
.to eq(IPAddr.new('fe80::202:b3ff:fe1e:8329/64'))
|
42
|
+
expect(mech.cidr_length).to eq(64)
|
40
43
|
expect(mech).not_to be_dns_lookup_term
|
41
44
|
end
|
42
45
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
require 'simplecov'
|
2
|
-
|
3
|
-
|
2
|
+
|
3
|
+
# save to CircleCI's artifacts directory if we're on CircleCI
|
4
|
+
if ENV['CIRCLE_ARTIFACTS']
|
5
|
+
dir = File.join(ENV['CIRCLE_ARTIFACTS'], 'coverage')
|
6
|
+
SimpleCov.coverage_dir(dir)
|
7
|
+
end
|
8
|
+
|
9
|
+
SimpleCov.start
|
4
10
|
|
5
11
|
require 'coppertone'
|
6
12
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coppertone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter M. Goldstein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dns_adapter
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- LICENSE
|
139
139
|
- README.md
|
140
140
|
- Rakefile
|
141
|
+
- circle.yml
|
141
142
|
- coppertone.gemspec
|
142
143
|
- lib/coppertone.rb
|
143
144
|
- lib/coppertone/class_builder.rb
|
@@ -267,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
267
268
|
version: '0'
|
268
269
|
requirements: []
|
269
270
|
rubyforge_project:
|
270
|
-
rubygems_version: 2.
|
271
|
+
rubygems_version: 2.6.8
|
271
272
|
signing_key:
|
272
273
|
specification_version: 4
|
273
274
|
summary: A Sender Policy Framework (SPF) toolkit
|