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.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -0
  3. data/.yardopts +1 -1
  4. data/README.md +2 -1
  5. data/db/migrate/0001_create_ronin_ip_address_mac_addresses_table.rb +1 -1
  6. data/db/migrate/0002_create_ronin_vulnerabilities_table.rb +1 -1
  7. data/db/migrate/0003_create_ronin_url_schemes_table.rb +1 -1
  8. data/db/migrate/0004_create_ronin_url_query_param_names_table.rb +1 -1
  9. data/db/migrate/0005_create_ronin_user_names_table.rb +1 -1
  10. data/db/migrate/0006_create_ronin_software_vendors_table.rb +1 -1
  11. data/db/migrate/0007_create_ronin_advisories_table.rb +1 -1
  12. data/db/migrate/0008_create_ronin_host_name_ip_addresses_table.rb +1 -1
  13. data/db/migrate/0009_create_ronin_host_names_table.rb +1 -1
  14. data/db/migrate/0010_create_ronin_arches_table.rb +1 -1
  15. data/db/migrate/0011_create_ronin_email_addresses_table.rb +1 -1
  16. data/db/migrate/0012_create_ronin_oses_table.rb +1 -1
  17. data/db/migrate/0013_create_ronin_organizations_table.rb +1 -1
  18. data/db/migrate/0014_create_ronin_ip_addresses_table.rb +1 -1
  19. data/db/migrate/0015_create_ronin_os_guesses_table.rb +1 -1
  20. data/db/migrate/0016_create_ronin_url_query_params_table.rb +1 -1
  21. data/db/migrate/0017_create_ronin_passwords_table.rb +1 -1
  22. data/db/migrate/0018_create_ronin_open_ports_table.rb +1 -1
  23. data/db/migrate/0019_create_ronin_urls_table.rb +1 -1
  24. data/db/migrate/0020_create_ronin_softwares_table.rb +1 -1
  25. data/db/migrate/0021_create_ronin_mac_addresses_table.rb +1 -1
  26. data/db/migrate/0022_create_ronin_countries_table.rb +1 -1
  27. data/db/migrate/0023_create_ronin_services_table.rb +1 -1
  28. data/db/migrate/0024_create_ronin_credentials_table.rb +1 -1
  29. data/db/migrate/0025_create_ronin_ports_table.rb +1 -1
  30. data/db/migrate/0026_create_ronin_asns_table.rb +1 -1
  31. data/db/migrate/0027_create_ronin_http_query_param_names_table.rb +1 -1
  32. data/db/migrate/0028_create_ronin_http_query_params_table.rb +1 -1
  33. data/db/migrate/0029_create_ronin_http_header_names_table.rb +1 -1
  34. data/db/migrate/0030_create_ronin_http_request_headers_table.rb +1 -1
  35. data/db/migrate/0031_create_ronin_http_response_headers_table.rb +1 -1
  36. data/db/migrate/0032_create_ronin_http_requests_table.rb +1 -1
  37. data/db/migrate/0033_create_ronin_http_responses_table.rb +1 -1
  38. data/db/migrate/0034_create_ronin_service_credentials_table.rb +1 -1
  39. data/db/migrate/0035_create_ronin_web_credentials_table.rb +1 -1
  40. data/gemspec.yml +3 -3
  41. data/lib/ronin/db/address.rb +1 -1
  42. data/lib/ronin/db/advisory.rb +1 -1
  43. data/lib/ronin/db/arch.rb +1 -1
  44. data/lib/ronin/db/asn.rb +1 -1
  45. data/lib/ronin/db/credential.rb +1 -1
  46. data/lib/ronin/db/email_address.rb +1 -1
  47. data/lib/ronin/db/host_name.rb +1 -1
  48. data/lib/ronin/db/host_name_ip_address.rb +1 -1
  49. data/lib/ronin/db/http_header_name.rb +1 -1
  50. data/lib/ronin/db/http_query_param.rb +1 -1
  51. data/lib/ronin/db/http_query_param_name.rb +1 -1
  52. data/lib/ronin/db/http_request.rb +1 -1
  53. data/lib/ronin/db/http_request_header.rb +1 -1
  54. data/lib/ronin/db/http_response.rb +1 -1
  55. data/lib/ronin/db/http_response_header.rb +1 -1
  56. data/lib/ronin/db/ip_address.rb +1 -1
  57. data/lib/ronin/db/ip_address_mac_address.rb +1 -1
  58. data/lib/ronin/db/mac_address.rb +1 -1
  59. data/lib/ronin/db/migrations.rb +1 -1
  60. data/lib/ronin/db/model/has_name.rb +1 -1
  61. data/lib/ronin/db/model/has_unique_name.rb +1 -1
  62. data/lib/ronin/db/model/importable.rb +1 -1
  63. data/lib/ronin/db/model/last_scanned_at.rb +1 -1
  64. data/lib/ronin/db/model.rb +1 -1
  65. data/lib/ronin/db/models.rb +1 -1
  66. data/lib/ronin/db/open_port.rb +1 -1
  67. data/lib/ronin/db/organization.rb +1 -1
  68. data/lib/ronin/db/os.rb +1 -1
  69. data/lib/ronin/db/os_guess.rb +1 -1
  70. data/lib/ronin/db/password.rb +1 -1
  71. data/lib/ronin/db/port.rb +1 -1
  72. data/lib/ronin/db/schema_migration.rb +1 -1
  73. data/lib/ronin/db/service.rb +1 -1
  74. data/lib/ronin/db/service_credential.rb +1 -1
  75. data/lib/ronin/db/software.rb +1 -1
  76. data/lib/ronin/db/software_vendor.rb +1 -1
  77. data/lib/ronin/db/url.rb +1 -1
  78. data/lib/ronin/db/url_query_param.rb +1 -1
  79. data/lib/ronin/db/url_query_param_name.rb +1 -1
  80. data/lib/ronin/db/url_scheme.rb +1 -1
  81. data/lib/ronin/db/user_name.rb +1 -1
  82. data/lib/ronin/db/vulnerability.rb +1 -1
  83. data/lib/ronin/db/web_credential.rb +1 -1
  84. data/ronin-db-activerecord.gemspec +2 -1
  85. metadata +5 -87
  86. data/lib/ronin/db/root.rb +0 -28
  87. data/spec/advisory_spec.rb +0 -277
  88. data/spec/arch_spec.rb +0 -228
  89. data/spec/asn_spec.rb +0 -504
  90. data/spec/credential_spec.rb +0 -362
  91. data/spec/email_address_spec.rb +0 -372
  92. data/spec/host_name_ip_address_spec.rb +0 -8
  93. data/spec/host_name_spec.rb +0 -207
  94. data/spec/http_header_name_spec.rb +0 -25
  95. data/spec/http_query_param_name_spec.rb +0 -25
  96. data/spec/http_query_param_spec.rb +0 -104
  97. data/spec/http_request_header_spec.rb +0 -72
  98. data/spec/http_request_spec.rb +0 -168
  99. data/spec/http_response_header_spec.rb +0 -74
  100. data/spec/http_response_spec.rb +0 -103
  101. data/spec/ip_address_mac_addresses_spec.rb +0 -8
  102. data/spec/ip_address_spec.rb +0 -386
  103. data/spec/mac_address_spec.rb +0 -67
  104. data/spec/migrations_spec.rb +0 -122
  105. data/spec/model/has_name_spec.rb +0 -65
  106. data/spec/model/has_unique_name_spec.rb +0 -61
  107. data/spec/model/importable_spec.rb +0 -105
  108. data/spec/models_spec.rb +0 -60
  109. data/spec/open_port_spec.rb +0 -87
  110. data/spec/organization_spec.rb +0 -10
  111. data/spec/os_guess_spec.rb +0 -43
  112. data/spec/os_spec.rb +0 -114
  113. data/spec/password_spec.rb +0 -81
  114. data/spec/port_spec.rb +0 -102
  115. data/spec/schema_migration_spec.rb +0 -8
  116. data/spec/service_credential_spec.rb +0 -43
  117. data/spec/service_spec.rb +0 -39
  118. data/spec/software_spec.rb +0 -76
  119. data/spec/software_vendor_spec.rb +0 -33
  120. data/spec/spec_helper.rb +0 -13
  121. data/spec/url_query_param_name_spec.rb +0 -25
  122. data/spec/url_query_param_spec.rb +0 -110
  123. data/spec/url_scheme_spec.rb +0 -39
  124. data/spec/url_spec.rb +0 -951
  125. data/spec/user_name_spec.rb +0 -54
  126. data/spec/vulnerability_spec.rb +0 -8
  127. data/spec/web_credential_spec.rb +0 -72
