ronin-db-activerecord 0.1.0.beta1 → 0.1.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -0
- data/.yardopts +1 -1
- data/README.md +2 -1
- data/db/migrate/0001_create_ronin_ip_address_mac_addresses_table.rb +1 -1
- data/db/migrate/0002_create_ronin_vulnerabilities_table.rb +1 -1
- data/db/migrate/0003_create_ronin_url_schemes_table.rb +1 -1
- data/db/migrate/0004_create_ronin_url_query_param_names_table.rb +1 -1
- data/db/migrate/0005_create_ronin_user_names_table.rb +1 -1
- data/db/migrate/0006_create_ronin_software_vendors_table.rb +1 -1
- data/db/migrate/0007_create_ronin_advisories_table.rb +1 -1
- data/db/migrate/0008_create_ronin_host_name_ip_addresses_table.rb +1 -1
- data/db/migrate/0009_create_ronin_host_names_table.rb +1 -1
- data/db/migrate/0010_create_ronin_arches_table.rb +1 -1
- data/db/migrate/0011_create_ronin_email_addresses_table.rb +1 -1
- data/db/migrate/0012_create_ronin_oses_table.rb +1 -1
- data/db/migrate/0013_create_ronin_organizations_table.rb +1 -1
- data/db/migrate/0014_create_ronin_ip_addresses_table.rb +1 -1
- data/db/migrate/0015_create_ronin_os_guesses_table.rb +1 -1
- data/db/migrate/0016_create_ronin_url_query_params_table.rb +1 -1
- data/db/migrate/0017_create_ronin_passwords_table.rb +1 -1
- data/db/migrate/0018_create_ronin_open_ports_table.rb +1 -1
- data/db/migrate/0019_create_ronin_urls_table.rb +1 -1
- data/db/migrate/0020_create_ronin_softwares_table.rb +1 -1
- data/db/migrate/0021_create_ronin_mac_addresses_table.rb +1 -1
- data/db/migrate/0022_create_ronin_countries_table.rb +1 -1
- data/db/migrate/0023_create_ronin_services_table.rb +1 -1
- data/db/migrate/0024_create_ronin_credentials_table.rb +1 -1
- data/db/migrate/0025_create_ronin_ports_table.rb +1 -1
- data/db/migrate/0026_create_ronin_asns_table.rb +1 -1
- data/db/migrate/0027_create_ronin_http_query_param_names_table.rb +1 -1
- data/db/migrate/0028_create_ronin_http_query_params_table.rb +1 -1
- data/db/migrate/0029_create_ronin_http_header_names_table.rb +1 -1
- data/db/migrate/0030_create_ronin_http_request_headers_table.rb +1 -1
- data/db/migrate/0031_create_ronin_http_response_headers_table.rb +1 -1
- data/db/migrate/0032_create_ronin_http_requests_table.rb +1 -1
- data/db/migrate/0033_create_ronin_http_responses_table.rb +1 -1
- data/db/migrate/0034_create_ronin_service_credentials_table.rb +1 -1
- data/db/migrate/0035_create_ronin_web_credentials_table.rb +1 -1
- data/gemspec.yml +3 -3
- data/lib/ronin/db/address.rb +1 -1
- data/lib/ronin/db/advisory.rb +1 -1
- data/lib/ronin/db/arch.rb +1 -1
- data/lib/ronin/db/asn.rb +1 -1
- data/lib/ronin/db/credential.rb +1 -1
- data/lib/ronin/db/email_address.rb +1 -1
- data/lib/ronin/db/host_name.rb +1 -1
- data/lib/ronin/db/host_name_ip_address.rb +1 -1
- data/lib/ronin/db/http_header_name.rb +1 -1
- data/lib/ronin/db/http_query_param.rb +1 -1
- data/lib/ronin/db/http_query_param_name.rb +1 -1
- data/lib/ronin/db/http_request.rb +1 -1
- data/lib/ronin/db/http_request_header.rb +1 -1
- data/lib/ronin/db/http_response.rb +1 -1
- data/lib/ronin/db/http_response_header.rb +1 -1
- data/lib/ronin/db/ip_address.rb +1 -1
- data/lib/ronin/db/ip_address_mac_address.rb +1 -1
- data/lib/ronin/db/mac_address.rb +1 -1
- data/lib/ronin/db/migrations.rb +1 -1
- data/lib/ronin/db/model/has_name.rb +1 -1
- data/lib/ronin/db/model/has_unique_name.rb +1 -1
- data/lib/ronin/db/model/importable.rb +1 -1
- data/lib/ronin/db/model/last_scanned_at.rb +1 -1
- data/lib/ronin/db/model.rb +1 -1
- data/lib/ronin/db/models.rb +1 -1
- data/lib/ronin/db/open_port.rb +1 -1
- data/lib/ronin/db/organization.rb +1 -1
- data/lib/ronin/db/os.rb +1 -1
- data/lib/ronin/db/os_guess.rb +1 -1
- data/lib/ronin/db/password.rb +1 -1
- data/lib/ronin/db/port.rb +1 -1
- data/lib/ronin/db/schema_migration.rb +1 -1
- data/lib/ronin/db/service.rb +1 -1
- data/lib/ronin/db/service_credential.rb +1 -1
- data/lib/ronin/db/software.rb +1 -1
- data/lib/ronin/db/software_vendor.rb +1 -1
- data/lib/ronin/db/url.rb +1 -1
- data/lib/ronin/db/url_query_param.rb +1 -1
- data/lib/ronin/db/url_query_param_name.rb +1 -1
- data/lib/ronin/db/url_scheme.rb +1 -1
- data/lib/ronin/db/user_name.rb +1 -1
- data/lib/ronin/db/vulnerability.rb +1 -1
- data/lib/ronin/db/web_credential.rb +1 -1
- data/ronin-db-activerecord.gemspec +2 -1
- metadata +5 -87
- data/lib/ronin/db/root.rb +0 -28
- data/spec/advisory_spec.rb +0 -277
- data/spec/arch_spec.rb +0 -228
- data/spec/asn_spec.rb +0 -504
- data/spec/credential_spec.rb +0 -362
- data/spec/email_address_spec.rb +0 -372
- data/spec/host_name_ip_address_spec.rb +0 -8
- data/spec/host_name_spec.rb +0 -207
- data/spec/http_header_name_spec.rb +0 -25
- data/spec/http_query_param_name_spec.rb +0 -25
- data/spec/http_query_param_spec.rb +0 -104
- data/spec/http_request_header_spec.rb +0 -72
- data/spec/http_request_spec.rb +0 -168
- data/spec/http_response_header_spec.rb +0 -74
- data/spec/http_response_spec.rb +0 -103
- data/spec/ip_address_mac_addresses_spec.rb +0 -8
- data/spec/ip_address_spec.rb +0 -386
- data/spec/mac_address_spec.rb +0 -67
- data/spec/migrations_spec.rb +0 -122
- data/spec/model/has_name_spec.rb +0 -65
- data/spec/model/has_unique_name_spec.rb +0 -61
- data/spec/model/importable_spec.rb +0 -105
- data/spec/models_spec.rb +0 -60
- data/spec/open_port_spec.rb +0 -87
- data/spec/organization_spec.rb +0 -10
- data/spec/os_guess_spec.rb +0 -43
- data/spec/os_spec.rb +0 -114
- data/spec/password_spec.rb +0 -81
- data/spec/port_spec.rb +0 -102
- data/spec/schema_migration_spec.rb +0 -8
- data/spec/service_credential_spec.rb +0 -43
- data/spec/service_spec.rb +0 -39
- data/spec/software_spec.rb +0 -76
- data/spec/software_vendor_spec.rb +0 -33
- data/spec/spec_helper.rb +0 -13
- data/spec/url_query_param_name_spec.rb +0 -25
- data/spec/url_query_param_spec.rb +0 -110
- data/spec/url_scheme_spec.rb +0 -39
- data/spec/url_spec.rb +0 -951
- data/spec/user_name_spec.rb +0 -54
- data/spec/vulnerability_spec.rb +0 -8
- data/spec/web_credential_spec.rb +0 -72
data/spec/arch_spec.rb
DELETED
@@ -1,228 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/db/arch'
|
3
|
-
|
4
|
-
describe Ronin::DB::Arch do
|
5
|
-
it "must use the 'ronin_arches' table" do
|
6
|
-
expect(described_class.table_name).to eq('ronin_arches')
|
7
|
-
end
|
8
|
-
|
9
|
-
let(:name) { 'cats' }
|
10
|
-
let(:endian) { :little }
|
11
|
-
let(:word_size) { 4 }
|
12
|
-
|
13
|
-
it "must include Ronin::DB::Model" do
|
14
|
-
expect(described_class).to include(Ronin::DB::Model)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "must include Ronin::DB::Model::HasUniqueName" do
|
18
|
-
expect(described_class).to include(Ronin::DB::Model::HasUniqueName)
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "validations" do
|
22
|
-
describe "name" do
|
23
|
-
it "must requier a name" do
|
24
|
-
arch = described_class.new(endian: endian, word_size: word_size)
|
25
|
-
expect(arch).to_not be_valid
|
26
|
-
expect(arch.errors[:name]).to eq(
|
27
|
-
["can't be blank"]
|
28
|
-
)
|
29
|
-
|
30
|
-
arch = described_class.new(
|
31
|
-
name: name,
|
32
|
-
endian: endian,
|
33
|
-
word_size: word_size
|
34
|
-
)
|
35
|
-
expect(arch).to be_valid
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "endian" do
|
40
|
-
subject do
|
41
|
-
described_class.new(
|
42
|
-
name: name,
|
43
|
-
word_size: word_size
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
|
-
it "must accept :little" do
|
48
|
-
arch = described_class.new(
|
49
|
-
name: name,
|
50
|
-
endian: :little,
|
51
|
-
word_size: word_size
|
52
|
-
)
|
53
|
-
expect(arch).to be_valid
|
54
|
-
end
|
55
|
-
|
56
|
-
it "must accept :big" do
|
57
|
-
arch = described_class.new(
|
58
|
-
name: name,
|
59
|
-
endian: :big,
|
60
|
-
word_size: word_size
|
61
|
-
)
|
62
|
-
expect(arch).to be_valid
|
63
|
-
end
|
64
|
-
|
65
|
-
context "otherwise" do
|
66
|
-
let(:endian) { :foo }
|
67
|
-
|
68
|
-
it do
|
69
|
-
expect {
|
70
|
-
described_class.new(
|
71
|
-
name: name,
|
72
|
-
endian: endian,
|
73
|
-
word_size: word_size
|
74
|
-
)
|
75
|
-
}.to raise_error(ArgumentError,"'#{endian}' is not a valid endian")
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "word_size" do
|
81
|
-
it "must require a word_size" do
|
82
|
-
arch = described_class.new(name: name, endian: endian)
|
83
|
-
expect(arch).to_not be_valid
|
84
|
-
expect(arch.errors[:word_size]).to include("can't be blank")
|
85
|
-
|
86
|
-
arch = described_class.new(
|
87
|
-
name: name,
|
88
|
-
endian: endian,
|
89
|
-
word_size: word_size
|
90
|
-
)
|
91
|
-
expect(arch).to be_valid
|
92
|
-
end
|
93
|
-
|
94
|
-
it "must accept a word_size of 4" do
|
95
|
-
arch = described_class.new(
|
96
|
-
name: name,
|
97
|
-
endian: endian,
|
98
|
-
word_size: 4
|
99
|
-
)
|
100
|
-
expect(arch).to be_valid
|
101
|
-
end
|
102
|
-
|
103
|
-
it "must accept a word_size of 8" do
|
104
|
-
arch = described_class.new(
|
105
|
-
name: name,
|
106
|
-
endian: endian,
|
107
|
-
word_size: 8
|
108
|
-
)
|
109
|
-
expect(arch).to be_valid
|
110
|
-
end
|
111
|
-
|
112
|
-
context "otherwise" do
|
113
|
-
let(:word_size) { 3 }
|
114
|
-
|
115
|
-
it do
|
116
|
-
arch = described_class.new(
|
117
|
-
name: name,
|
118
|
-
endian: endian,
|
119
|
-
word_size: word_size
|
120
|
-
)
|
121
|
-
expect(arch).to_not be_valid
|
122
|
-
expect(arch.errors[:word_size]).to eq(
|
123
|
-
['is not included in the list']
|
124
|
-
)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
describe ".x86" do
|
131
|
-
subject { described_class.x86 }
|
132
|
-
|
133
|
-
it "should return the x86 architecture" do
|
134
|
-
expect(subject).to be_kind_of(described_class)
|
135
|
-
expect(subject.name).to eq('x86')
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
describe ".i686" do
|
140
|
-
subject { described_class.i686 }
|
141
|
-
|
142
|
-
it "should return the i686 architecture" do
|
143
|
-
expect(subject).to be_kind_of(described_class)
|
144
|
-
expect(subject.name).to eq('i686')
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
describe ".x86_64" do
|
149
|
-
subject { described_class.x86_64 }
|
150
|
-
|
151
|
-
it "should return the x86-64 architecture" do
|
152
|
-
expect(subject).to be_kind_of(described_class)
|
153
|
-
expect(subject.name).to eq('x86-64')
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
describe ".ppc" do
|
158
|
-
subject { described_class.ppc }
|
159
|
-
|
160
|
-
it "should return the PPC architecture" do
|
161
|
-
expect(subject).to be_kind_of(described_class)
|
162
|
-
expect(subject.name).to eq('PPC')
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
describe ".ppc64" do
|
167
|
-
subject { described_class.ppc64 }
|
168
|
-
|
169
|
-
it "should return the PPC64 architecture" do
|
170
|
-
expect(subject).to be_kind_of(described_class)
|
171
|
-
expect(subject.name).to eq('PPC64')
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
describe ".mips" do
|
176
|
-
subject { described_class.mips }
|
177
|
-
|
178
|
-
it "should return the MIPS architecture" do
|
179
|
-
expect(subject).to be_kind_of(described_class)
|
180
|
-
expect(subject.name).to eq('MIPS')
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
describe ".mips_le" do
|
185
|
-
subject { described_class.mips_le }
|
186
|
-
|
187
|
-
it "should return the MIPS (Little-Endian) architecture" do
|
188
|
-
expect(subject).to be_kind_of(described_class)
|
189
|
-
expect(subject.name).to eq('MIPS (Little-Endian)')
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
describe ".mips_be" do
|
194
|
-
subject { described_class.mips_be }
|
195
|
-
|
196
|
-
it "should return the MIPS (Big-Endian) architecture" do
|
197
|
-
expect(subject).to be_kind_of(described_class)
|
198
|
-
expect(subject.name).to eq('MIPS (Big-Endian)')
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
202
|
-
describe ".arm" do
|
203
|
-
subject { described_class.arm }
|
204
|
-
|
205
|
-
it "should return the ARM architecture" do
|
206
|
-
expect(subject).to be_kind_of(described_class)
|
207
|
-
expect(subject.name).to eq('ARM')
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
describe ".arm_le" do
|
212
|
-
subject { described_class.arm_le }
|
213
|
-
|
214
|
-
it "should return the ARM (Little-Endian) architecture" do
|
215
|
-
expect(subject).to be_kind_of(described_class)
|
216
|
-
expect(subject.name).to eq('ARM (Little-Endian)')
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
describe ".arm_be" do
|
221
|
-
subject { described_class.arm_be }
|
222
|
-
|
223
|
-
it "should return the ARM (Big-Endian) architecture" do
|
224
|
-
expect(subject).to be_kind_of(described_class)
|
225
|
-
expect(subject.name).to eq('ARM (Big-Endian)')
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
data/spec/asn_spec.rb
DELETED
@@ -1,504 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/db/asn'
|
3
|
-
|
4
|
-
describe Ronin::DB::ASN do
|
5
|
-
it "must use the 'ronin_asns' table" do
|
6
|
-
expect(described_class.table_name).to eq('ronin_asns')
|
7
|
-
end
|
8
|
-
|
9
|
-
let(:version) { 4 }
|
10
|
-
let(:range_start) { '4.0.0.0' }
|
11
|
-
let(:range_end) { '4.7.168.255' }
|
12
|
-
let(:number) { 3356 }
|
13
|
-
let(:country_code) { 'US' }
|
14
|
-
let(:name) { 'LEVEL3' }
|
15
|
-
|
16
|
-
describe "validations" do
|
17
|
-
describe "version" do
|
18
|
-
it "must require a version" do
|
19
|
-
asn = described_class.new(
|
20
|
-
range_start: range_start,
|
21
|
-
range_end: range_end,
|
22
|
-
number: number,
|
23
|
-
country_code: country_code,
|
24
|
-
name: name
|
25
|
-
)
|
26
|
-
|
27
|
-
expect(asn).to_not be_valid
|
28
|
-
expect(asn.errors[:version]).to eq(
|
29
|
-
["can't be blank", "is not included in the list"]
|
30
|
-
)
|
31
|
-
end
|
32
|
-
|
33
|
-
it "must accept a value of 4" do
|
34
|
-
asn = described_class.new(
|
35
|
-
version: 4,
|
36
|
-
range_start: range_start,
|
37
|
-
range_end: range_end,
|
38
|
-
number: number,
|
39
|
-
country_code: country_code,
|
40
|
-
name: name
|
41
|
-
)
|
42
|
-
|
43
|
-
expect(asn).to be_valid
|
44
|
-
end
|
45
|
-
|
46
|
-
it "must accept a value of 6" do
|
47
|
-
asn = described_class.new(
|
48
|
-
version: 6,
|
49
|
-
range_start: range_start,
|
50
|
-
range_end: range_end,
|
51
|
-
number: number,
|
52
|
-
country_code: country_code,
|
53
|
-
name: name
|
54
|
-
)
|
55
|
-
|
56
|
-
expect(asn).to be_valid
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "range_start" do
|
61
|
-
it "must require #range_start" do
|
62
|
-
asn = described_class.new(
|
63
|
-
version: version,
|
64
|
-
range_end: range_end,
|
65
|
-
number: number,
|
66
|
-
country_code: country_code,
|
67
|
-
name: name
|
68
|
-
)
|
69
|
-
|
70
|
-
expect(asn).to_not be_valid
|
71
|
-
expect(asn.errors[:range_start]).to eq(
|
72
|
-
["can't be blank"]
|
73
|
-
)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe "range_end" do
|
78
|
-
it "must require #range_end" do
|
79
|
-
asn = described_class.new(
|
80
|
-
version: version,
|
81
|
-
range_start: range_start,
|
82
|
-
number: number,
|
83
|
-
country_code: country_code,
|
84
|
-
name: name
|
85
|
-
)
|
86
|
-
|
87
|
-
expect(asn).to_not be_valid
|
88
|
-
expect(asn.errors[:range_end]).to eq(
|
89
|
-
["can't be blank"]
|
90
|
-
)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "number" do
|
95
|
-
it "must require #number" do
|
96
|
-
asn = described_class.new(
|
97
|
-
version: version,
|
98
|
-
range_start: range_start,
|
99
|
-
range_end: range_end,
|
100
|
-
country_code: country_code,
|
101
|
-
name: name
|
102
|
-
)
|
103
|
-
|
104
|
-
expect(asn).to_not be_valid
|
105
|
-
expect(asn.errors[:number]).to eq(
|
106
|
-
["can't be blank"]
|
107
|
-
)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe "country_code" do
|
112
|
-
it "must omit the name if unrouted" do
|
113
|
-
asn = described_class.new(
|
114
|
-
version: version,
|
115
|
-
range_start: range_start,
|
116
|
-
range_end: range_end,
|
117
|
-
number: number
|
118
|
-
)
|
119
|
-
|
120
|
-
expect(asn).to be_valid
|
121
|
-
end
|
122
|
-
end
|
123
|
-
|
124
|
-
describe "name" do
|
125
|
-
it "must omit the name if unrouted" do
|
126
|
-
asn = described_class.new(
|
127
|
-
version: version,
|
128
|
-
range_start: range_start,
|
129
|
-
range_end: range_end,
|
130
|
-
number: number
|
131
|
-
)
|
132
|
-
|
133
|
-
expect(asn).to be_valid
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
describe ".v4" do
|
139
|
-
subject { described_class }
|
140
|
-
|
141
|
-
before do
|
142
|
-
subject.create(
|
143
|
-
version: 6,
|
144
|
-
range_start: '64:ff9b::1:0:0',
|
145
|
-
range_end: '100::ffff:ffff:ffff:ffff',
|
146
|
-
number: 0
|
147
|
-
)
|
148
|
-
|
149
|
-
subject.create(
|
150
|
-
version: 4,
|
151
|
-
range_start: range_start,
|
152
|
-
range_end: range_end,
|
153
|
-
number: number,
|
154
|
-
country_code: country_code,
|
155
|
-
name: name
|
156
|
-
)
|
157
|
-
|
158
|
-
subject.create(
|
159
|
-
version: 6,
|
160
|
-
range_start: '::',
|
161
|
-
range_end: '::1',
|
162
|
-
number: 0
|
163
|
-
)
|
164
|
-
end
|
165
|
-
|
166
|
-
it "must query all IPv4 ASNs" do
|
167
|
-
asns = subject.v4
|
168
|
-
|
169
|
-
expect(asns).to_not be_empty
|
170
|
-
expect(asns.map(&:version)).to all(eq(4))
|
171
|
-
end
|
172
|
-
|
173
|
-
after { described_class.destroy_all }
|
174
|
-
end
|
175
|
-
|
176
|
-
describe ".v6" do
|
177
|
-
subject { described_class }
|
178
|
-
|
179
|
-
before do
|
180
|
-
subject.create(
|
181
|
-
version: 4,
|
182
|
-
range_start: '1.0.0.0',
|
183
|
-
range_end: '1.0.0.255',
|
184
|
-
number: 13335,
|
185
|
-
country_code: 'US',
|
186
|
-
name: 'CLOUDFLARENET'
|
187
|
-
)
|
188
|
-
|
189
|
-
subject.create(
|
190
|
-
version: 6,
|
191
|
-
range_start: '64:ff9b::1:0:0',
|
192
|
-
range_end: '100::ffff:ffff:ffff:ffff',
|
193
|
-
number: 0
|
194
|
-
)
|
195
|
-
|
196
|
-
subject.create(
|
197
|
-
version: 4,
|
198
|
-
range_start: '1.0.1.0',
|
199
|
-
range_end: '1.0.3.255',
|
200
|
-
number: 0
|
201
|
-
)
|
202
|
-
end
|
203
|
-
|
204
|
-
it "must query all IPv6 ASNs" do
|
205
|
-
asns = subject.v6
|
206
|
-
|
207
|
-
expect(asns).to_not be_empty
|
208
|
-
expect(asns.map(&:version)).to all(eq(6))
|
209
|
-
end
|
210
|
-
|
211
|
-
after { described_class.destroy_all }
|
212
|
-
end
|
213
|
-
|
214
|
-
describe ".with_number" do
|
215
|
-
subject { described_class }
|
216
|
-
|
217
|
-
let(:number) { 3356 }
|
218
|
-
|
219
|
-
before do
|
220
|
-
subject.create(
|
221
|
-
version: 4,
|
222
|
-
range_start: '3.248.0.0',
|
223
|
-
range_end: '3.255.255.255',
|
224
|
-
number: 16509,
|
225
|
-
country_code: 'US',
|
226
|
-
name: 'AMAZON-02'
|
227
|
-
)
|
228
|
-
|
229
|
-
subject.create(
|
230
|
-
version: 4,
|
231
|
-
range_start: '4.0.0.0',
|
232
|
-
range_end: '4.7.168.255',
|
233
|
-
number: number,
|
234
|
-
country_code: 'US',
|
235
|
-
name: 'LEVEL3'
|
236
|
-
)
|
237
|
-
|
238
|
-
subject.create(
|
239
|
-
version: 4,
|
240
|
-
range_start: '4.7.169.0',
|
241
|
-
range_end: '4.23.87.255',
|
242
|
-
number: number,
|
243
|
-
country_code: 'US',
|
244
|
-
name: 'LEVEL3'
|
245
|
-
)
|
246
|
-
|
247
|
-
subject.create(
|
248
|
-
version: 4,
|
249
|
-
range_start: '4.23.88.0',
|
250
|
-
range_end: '4.23.89.255',
|
251
|
-
number: 46164,
|
252
|
-
country_code: 'US',
|
253
|
-
name: 'ATT-MOBILITY-LABS'
|
254
|
-
)
|
255
|
-
end
|
256
|
-
|
257
|
-
it "must query the ASN recrds with the matching number" do
|
258
|
-
asns = subject.with_number(number)
|
259
|
-
|
260
|
-
expect(asns.length).to eq(2)
|
261
|
-
expect(asns).to all(be_kind_of(described_class))
|
262
|
-
expect(asns[0].number).to eq(number)
|
263
|
-
expect(asns[1].number).to eq(number)
|
264
|
-
end
|
265
|
-
|
266
|
-
after { described_class.destroy_all }
|
267
|
-
end
|
268
|
-
|
269
|
-
describe ".with_country_code" do
|
270
|
-
subject { described_class }
|
271
|
-
|
272
|
-
let(:country_code) { 'US' }
|
273
|
-
|
274
|
-
before do
|
275
|
-
subject.create(
|
276
|
-
version: 4,
|
277
|
-
range_start: '3.30.0.0',
|
278
|
-
range_end: '3.32.255.255',
|
279
|
-
number: 8987,
|
280
|
-
country_code: 'IE',
|
281
|
-
name: 'AMAZON EXPANSION'
|
282
|
-
)
|
283
|
-
|
284
|
-
subject.create(
|
285
|
-
version: 4,
|
286
|
-
range_start: '4.0.0.0',
|
287
|
-
range_end: '4.7.168.255',
|
288
|
-
number: 3356,
|
289
|
-
country_code: country_code,
|
290
|
-
name: 'LEVEL3'
|
291
|
-
)
|
292
|
-
|
293
|
-
subject.create(
|
294
|
-
version: 4,
|
295
|
-
range_start: '4.7.169.0',
|
296
|
-
range_end: '4.23.87.255',
|
297
|
-
number: 3356,
|
298
|
-
country_code: country_code,
|
299
|
-
name: 'LEVEL3'
|
300
|
-
)
|
301
|
-
|
302
|
-
subject.create(
|
303
|
-
version: 4,
|
304
|
-
range_start: '5.0.0.0',
|
305
|
-
range_end: '5.0.255.255',
|
306
|
-
number: 29256,
|
307
|
-
country_code: 'SV',
|
308
|
-
name: 'INT-PDN-STE-AS STE PDN Internal AS'
|
309
|
-
)
|
310
|
-
end
|
311
|
-
|
312
|
-
it "must query the ASN recrds with the matching country code" do
|
313
|
-
asns = subject.with_country_code(country_code)
|
314
|
-
|
315
|
-
expect(asns.length).to eq(2)
|
316
|
-
expect(asns).to all(be_kind_of(described_class))
|
317
|
-
expect(asns[0].country_code).to eq(country_code)
|
318
|
-
expect(asns[1].country_code).to eq(country_code)
|
319
|
-
end
|
320
|
-
|
321
|
-
after { described_class.destroy_all }
|
322
|
-
end
|
323
|
-
|
324
|
-
describe ".with_name" do
|
325
|
-
subject { described_class }
|
326
|
-
|
327
|
-
let(:number) { 3356 }
|
328
|
-
let(:name) { 'LEVEL3' }
|
329
|
-
|
330
|
-
before do
|
331
|
-
subject.create(
|
332
|
-
version: 4,
|
333
|
-
range_start: '3.248.0.0',
|
334
|
-
range_end: '3.255.255.255',
|
335
|
-
number: 16509,
|
336
|
-
country_code: 'US',
|
337
|
-
name: 'AMAZON-02'
|
338
|
-
)
|
339
|
-
|
340
|
-
subject.create(
|
341
|
-
version: 4,
|
342
|
-
range_start: '4.0.0.0',
|
343
|
-
range_end: '4.7.168.255',
|
344
|
-
number: number,
|
345
|
-
country_code: 'US',
|
346
|
-
name: name
|
347
|
-
)
|
348
|
-
|
349
|
-
subject.create(
|
350
|
-
version: 4,
|
351
|
-
range_start: '4.7.169.0',
|
352
|
-
range_end: '4.23.87.255',
|
353
|
-
number: number,
|
354
|
-
country_code: 'US',
|
355
|
-
name: name
|
356
|
-
)
|
357
|
-
|
358
|
-
subject.create(
|
359
|
-
version: 4,
|
360
|
-
range_start: '4.23.88.0',
|
361
|
-
range_end: '4.23.89.255',
|
362
|
-
number: 46164,
|
363
|
-
country_code: 'US',
|
364
|
-
name: 'ATT-MOBILITY-LABS'
|
365
|
-
)
|
366
|
-
end
|
367
|
-
|
368
|
-
it "must query the ASN recrds with the matching number" do
|
369
|
-
asns = subject.with_name(name)
|
370
|
-
|
371
|
-
expect(asns.length).to eq(2)
|
372
|
-
expect(asns).to all(be_kind_of(described_class))
|
373
|
-
expect(asns[0].name).to eq(name)
|
374
|
-
expect(asns[1].name).to eq(name)
|
375
|
-
end
|
376
|
-
|
377
|
-
after { described_class.destroy_all }
|
378
|
-
end
|
379
|
-
|
380
|
-
describe ".containing_ip" do
|
381
|
-
subject { described_class }
|
382
|
-
|
383
|
-
before do
|
384
|
-
subject.create(
|
385
|
-
version: version,
|
386
|
-
range_start: range_start,
|
387
|
-
range_end: range_end,
|
388
|
-
number: number,
|
389
|
-
country_code: country_code,
|
390
|
-
name: name
|
391
|
-
)
|
392
|
-
end
|
393
|
-
|
394
|
-
let(:ip) { "4.4.4.4" }
|
395
|
-
|
396
|
-
it "must find the #{described_class} that contains the given IP address" do
|
397
|
-
asn = subject.containing_ip(ip)
|
398
|
-
|
399
|
-
expect(asn).to be_kind_of(described_class)
|
400
|
-
expect(asn.version).to eq(version)
|
401
|
-
expect(asn.range_start).to eq(range_start)
|
402
|
-
expect(asn.range_end).to eq(range_end)
|
403
|
-
expect(asn.number).to eq(number)
|
404
|
-
expect(asn.country_code).to eq(country_code)
|
405
|
-
expect(asn.name).to eq(name)
|
406
|
-
end
|
407
|
-
|
408
|
-
after { described_class.destroy_all }
|
409
|
-
end
|
410
|
-
|
411
|
-
subject do
|
412
|
-
described_class.new(
|
413
|
-
version: version,
|
414
|
-
range_start: range_start,
|
415
|
-
range_end: range_end,
|
416
|
-
number: number,
|
417
|
-
country_code: country_code,
|
418
|
-
name: name
|
419
|
-
)
|
420
|
-
end
|
421
|
-
|
422
|
-
describe "#range_start_ipaddr" do
|
423
|
-
context "when #range_start is set" do
|
424
|
-
it "must return an IPAddr of #range_start" do
|
425
|
-
expect(subject.range_start_ipaddr).to be_kind_of(IPAddr)
|
426
|
-
expect(subject.range_start_ipaddr.to_s).to eq(subject.range_start)
|
427
|
-
end
|
428
|
-
end
|
429
|
-
|
430
|
-
context "when #range_start is nil" do
|
431
|
-
subject { described_class.new }
|
432
|
-
|
433
|
-
it "must return nil" do
|
434
|
-
expect(subject.range_start_ipaddr).to be(nil)
|
435
|
-
end
|
436
|
-
end
|
437
|
-
end
|
438
|
-
|
439
|
-
describe "#range_end_ipaddr" do
|
440
|
-
context "when #range_end is set" do
|
441
|
-
it "must return an IPAddr of #range_end" do
|
442
|
-
expect(subject.range_end_ipaddr).to be_kind_of(IPAddr)
|
443
|
-
expect(subject.range_end_ipaddr.to_s).to eq(subject.range_end)
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|
447
|
-
context "when #range_end is nil" do
|
448
|
-
subject { described_class.new }
|
449
|
-
|
450
|
-
it "must return nil" do
|
451
|
-
expect(subject.range_end_ipaddr).to be(nil)
|
452
|
-
end
|
453
|
-
end
|
454
|
-
end
|
455
|
-
|
456
|
-
describe "#ip_addresses" do
|
457
|
-
let(:address1) { '4.1.1.1' }
|
458
|
-
let(:address2) { '4.2.2.2' }
|
459
|
-
let(:address3) { '4.3.3.3' }
|
460
|
-
|
461
|
-
before do
|
462
|
-
Ronin::DB::IPAddress.create(address: '3.255.255.255')
|
463
|
-
Ronin::DB::IPAddress.create(address: address1)
|
464
|
-
Ronin::DB::IPAddress.create(address: address2)
|
465
|
-
Ronin::DB::IPAddress.create(address: address3)
|
466
|
-
Ronin::DB::IPAddress.create(address: '4.7.169.0')
|
467
|
-
end
|
468
|
-
|
469
|
-
it "must query all IP addresses that are in between the first and last IP address" do
|
470
|
-
ip_addresses = subject.ip_addresses
|
471
|
-
|
472
|
-
expect(ip_addresses.length).to eq(3)
|
473
|
-
expect(ip_addresses).to all(be_kind_of(Ronin::DB::IPAddress))
|
474
|
-
expect(ip_addresses[0].address).to eq(address1)
|
475
|
-
expect(ip_addresses[1].address).to eq(address2)
|
476
|
-
expect(ip_addresses[2].address).to eq(address3)
|
477
|
-
end
|
478
|
-
|
479
|
-
after { Ronin::DB::IPAddress.destroy_all }
|
480
|
-
end
|
481
|
-
|
482
|
-
describe "#save" do
|
483
|
-
subject do
|
484
|
-
described_class.create(
|
485
|
-
version: 4,
|
486
|
-
range_start: range_start,
|
487
|
-
range_end: range_end,
|
488
|
-
number: number,
|
489
|
-
country_code: country_code,
|
490
|
-
name: name
|
491
|
-
)
|
492
|
-
end
|
493
|
-
|
494
|
-
it "must set #range_start_hton" do
|
495
|
-
expect(subject.range_start_hton).to eq(subject.range_start_ipaddr.hton)
|
496
|
-
end
|
497
|
-
|
498
|
-
it "must set #range_end_hton" do
|
499
|
-
expect(subject.range_end_hton).to eq(subject.range_end_ipaddr.hton)
|
500
|
-
end
|
501
|
-
|
502
|
-
after { subject.destroy }
|
503
|
-
end
|
504
|
-
end
|