ronin-db-activerecord 0.1.0.beta1
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/.document +5 -0
- data/.github/workflows/ruby.yml +31 -0
- data/.gitignore +13 -0
- data/.rspec +1 -0
- data/.ruby-version +1 -0
- data/.yardopts +1 -0
- data/COPYING.txt +165 -0
- data/ChangeLog.md +39 -0
- data/Gemfile +27 -0
- data/README.md +143 -0
- data/Rakefile +72 -0
- data/db/migrate/0001_create_ronin_ip_address_mac_addresses_table.rb +43 -0
- data/db/migrate/0002_create_ronin_vulnerabilities_table.rb +61 -0
- data/db/migrate/0003_create_ronin_url_schemes_table.rb +32 -0
- data/db/migrate/0004_create_ronin_url_query_param_names_table.rb +32 -0
- data/db/migrate/0005_create_ronin_user_names_table.rb +33 -0
- data/db/migrate/0006_create_ronin_software_vendors_table.rb +32 -0
- data/db/migrate/0007_create_ronin_advisories_table.rb +42 -0
- data/db/migrate/0008_create_ronin_host_name_ip_addresses_table.rb +43 -0
- data/db/migrate/0009_create_ronin_host_names_table.rb +34 -0
- data/db/migrate/0010_create_ronin_arches_table.rb +37 -0
- data/db/migrate/0011_create_ronin_email_addresses_table.rb +44 -0
- data/db/migrate/0012_create_ronin_oses_table.rb +36 -0
- data/db/migrate/0013_create_ronin_organizations_table.rb +31 -0
- data/db/migrate/0014_create_ronin_ip_addresses_table.rb +35 -0
- data/db/migrate/0015_create_ronin_os_guesses_table.rb +40 -0
- data/db/migrate/0016_create_ronin_url_query_params_table.rb +42 -0
- data/db/migrate/0017_create_ronin_passwords_table.rb +32 -0
- data/db/migrate/0018_create_ronin_open_ports_table.rb +46 -0
- data/db/migrate/0019_create_ronin_urls_table.rb +50 -0
- data/db/migrate/0020_create_ronin_softwares_table.rb +39 -0
- data/db/migrate/0021_create_ronin_mac_addresses_table.rb +33 -0
- data/db/migrate/0022_create_ronin_countries_table.rb +34 -0
- data/db/migrate/0023_create_ronin_services_table.rb +32 -0
- data/db/migrate/0024_create_ronin_credentials_table.rb +44 -0
- data/db/migrate/0025_create_ronin_ports_table.rb +33 -0
- data/db/migrate/0026_create_ronin_asns_table.rb +44 -0
- data/db/migrate/0027_create_ronin_http_query_param_names_table.rb +32 -0
- data/db/migrate/0028_create_ronin_http_query_params_table.rb +42 -0
- data/db/migrate/0029_create_ronin_http_header_names_table.rb +31 -0
- data/db/migrate/0030_create_ronin_http_request_headers_table.rb +41 -0
- data/db/migrate/0031_create_ronin_http_response_headers_table.rb +41 -0
- data/db/migrate/0032_create_ronin_http_requests_table.rb +41 -0
- data/db/migrate/0033_create_ronin_http_responses_table.rb +36 -0
- data/db/migrate/0034_create_ronin_service_credentials_table.rb +41 -0
- data/db/migrate/0035_create_ronin_web_credentials_table.rb +41 -0
- data/gemspec.yml +28 -0
- data/lib/ronin/db/address.rb +105 -0
- data/lib/ronin/db/advisory.rb +169 -0
- data/lib/ronin/db/arch.rb +160 -0
- data/lib/ronin/db/asn.rb +212 -0
- data/lib/ronin/db/credential.rb +248 -0
- data/lib/ronin/db/email_address.rb +225 -0
- data/lib/ronin/db/host_name.rb +224 -0
- data/lib/ronin/db/host_name_ip_address.rb +65 -0
- data/lib/ronin/db/http_header_name.rb +75 -0
- data/lib/ronin/db/http_query_param.rb +79 -0
- data/lib/ronin/db/http_query_param_name.rb +76 -0
- data/lib/ronin/db/http_request.rb +120 -0
- data/lib/ronin/db/http_request_header.rb +78 -0
- data/lib/ronin/db/http_response.rb +91 -0
- data/lib/ronin/db/http_response_header.rb +78 -0
- data/lib/ronin/db/ip_address.rb +351 -0
- data/lib/ronin/db/ip_address_mac_address.rb +62 -0
- data/lib/ronin/db/mac_address.rb +91 -0
- data/lib/ronin/db/migrations.rb +137 -0
- data/lib/ronin/db/model/has_name.rb +102 -0
- data/lib/ronin/db/model/has_unique_name.rb +82 -0
- data/lib/ronin/db/model/importable.rb +85 -0
- data/lib/ronin/db/model/last_scanned_at.rb +48 -0
- data/lib/ronin/db/model.rb +37 -0
- data/lib/ronin/db/models.rb +108 -0
- data/lib/ronin/db/open_port.rb +148 -0
- data/lib/ronin/db/organization.rb +50 -0
- data/lib/ronin/db/os.rb +183 -0
- data/lib/ronin/db/os_guess.rb +67 -0
- data/lib/ronin/db/password.rb +167 -0
- data/lib/ronin/db/port.rb +123 -0
- data/lib/ronin/db/root.rb +28 -0
- data/lib/ronin/db/schema_migration.rb +34 -0
- data/lib/ronin/db/service.rb +48 -0
- data/lib/ronin/db/service_credential.rb +66 -0
- data/lib/ronin/db/software.rb +85 -0
- data/lib/ronin/db/software_vendor.rb +42 -0
- data/lib/ronin/db/url.rb +497 -0
- data/lib/ronin/db/url_query_param.rb +79 -0
- data/lib/ronin/db/url_query_param_name.rb +76 -0
- data/lib/ronin/db/url_scheme.rb +80 -0
- data/lib/ronin/db/user_name.rb +96 -0
- data/lib/ronin/db/vulnerability.rb +81 -0
- data/lib/ronin/db/web_credential.rb +69 -0
- data/ronin-db-activerecord.gemspec +61 -0
- data/spec/advisory_spec.rb +277 -0
- data/spec/arch_spec.rb +228 -0
- data/spec/asn_spec.rb +504 -0
- data/spec/credential_spec.rb +362 -0
- data/spec/email_address_spec.rb +372 -0
- data/spec/host_name_ip_address_spec.rb +8 -0
- data/spec/host_name_spec.rb +207 -0
- data/spec/http_header_name_spec.rb +25 -0
- data/spec/http_query_param_name_spec.rb +25 -0
- data/spec/http_query_param_spec.rb +104 -0
- data/spec/http_request_header_spec.rb +72 -0
- data/spec/http_request_spec.rb +168 -0
- data/spec/http_response_header_spec.rb +74 -0
- data/spec/http_response_spec.rb +103 -0
- data/spec/ip_address_mac_addresses_spec.rb +8 -0
- data/spec/ip_address_spec.rb +386 -0
- data/spec/mac_address_spec.rb +67 -0
- data/spec/migrations_spec.rb +122 -0
- data/spec/model/has_name_spec.rb +65 -0
- data/spec/model/has_unique_name_spec.rb +61 -0
- data/spec/model/importable_spec.rb +105 -0
- data/spec/models_spec.rb +60 -0
- data/spec/open_port_spec.rb +87 -0
- data/spec/organization_spec.rb +10 -0
- data/spec/os_guess_spec.rb +43 -0
- data/spec/os_spec.rb +114 -0
- data/spec/password_spec.rb +81 -0
- data/spec/port_spec.rb +102 -0
- data/spec/schema_migration_spec.rb +8 -0
- data/spec/service_credential_spec.rb +43 -0
- data/spec/service_spec.rb +39 -0
- data/spec/software_spec.rb +76 -0
- data/spec/software_vendor_spec.rb +33 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/url_query_param_name_spec.rb +25 -0
- data/spec/url_query_param_spec.rb +110 -0
- data/spec/url_scheme_spec.rb +39 -0
- data/spec/url_spec.rb +951 -0
- data/spec/user_name_spec.rb +54 -0
- data/spec/vulnerability_spec.rb +8 -0
- data/spec/web_credential_spec.rb +72 -0
- metadata +266 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
#
|
|
3
|
+
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
|
4
|
+
#
|
|
5
|
+
# Copyright (c) 2022 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
+
#
|
|
7
|
+
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published
|
|
9
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
# (at your option) any later version.
|
|
11
|
+
#
|
|
12
|
+
# ronin-db-activerecord is distributed in the hope that it will be useful,
|
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
# GNU Lesser General Public License for more details.
|
|
16
|
+
#
|
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
# along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
require 'ronin/db/model'
|
|
22
|
+
|
|
23
|
+
require 'active_record'
|
|
24
|
+
|
|
25
|
+
module Ronin
|
|
26
|
+
module DB
|
|
27
|
+
#
|
|
28
|
+
# Associates a {HostName} with an {IPAddress}.
|
|
29
|
+
#
|
|
30
|
+
class HostNameIPAddress < ActiveRecord::Base
|
|
31
|
+
|
|
32
|
+
include Model
|
|
33
|
+
|
|
34
|
+
# self.table_name = 'ronin_host_name_ip_addresses'
|
|
35
|
+
|
|
36
|
+
# @!attribute [rw] id
|
|
37
|
+
# The primary-key of the join model.
|
|
38
|
+
#
|
|
39
|
+
# @return [Integer]
|
|
40
|
+
attribute :id, :integer
|
|
41
|
+
|
|
42
|
+
# @!attribute [rw] host_name
|
|
43
|
+
# The host name pointing to the IP Address
|
|
44
|
+
#
|
|
45
|
+
# @return [HostName]
|
|
46
|
+
belongs_to :host_name, required: true,
|
|
47
|
+
inverse_of: :host_name_ip_addresses
|
|
48
|
+
|
|
49
|
+
# @!attribute [rw] ip_address
|
|
50
|
+
# The associated IP address.
|
|
51
|
+
#
|
|
52
|
+
# @return [IPAddress]
|
|
53
|
+
belongs_to :ip_address, required: true,
|
|
54
|
+
inverse_of: :host_name_ip_addresses,
|
|
55
|
+
class_name: 'IPAddress'
|
|
56
|
+
|
|
57
|
+
# @!attribute [rw] created_at
|
|
58
|
+
# Tracks when a IP Address is associated with a host name
|
|
59
|
+
#
|
|
60
|
+
# @return [Time]
|
|
61
|
+
attribute :created_at, :time
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
#
|
|
3
|
+
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
|
4
|
+
#
|
|
5
|
+
# Copyright (c) 2022 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
+
#
|
|
7
|
+
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published
|
|
9
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
# (at your option) any later version.
|
|
11
|
+
#
|
|
12
|
+
# ronin-db-activerecord is distributed in the hope that it will be useful,
|
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
# GNU Lesser General Public License for more details.
|
|
16
|
+
#
|
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
# along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
require 'ronin/db/model'
|
|
22
|
+
require 'ronin/db/model/has_unique_name'
|
|
23
|
+
|
|
24
|
+
require 'active_record'
|
|
25
|
+
|
|
26
|
+
module Ronin
|
|
27
|
+
module DB
|
|
28
|
+
#
|
|
29
|
+
# Represents a HTTP request or response Header name.
|
|
30
|
+
#
|
|
31
|
+
class HTTPHeaderName < ActiveRecord::Base
|
|
32
|
+
|
|
33
|
+
include Model
|
|
34
|
+
include Model::HasUniqueName
|
|
35
|
+
|
|
36
|
+
# @!attribute [rw] id
|
|
37
|
+
# The primary key of the HTTP header name.
|
|
38
|
+
#
|
|
39
|
+
# @return [Integer]
|
|
40
|
+
attribute :id, :integer
|
|
41
|
+
|
|
42
|
+
# @!attribute [rw] name
|
|
43
|
+
# The Header name.
|
|
44
|
+
#
|
|
45
|
+
# @return [String]
|
|
46
|
+
attribute :name, :string # length: 256
|
|
47
|
+
validates :name, presence: true, uniqueness: true
|
|
48
|
+
|
|
49
|
+
# @!attribute [rw] http_request_headers
|
|
50
|
+
# The associated HTTP request headers.
|
|
51
|
+
#
|
|
52
|
+
# @return [Array<HTTPRequestHeader>]
|
|
53
|
+
has_many :http_request_headers
|
|
54
|
+
|
|
55
|
+
# @!attribute [rw] http_requests
|
|
56
|
+
# The HTTP requests which contain this HTTP Header name.
|
|
57
|
+
#
|
|
58
|
+
# @return [Array<HTTPRequest>]
|
|
59
|
+
has_many :http_requests, through: :http_request_headers
|
|
60
|
+
|
|
61
|
+
# @!attribute [rw] http_response_headers
|
|
62
|
+
# The associated HTTP response headers.
|
|
63
|
+
#
|
|
64
|
+
# @return [Array<HTTPResponseHeader>]
|
|
65
|
+
has_many :http_response_headers
|
|
66
|
+
|
|
67
|
+
# @!attribute [rw] http_responses
|
|
68
|
+
# The HTTP responses which contain this HTTP Header name.
|
|
69
|
+
#
|
|
70
|
+
# @return [Array<HTTPResponse>]
|
|
71
|
+
has_many :http_responses, through: :http_response_headers
|
|
72
|
+
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
#
|
|
3
|
+
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
|
4
|
+
#
|
|
5
|
+
# Copyright (c) 2022 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
+
#
|
|
7
|
+
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published
|
|
9
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
# (at your option) any later version.
|
|
11
|
+
#
|
|
12
|
+
# ronin-db-activerecord is distributed in the hope that it will be useful,
|
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
# GNU Lesser General Public License for more details.
|
|
16
|
+
#
|
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
# along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
require 'ronin/db/model'
|
|
22
|
+
|
|
23
|
+
require 'active_record'
|
|
24
|
+
require 'uri/query_params'
|
|
25
|
+
|
|
26
|
+
module Ronin
|
|
27
|
+
module DB
|
|
28
|
+
#
|
|
29
|
+
# Represents a query param that belongs to a {HTTPRequest}.
|
|
30
|
+
#
|
|
31
|
+
class HTTPQueryParam < ActiveRecord::Base
|
|
32
|
+
|
|
33
|
+
include Model
|
|
34
|
+
|
|
35
|
+
# @!attribute [rw] id
|
|
36
|
+
# The primary-key of the HTTP query param
|
|
37
|
+
#
|
|
38
|
+
# @return [Integer]
|
|
39
|
+
attribute :id, :integer
|
|
40
|
+
|
|
41
|
+
# @!attribute [rw] name
|
|
42
|
+
# The name of the HTTP query param
|
|
43
|
+
#
|
|
44
|
+
# @return [HTTPQueryParamName]
|
|
45
|
+
belongs_to :name, required: true,
|
|
46
|
+
class_name: 'HTTPQueryParamName'
|
|
47
|
+
validates :name_id, uniqueness: {scope: :request_id}
|
|
48
|
+
|
|
49
|
+
# @!attribute [rw] value
|
|
50
|
+
# The value of the HTTP query param
|
|
51
|
+
#
|
|
52
|
+
# @return [String]
|
|
53
|
+
attribute :value, :text
|
|
54
|
+
|
|
55
|
+
# @!attribute [rw] request
|
|
56
|
+
# The HTTP request which contains this HTTP query param.
|
|
57
|
+
#
|
|
58
|
+
# @return [HTTPRequest]
|
|
59
|
+
belongs_to :request, required: true,
|
|
60
|
+
class_name: 'HTTPRequest'
|
|
61
|
+
|
|
62
|
+
#
|
|
63
|
+
# Converts the HTTP query param to a String.
|
|
64
|
+
#
|
|
65
|
+
# @return [String]
|
|
66
|
+
# The dumped HTTP query param.
|
|
67
|
+
#
|
|
68
|
+
# @api public
|
|
69
|
+
#
|
|
70
|
+
def to_s
|
|
71
|
+
URI::QueryParams.dump(self.name.to_s => self.value)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
require 'ronin/db/http_query_param_name'
|
|
79
|
+
require 'ronin/db/http_request'
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
#
|
|
3
|
+
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
|
4
|
+
#
|
|
5
|
+
# Copyright (c) 2022 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
+
#
|
|
7
|
+
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published
|
|
9
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
# (at your option) any later version.
|
|
11
|
+
#
|
|
12
|
+
# ronin-db-activerecord is distributed in the hope that it will be useful,
|
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
# GNU Lesser General Public License for more details.
|
|
16
|
+
#
|
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
# along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
require 'ronin/db/model'
|
|
22
|
+
require 'ronin/db/model/has_unique_name'
|
|
23
|
+
|
|
24
|
+
require 'active_record'
|
|
25
|
+
|
|
26
|
+
module Ronin
|
|
27
|
+
module DB
|
|
28
|
+
#
|
|
29
|
+
# Represents the name of a {HTTPQueryParam}.
|
|
30
|
+
#
|
|
31
|
+
class HTTPQueryParamName < ActiveRecord::Base
|
|
32
|
+
|
|
33
|
+
include Model
|
|
34
|
+
include Model::HasUniqueName
|
|
35
|
+
|
|
36
|
+
# @!attribute [rw] id
|
|
37
|
+
# The primary-key of the HTTP query param
|
|
38
|
+
#
|
|
39
|
+
# @return [Integer]
|
|
40
|
+
attribute :id, :integer
|
|
41
|
+
|
|
42
|
+
# @!attribute [rw] name
|
|
43
|
+
# The name of the HTTP query param.
|
|
44
|
+
#
|
|
45
|
+
# @return [String]
|
|
46
|
+
attribute :name, :string # length: 256
|
|
47
|
+
validates :name, presence: true, uniqueness: true
|
|
48
|
+
|
|
49
|
+
# @!attribute [rw] query_params
|
|
50
|
+
# The HTTP query params.
|
|
51
|
+
#
|
|
52
|
+
# @return [Array<URLQueryParam>]
|
|
53
|
+
has_many :query_params, class_name: 'HTTPQueryParam',
|
|
54
|
+
foreign_key: :name_id
|
|
55
|
+
|
|
56
|
+
# @!attribute [rw] created_at
|
|
57
|
+
# When the HTTP query param name was first created.
|
|
58
|
+
#
|
|
59
|
+
# @return [Time]
|
|
60
|
+
attribute :created_at, :time
|
|
61
|
+
|
|
62
|
+
#
|
|
63
|
+
# Converts the HTTP query param name to a String.
|
|
64
|
+
#
|
|
65
|
+
# @return [String]
|
|
66
|
+
# The name of the HTTP query param
|
|
67
|
+
#
|
|
68
|
+
# @api public
|
|
69
|
+
#
|
|
70
|
+
def to_s
|
|
71
|
+
self.name.to_s
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
#
|
|
3
|
+
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
|
4
|
+
#
|
|
5
|
+
# Copyright (c) 2022 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
+
#
|
|
7
|
+
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published
|
|
9
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
# (at your option) any later version.
|
|
11
|
+
#
|
|
12
|
+
# ronin-db-activerecord is distributed in the hope that it will be useful,
|
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
# GNU Lesser General Public License for more details.
|
|
16
|
+
#
|
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
# along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
require 'ronin/db/model'
|
|
22
|
+
|
|
23
|
+
require 'active_record'
|
|
24
|
+
|
|
25
|
+
module Ronin
|
|
26
|
+
module DB
|
|
27
|
+
#
|
|
28
|
+
# Represents a HTTP request.
|
|
29
|
+
#
|
|
30
|
+
class HTTPRequest < ActiveRecord::Base
|
|
31
|
+
|
|
32
|
+
include Model
|
|
33
|
+
|
|
34
|
+
# @!attribute [rw] id
|
|
35
|
+
# The primary ID for the HTTP request.
|
|
36
|
+
#
|
|
37
|
+
# @return [Integer]
|
|
38
|
+
attribute :id, :integer
|
|
39
|
+
|
|
40
|
+
# @!attribute [rw] version
|
|
41
|
+
# The HTTP version of the HTTP request.
|
|
42
|
+
#
|
|
43
|
+
# @return [String]
|
|
44
|
+
attribute :version, :string
|
|
45
|
+
validates :version, presence: true,
|
|
46
|
+
inclusion: {in: %w[1.0 1.1 2.0]}
|
|
47
|
+
|
|
48
|
+
# @!attribute [rw] request_method
|
|
49
|
+
# The request method.
|
|
50
|
+
#
|
|
51
|
+
# @return [:copy, :delete, :get, :head, :lock, :mkcol, :move, :options, :patch, :post, :propfind, :proppatch, :put, :trace, :unlock]
|
|
52
|
+
enum request_method: [
|
|
53
|
+
:copy,
|
|
54
|
+
:delete,
|
|
55
|
+
:get,
|
|
56
|
+
:head,
|
|
57
|
+
:lock,
|
|
58
|
+
:mkcol,
|
|
59
|
+
:move,
|
|
60
|
+
:options,
|
|
61
|
+
:patch,
|
|
62
|
+
:post,
|
|
63
|
+
:propfind,
|
|
64
|
+
:proppatch,
|
|
65
|
+
:put,
|
|
66
|
+
:trace,
|
|
67
|
+
:unlock
|
|
68
|
+
], _suffix: :requests
|
|
69
|
+
validates :request_method, presence: true
|
|
70
|
+
|
|
71
|
+
# @!attribute [rw] path
|
|
72
|
+
# The path of the HTTP request.
|
|
73
|
+
#
|
|
74
|
+
# @return [String]
|
|
75
|
+
attribute :path, :string
|
|
76
|
+
validates :path, presence: true
|
|
77
|
+
|
|
78
|
+
# @!attribute [rw] query
|
|
79
|
+
# The query string of the HTTP request.
|
|
80
|
+
#
|
|
81
|
+
# @return [String, nil]
|
|
82
|
+
attribute :query, :string
|
|
83
|
+
|
|
84
|
+
# @!attribute [rw] query_params
|
|
85
|
+
# The additional parsed query params of the HTTP request.
|
|
86
|
+
#
|
|
87
|
+
# @return [Array<HTTPQueryParam>]
|
|
88
|
+
has_many :query_params, foreign_key: 'request_id',
|
|
89
|
+
class_name: 'HTTPQueryParam',
|
|
90
|
+
dependent: :destroy
|
|
91
|
+
# @!attribute [rw] body
|
|
92
|
+
# The optional body of the HTTP request.
|
|
93
|
+
#
|
|
94
|
+
# @return [String, nil]
|
|
95
|
+
attribute :body, :text
|
|
96
|
+
|
|
97
|
+
# @!attribute [rw] headers
|
|
98
|
+
# The additional headers of HTTP request.
|
|
99
|
+
#
|
|
100
|
+
# @return [Array<HTTPRequestHeader>]
|
|
101
|
+
has_many :headers, foreign_key: 'request_id',
|
|
102
|
+
class_name: 'HTTPRequestHeader',
|
|
103
|
+
dependent: :destroy
|
|
104
|
+
|
|
105
|
+
# @!attribute [rw] response
|
|
106
|
+
# The optional HTTP response associated with the HTTP request.
|
|
107
|
+
#
|
|
108
|
+
# @return [HTTPResponse, nil]
|
|
109
|
+
belongs_to :response, class_name: 'HTTPResponse',
|
|
110
|
+
dependent: :destroy
|
|
111
|
+
|
|
112
|
+
# @!attribute [rw] created_at
|
|
113
|
+
# When the HTTP request was created.
|
|
114
|
+
#
|
|
115
|
+
# @return [Time]
|
|
116
|
+
attribute :created_at, :time
|
|
117
|
+
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
#
|
|
3
|
+
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
|
4
|
+
#
|
|
5
|
+
# Copyright (c) 2022 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
+
#
|
|
7
|
+
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published
|
|
9
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
# (at your option) any later version.
|
|
11
|
+
#
|
|
12
|
+
# ronin-db-activerecord is distributed in the hope that it will be useful,
|
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
# GNU Lesser General Public License for more details.
|
|
16
|
+
#
|
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
# along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
require 'ronin/db/model'
|
|
22
|
+
|
|
23
|
+
require 'active_record'
|
|
24
|
+
|
|
25
|
+
module Ronin
|
|
26
|
+
module DB
|
|
27
|
+
#
|
|
28
|
+
# Represents a HTTP header sent in a HTTP request.
|
|
29
|
+
#
|
|
30
|
+
class HTTPRequestHeader < ActiveRecord::Base
|
|
31
|
+
|
|
32
|
+
include Model
|
|
33
|
+
|
|
34
|
+
# @!attribute [rw] id
|
|
35
|
+
# The primary ID of the HTTP request header.
|
|
36
|
+
#
|
|
37
|
+
# @return [Integer]
|
|
38
|
+
attribute :id, :integer
|
|
39
|
+
|
|
40
|
+
# @!attribute [rw] name
|
|
41
|
+
# The name of the HTTP request header.
|
|
42
|
+
#
|
|
43
|
+
# @return [HTTPHeaderName]
|
|
44
|
+
belongs_to :name, required: true,
|
|
45
|
+
class_name: 'HTTPHeaderName'
|
|
46
|
+
|
|
47
|
+
# @!attribute [rw] value
|
|
48
|
+
# The value of the HTTP request header.
|
|
49
|
+
#
|
|
50
|
+
# @return [String]
|
|
51
|
+
attribute :value, :string
|
|
52
|
+
validates :value, presence: true
|
|
53
|
+
|
|
54
|
+
# @!attribute [rw] request
|
|
55
|
+
# The HTTP request that the header belongs to.
|
|
56
|
+
#
|
|
57
|
+
# @return [HTTPRequest]
|
|
58
|
+
belongs_to :request, required: true,
|
|
59
|
+
class_name: 'HTTPRequest'
|
|
60
|
+
|
|
61
|
+
#
|
|
62
|
+
# Converts the HTTP request header to a String.
|
|
63
|
+
#
|
|
64
|
+
# @return [String]
|
|
65
|
+
# The header's name and value.
|
|
66
|
+
#
|
|
67
|
+
# @api public
|
|
68
|
+
#
|
|
69
|
+
def to_s
|
|
70
|
+
"#{self.name}: #{self.value}"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
require 'ronin/db/http_header_name'
|
|
78
|
+
require 'ronin/db/http_request'
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
#
|
|
3
|
+
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
|
4
|
+
#
|
|
5
|
+
# Copyright (c) 2022 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
+
#
|
|
7
|
+
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published
|
|
9
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
# (at your option) any later version.
|
|
11
|
+
#
|
|
12
|
+
# ronin-db-activerecord is distributed in the hope that it will be useful,
|
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
# GNU Lesser General Public License for more details.
|
|
16
|
+
#
|
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
# along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
require 'ronin/db/model'
|
|
22
|
+
|
|
23
|
+
require 'active_record'
|
|
24
|
+
|
|
25
|
+
module Ronin
|
|
26
|
+
module DB
|
|
27
|
+
#
|
|
28
|
+
# Represents a HTTP response.
|
|
29
|
+
#
|
|
30
|
+
class HTTPResponse < ActiveRecord::Base
|
|
31
|
+
|
|
32
|
+
include Model
|
|
33
|
+
|
|
34
|
+
# @!attribute [rw] id
|
|
35
|
+
# The primary ID of the HTTP reponse.
|
|
36
|
+
#
|
|
37
|
+
# @return [Integer]
|
|
38
|
+
attribute :id, :integer
|
|
39
|
+
|
|
40
|
+
# @!attribute [rw] status
|
|
41
|
+
# The HTTP status code of the response.
|
|
42
|
+
#
|
|
43
|
+
# @return [Integer]
|
|
44
|
+
attribute :status, :integer
|
|
45
|
+
validates :status, presence: true,
|
|
46
|
+
inclusion: {
|
|
47
|
+
in: [
|
|
48
|
+
100, 101, 103,
|
|
49
|
+
200, 201, 202, 203, 204, 206, 207, 208, 226,
|
|
50
|
+
300, 301, 302, 303, 304, 305, 306, 307, 308,
|
|
51
|
+
400, 401, 402, 403, 404, 405, 406, 407, 408, 409,
|
|
52
|
+
410, 411, 412, 413, 414, 415, 416, 417, 418,
|
|
53
|
+
421, 422, 423, 424, 425, 426, 428, 429,
|
|
54
|
+
431, 451,
|
|
55
|
+
500, 501, 502, 503, 504, 505, 506, 507, 508, 511
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# @!attribute [rw] headers
|
|
60
|
+
# The associated headers of the HTTP response.
|
|
61
|
+
#
|
|
62
|
+
# @return [Array<HTTPResponseHeader>]
|
|
63
|
+
has_many :headers, foreign_key: :request_id,
|
|
64
|
+
class_name: 'HTTPResponseHeader',
|
|
65
|
+
dependent: :destroy
|
|
66
|
+
|
|
67
|
+
# @!attribute [rw] body
|
|
68
|
+
# The optional body of the HTTP response.
|
|
69
|
+
#
|
|
70
|
+
# @return [String, nil]
|
|
71
|
+
attribute :body, :text
|
|
72
|
+
|
|
73
|
+
# @!attribute [r] created_at
|
|
74
|
+
# When the HTTP response was created.
|
|
75
|
+
#
|
|
76
|
+
# @return [Time]
|
|
77
|
+
attribute :created_at, :time
|
|
78
|
+
|
|
79
|
+
# @!attribute [rw] request
|
|
80
|
+
# The associated HTTP request that the response was returned for.
|
|
81
|
+
#
|
|
82
|
+
# @return [HTTPRequest]
|
|
83
|
+
has_one :request, required: true,
|
|
84
|
+
foreign_key: :response_id,
|
|
85
|
+
class_name: 'HTTPRequest'
|
|
86
|
+
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
require 'ronin/db/http_request'
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
#
|
|
3
|
+
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
|
4
|
+
#
|
|
5
|
+
# Copyright (c) 2022 Hal Brodigan (postmodern.mod3 at gmail.com)
|
|
6
|
+
#
|
|
7
|
+
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
|
8
|
+
# it under the terms of the GNU Lesser General Public License as published
|
|
9
|
+
# by the Free Software Foundation, either version 3 of the License, or
|
|
10
|
+
# (at your option) any later version.
|
|
11
|
+
#
|
|
12
|
+
# ronin-db-activerecord is distributed in the hope that it will be useful,
|
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
# GNU Lesser General Public License for more details.
|
|
16
|
+
#
|
|
17
|
+
# You should have received a copy of the GNU Lesser General Public License
|
|
18
|
+
# along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
require 'ronin/db/model'
|
|
22
|
+
|
|
23
|
+
require 'active_record'
|
|
24
|
+
|
|
25
|
+
module Ronin
|
|
26
|
+
module DB
|
|
27
|
+
#
|
|
28
|
+
# Represents a HTTP header belonging to an HTTP response.
|
|
29
|
+
#
|
|
30
|
+
class HTTPResponseHeader < ActiveRecord::Base
|
|
31
|
+
|
|
32
|
+
include Model
|
|
33
|
+
|
|
34
|
+
# @!attribute [rw] id
|
|
35
|
+
# The primary ID of the HTTP response header.
|
|
36
|
+
#
|
|
37
|
+
# @return [Integer]
|
|
38
|
+
attribute :id, :integer
|
|
39
|
+
|
|
40
|
+
# @!attribute [rw] name
|
|
41
|
+
# The name of the HTTP response header.
|
|
42
|
+
#
|
|
43
|
+
# @return [HTTPHeaderName]
|
|
44
|
+
belongs_to :name, required: true,
|
|
45
|
+
class_name: 'HTTPHeaderName'
|
|
46
|
+
|
|
47
|
+
# @!attribute [rw] value
|
|
48
|
+
# The value of the HTTP response header.
|
|
49
|
+
#
|
|
50
|
+
# @return [String]
|
|
51
|
+
attribute :value, :string
|
|
52
|
+
validates :value, presence: true
|
|
53
|
+
|
|
54
|
+
# @!attribute [rw] response
|
|
55
|
+
# The associated HTTP response that the HTTP response header belongs to.
|
|
56
|
+
#
|
|
57
|
+
# @return [HTTPResponse]
|
|
58
|
+
belongs_to :response, required: true,
|
|
59
|
+
class_name: 'HTTPResponse'
|
|
60
|
+
|
|
61
|
+
#
|
|
62
|
+
# Converts the HTTP request header to a String.
|
|
63
|
+
#
|
|
64
|
+
# @return [String]
|
|
65
|
+
# The header's name and value.
|
|
66
|
+
#
|
|
67
|
+
# @api public
|
|
68
|
+
#
|
|
69
|
+
def to_s
|
|
70
|
+
"#{self.name}: #{self.value}"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
require 'ronin/db/http_header_name'
|
|
78
|
+
require 'ronin/db/http_response'
|