@@ -1,104 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/db/http_query_param'
3
- require 'ronin/db/http_request'
4
-
5
- describe Ronin::DB::HTTPQueryParam do
6
- it "must use the 'ronin_http_query_params' table" do
7
- expect(described_class.table_name).to eq('ronin_http_query_params')
8
- end
9
-
10
- let(:name) { 'foo' }
11
- let(:value) { 'bar' }
12
-
13
- let(:http_query_param_name) do
14
- Ronin::DB::HTTPQueryParamName.find_or_initialize_by(name: name)
15
- end
16
-
17
- let(:request_method) { :get }
18
- let(:path) { '/search' }
19
- let(:request) do
20
- Ronin::DB::HTTPRequest.new(
21
- request_method: request_method,
22
- path: path
23
- )
24
- end
25
-
26
- describe "validations" do
27
- describe "name" do
28
- it "must require a name association" do
29
- http_query_param = described_class.new(value: value)
30
- expect(http_query_param).to_not be_valid
31
- expect(http_query_param.errors[:name]).to eq(
32
- ["must exist"]
33
- )
34
-
35
- http_query_param = described_class.new(
36
- name: http_query_param_name,
37
- value: value,
38
- request: request
39
- )
40
- expect(http_query_param).to be_valid
41
- end
42
- end
43
-
44
- describe "request" do
45
- it "must require a request association" do
46
- http_query_param = described_class.new(
47
- name: http_query_param_name,
48
- value: value
49
- )
50
-
51
- expect(http_query_param).to_not be_valid
52
- expect(http_query_param.errors[:request]).to eq(
53
- ['must exist']
54
- )
55
- end
56
- end
57
- end
58
-
59
- subject do
60
- described_class.new(
61
- name: Ronin::DB::HTTPQueryParamName.new(name: name),
62
- value: value,
63
- request: request
64
- )
65
- end
66
-
67
- describe "#to_s" do
68
- it "should dump a name and a value into a String" do
69
- expect(subject.to_s).to eq("#{name}=#{value}")
70
- end
71
-
72
- context "when an empty value" do
73
- let(:value) { '' }
74
-
75
- it "should ignore empty or nil values" do
76
- expect(subject.to_s).to eq("#{name}=")
77
- end
78
- end
79
-
80
- context "when a nil value" do
81
- let(:value) { nil }
82
-
83
- it "should ignore empty or nil values" do
84
- expect(subject.to_s).to eq("#{name}=")
85
- end
86
- end
87
-
88
- context "with special characters" do
89
- let(:value) { 'bar baz' }
90
- let(:encoded_value) { URI::DEFAULT_PARSER.escape(value) }
91
-
92
- subject do
93
- described_class.new(
94
- name: Ronin::DB::HTTPQueryParamName.new(name: name),
95
- value: value
96
- )
97
- end
98
-
99
- it "should escape special characters" do
100
- expect(subject.to_s).to eq("#{name}=#{encoded_value}")
101
- end
102
- end
103
- end
104
- end
@@ -1,72 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/db/http_request_header'
3
- require 'ronin/db/http_request'
4
-
5
- describe Ronin::DB::HTTPRequestHeader do
6
- it "must use the 'ronin_http_request_headers' table" do
7
- expect(described_class.table_name).to eq('ronin_http_request_headers')
8
- end
9
-
10
- let(:name) { 'foo' }
11
- let(:value) { 'bar' }
12
-
13
- let(:http_header_name) do
14
- Ronin::DB::HTTPHeaderName.find_or_initialize_by(name: name)
15
- end
16
-
17
- let(:request_method) { :get }
18
- let(:path) { '/search' }
19
- let(:request) do
20
- Ronin::DB::HTTPRequest.new(
21
- request_method: request_method,
22
- path: path
23
- )
24
- end
25
-
26
- describe "validations" do
27
- describe "name" do
28
- it "must require a name association" do
29
- http_request_header = described_class.new(value: value)
30
- expect(http_request_header).to_not be_valid
31
- expect(http_request_header.errors[:name]).to eq(
32
- ["must exist"]
33
- )
34
-
35
- http_request_header = described_class.new(
36
- name: http_header_name,
37
- value: value,
38
- request: request
39
- )
40
- expect(http_request_header).to be_valid
41
- end
42
- end
43
-
44
- describe "request" do
45
- it "must require a request association" do
46
- http_request_header = described_class.new(
47
- name: http_header_name,
48
- value: value
49
- )
50
-
51
- expect(http_request_header).to_not be_valid
52
- expect(http_request_header.errors[:request]).to eq(
53
- ['must exist']
54
- )
55
- end
56
- end
57
- end
58
-
59
- subject do
60
- described_class.new(
61
- name: Ronin::DB::HTTPHeaderName.new(name: name),
62
- value: value,
63
- request: request
64
- )
65
- end
66
-
67
- describe "#to_s" do
68
- it "should dump a name and a value into a String" do
69
- expect(subject.to_s).to eq("#{name}: #{value}")
70
- end
71
- end
72
- end
@@ -1,168 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/db/http_request'
3
-
4
- describe Ronin::DB::HTTPRequest do
5
- it "must use the 'ronin_http_requests' table" do
6
- expect(described_class.table_name).to eq('ronin_http_requests')
7
- end
8
-
9
- let(:name) { 'foo' }
10
- let(:value) { 'bar' }
11
-
12
- let(:http_header_name) do
13
- Ronin::DB::HTTPHeaderName.find_or_initialize_by(name: name)
14
- end
15
-
16
- let(:version) { '1.1' }
17
- let(:request_method) { :get }
18
- let(:path) { '/search' }
19
-
20
- subject do
21
- described_class.new(
22
- version: version,
23
- request_method: request_method,
24
- path: path
25
- )
26
- end
27
-
28
- describe "validations" do
29
- describe "version" do
30
- %w[1.0 1.1 2.0].each do |valid_version|
31
- it "must accept '#{valid_version}'" do
32
- request = described_class.new(
33
- version: valid_version,
34
- request_method: request_method,
35
- path: path
36
- )
37
-
38
- expect(request).to be_valid
39
- end
40
- end
41
-
42
- it "must not accept any other version String" do
43
- request = described_class.new(
44
- version: '3.0',
45
- request_method: request_method,
46
- path: path
47
- )
48
-
49
- expect(request).to_not be_valid
50
- expect(request.errors[:version]).to eq(
51
- ["is not included in the list"]
52
- )
53
- end
54
-
55
- it "must not accept any other String" do
56
- request = described_class.new(
57
- version: 'foo',
58
- request_method: request_method,
59
- path: path
60
- )
61
-
62
- expect(request).to_not be_valid
63
- expect(request.errors[:version]).to eq(
64
- ["is not included in the list"]
65
- )
66
- end
67
-
68
- it "must not accept nil" do
69
- request = described_class.new(
70
- version: nil,
71
- request_method: request_method,
72
- path: path
73
- )
74
-
75
- expect(request).to_not be_valid
76
- expect(request.errors[:version]).to eq(
77
- ["can't be blank", "is not included in the list"]
78
- )
79
- end
80
- end
81
-
82
- describe "request_method" do
83
- [
84
- :copy,
85
- :delete,
86
- :get,
87
- :head,
88
- :lock,
89
- :mkcol,
90
- :move,
91
- :options,
92
- :patch,
93
- :post,
94
- :propfind,
95
- :proppatch,
96
- :put,
97
- :trace,
98
- :unlock
99
- ].each do |valid_request_method|
100
- it "must accept #{valid_request_method.inspect}" do
101
- request = described_class.new(
102
- version: version,
103
- request_method: valid_request_method,
104
- path: path
105
- )
106
-
107
- expect(request).to be_valid
108
- end
109
- end
110
-
111
- it "must not accept any other Symbol" do
112
- expect {
113
- described_class.new(
114
- version: version,
115
- request_method: :foo,
116
- path: path
117
- )
118
- }.to raise_error(ArgumentError,"'foo' is not a valid request_method")
119
- end
120
-
121
- it "must not accept a nil value" do
122
- request = described_class.new(
123
- version: version,
124
- request_method: nil,
125
- path: path
126
- )
127
-
128
- expect(request).to_not be_valid
129
- end
130
-
131
- it "must require a request_method value" do
132
- request = described_class.new(
133
- version: version,
134
- path: path
135
- )
136
-
137
- expect(request).to_not be_valid
138
- end
139
- end
140
-
141
- describe "path" do
142
- it "must require a path" do
143
- request = described_class.new(
144
- version: version,
145
- request_method: request_method
146
- )
147
-
148
- expect(request).to_not be_valid
149
- expect(request.errors[:path]).to eq(
150
- ["can't be blank"]
151
- )
152
- end
153
-
154
- it "must require a non-empty path" do
155
- request = described_class.new(
156
- version: version,
157
- request_method: request_method,
158
- path: ''
159
- )
160
-
161
- expect(request).to_not be_valid
162
- expect(request.errors[:path]).to eq(
163
- ["can't be blank"]
164
- )
165
- end
166
- end
167
- end
168
- end
@@ -1,74 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/db/http_response_header'
3
- require 'ronin/db/http_response'
4
-
5
- describe Ronin::DB::HTTPResponseHeader do
6
- it "must use the 'ronin_http_response_headers' table" do
7
- expect(described_class.table_name).to eq('ronin_http_response_headers')
8
- end
9
-
10
- let(:name) { 'foo' }
11
- let(:value) { 'bar' }
12
-
13
- let(:http_header_name) do
14
- Ronin::DB::HTTPHeaderName.find_or_initialize_by(name: name)
15
- end
16
-
17
- let(:request_method) { :get }
18
- let(:path) { '/search' }
19
- let(:request) do
20
- Ronin::DB::HTTPRequest.new(
21
- request_method: request_method,
22
- path: path,
23
- respnse: response
24
- )
25
- end
26
- let(:response) { Ronin::DB::HTTPResponse.new }
27
-
28
- describe "validations" do
29
- describe "name" do
30
- it "must require a name association" do
31
- http_response_header = described_class.new(value: value)
32
- expect(http_response_header).to_not be_valid
33
- expect(http_response_header.errors[:name]).to eq(
34
- ["must exist"]
35
- )
36
-
37
- http_response_header = described_class.new(
38
- name: http_header_name,
39
- value: value,
40
- response: response
41
- )
42
- expect(http_response_header).to be_valid
43
- end
44
- end
45
-
46
- describe "response" do
47
- it "must require a response association" do
48
- http_response_header = described_class.new(
49
- name: http_header_name,
50
- value: value
51
- )
52
-
53
- expect(http_response_header).to_not be_valid
54
- expect(http_response_header.errors[:response]).to eq(
55
- ['must exist']
56
- )
57
- end
58
- end
59
- end
60
-
61
- subject do
62
- described_class.new(
63
- name: Ronin::DB::HTTPHeaderName.new(name: name),
64
- value: value,
65
- response: response
66
- )
67
- end
68
-
69
- describe "#to_s" do
70
- it "should dump a name and a value into a String" do
71
- expect(subject.to_s).to eq("#{name}: #{value}")
72
- end
73
- end
74
- end
@@ -1,103 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/db/http_response'
3
-
4
- describe Ronin::DB::HTTPResponse do
5
- it "must use the 'ronin_http_responses' table" do
6
- expect(described_class.table_name).to eq('ronin_http_responses')
7
- end
8
-
9
- let(:name) { 'foo' }
10
- let(:value) { 'bar' }
11
-
12
- let(:http_header_name) do
13
- Ronin::DB::HTTPHeaderName.find_or_initialize_by(name: name)
14
- end
15
-
16
- let(:version) { '1.1' }
17
- let(:request_method) { :get }
18
- let(:path) { '/search' }
19
-
20
- let(:request) do
21
- Ronin::DB::HTTPRequest.new(
22
- version: version,
23
- request_method: request_method,
24
- path: path
25
- )
26
- end
27
-
28
- let(:status) { 200 }
29
- subject do
30
- described_class.new(
31
- status: status,
32
- request: request
33
- )
34
- end
35
-
36
- describe "validations" do
37
- describe "status" do
38
- it "must require a status" do
39
- response = described_class.new(request: request)
40
-
41
- expect(response).to_not be_valid
42
- expect(response.errors[:status]).to eq(
43
- ["can't be blank", "is not included in the list"]
44
- )
45
- end
46
-
47
- it "must not allow nil" do
48
- response = described_class.new(
49
- status: nil,
50
- request: request
51
- )
52
-
53
- expect(response).to_not be_valid
54
- expect(response.errors[:status]).to eq(
55
- ["can't be blank", "is not included in the list"]
56
- )
57
- end
58
-
59
- [
60
- 100, 101, 103,
61
- 200, 201, 202, 203, 204, 206, 207, 208, 226,
62
- 300, 301, 302, 303, 304, 305, 306, 307, 308,
63
- 400, 401, 402, 403, 404, 405, 406, 407, 408, 409,
64
- 410, 411, 412, 413, 414, 415, 416, 417, 418,
65
- 421, 422, 423, 424, 425, 426, 428, 429,
66
- 431, 451,
67
- 500, 501, 502, 503, 504, 505, 506, 507, 508, 511
68
- ].each do |valid_status|
69
- it "must accept #{valid_status}" do
70
- response = described_class.new(
71
- status: valid_status,
72
- request: request
73
- )
74
-
75
- expect(response).to be_valid
76
- end
77
- end
78
-
79
- it "must not accept any other Integer" do
80
- response = described_class.new(
81
- status: 600,
82
- request: request
83
- )
84
-
85
- expect(response).to_not be_valid
86
- expect(response.errors[:status]).to eq(
87
- ["is not included in the list"]
88
- )
89
- end
90
- end
91
-
92
- describe "request" do
93
- it "must require a parent request" do
94
- response = described_class.new(status: status)
95
-
96
- expect(response).to_not be_valid
97
- expect(response.errors[:request]).to eq(
98
- ["must exist"]
99
- )
100
- end
101
- end
102
- end
103
- end
@@ -1,8 +0,0 @@
1
- require 'spec_helper'
2
- require 'ronin/db/ip_address_mac_address'
3
-
4
- describe Ronin::DB::IPAddressMACAddress do
5
- it "must use the 'ronin_ip_addresses_mac_address' table" do
6
- expect(described_class.table_name).to eq('ronin_ip_address_mac_addresses')
7
- end
8
- end