ronin-db-activerecord 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.document +0 -1
- data/.github/workflows/ruby.yml +14 -0
- data/.rubocop.yml +16 -0
- data/ChangeLog.md +18 -1
- data/Gemfile +4 -0
- data/README.md +1 -2
- data/Rakefile +3 -3
- data/db/migrate/{0014_create_ronin_ip_addresses_table.rb → 0001_create_ronin_ip_addresses_table.rb} +4 -0
- data/db/migrate/{0021_create_ronin_mac_addresses_table.rb → 0002_create_ronin_mac_addresses_table.rb} +4 -0
- data/db/migrate/{0001_create_ronin_ip_address_mac_addresses_table.rb → 0003_create_ronin_ip_address_mac_addresses_table.rb} +4 -0
- data/db/migrate/{0009_create_ronin_host_names_table.rb → 0004_create_ronin_host_names_table.rb} +4 -0
- data/db/migrate/{0025_create_ronin_ports_table.rb → 0005_create_ronin_ports_table.rb} +4 -0
- data/db/migrate/{0023_create_ronin_services_table.rb → 0006_create_ronin_services_table.rb} +4 -0
- data/db/migrate/{0018_create_ronin_open_ports_table.rb → 0007_create_ronin_open_ports_table.rb} +4 -0
- data/db/migrate/{0003_create_ronin_url_schemes_table.rb → 0008_create_ronin_url_schemes_table.rb} +4 -0
- data/db/migrate/{0019_create_ronin_urls_table.rb → 0009_create_ronin_urls_table.rb} +5 -0
- data/db/migrate/0010_create_ronin_advisories_table.rb +45 -0
- data/db/migrate/{0002_create_ronin_vulnerabilities_table.rb → 0011_create_ronin_vulnerabilities_table.rb} +14 -11
- data/db/migrate/{0004_create_ronin_url_query_param_names_table.rb → 0012_create_ronin_url_query_param_names_table.rb} +4 -0
- data/db/migrate/{0005_create_ronin_user_names_table.rb → 0013_create_ronin_user_names_table.rb} +4 -0
- data/db/migrate/{0006_create_ronin_software_vendors_table.rb → 0014_create_ronin_software_vendors_table.rb} +4 -0
- data/db/migrate/{0008_create_ronin_host_name_ip_addresses_table.rb → 0015_create_ronin_host_name_ip_addresses_table.rb} +4 -0
- data/db/migrate/{0010_create_ronin_arches_table.rb → 0016_create_ronin_arches_table.rb} +3 -0
- data/db/migrate/{0011_create_ronin_email_addresses_table.rb → 0017_create_ronin_email_addresses_table.rb} +4 -0
- data/db/migrate/{0012_create_ronin_oses_table.rb → 0018_create_ronin_oses_table.rb} +4 -0
- data/db/migrate/{0013_create_ronin_organizations_table.rb → 0019_create_ronin_organizations_table.rb} +4 -0
- data/db/migrate/{0015_create_ronin_os_guesses_table.rb → 0020_create_ronin_os_guesses_table.rb} +4 -0
- data/db/migrate/{0016_create_ronin_url_query_params_table.rb → 0021_create_ronin_url_query_params_table.rb} +4 -0
- data/db/migrate/{0017_create_ronin_passwords_table.rb → 0022_create_ronin_passwords_table.rb} +4 -0
- data/db/migrate/{0020_create_ronin_softwares_table.rb → 0023_create_ronin_softwares_table.rb} +5 -3
- data/db/migrate/{0022_create_ronin_countries_table.rb → 0024_create_ronin_countries_table.rb} +4 -0
- data/db/migrate/{0024_create_ronin_credentials_table.rb → 0025_create_ronin_credentials_table.rb} +4 -0
- data/db/migrate/0026_create_ronin_asns_table.rb +4 -0
- data/db/migrate/0027_create_ronin_http_query_param_names_table.rb +4 -0
- data/db/migrate/{0033_create_ronin_http_responses_table.rb → 0028_create_ronin_http_responses_table.rb} +5 -3
- data/db/migrate/{0032_create_ronin_http_requests_table.rb → 0029_create_ronin_http_requests_table.rb} +5 -3
- data/db/migrate/{0028_create_ronin_http_query_params_table.rb → 0030_create_ronin_http_query_params_table.rb} +4 -0
- data/db/migrate/{0029_create_ronin_http_header_names_table.rb → 0031_create_ronin_http_header_names_table.rb} +4 -0
- data/db/migrate/{0030_create_ronin_http_request_headers_table.rb → 0032_create_ronin_http_request_headers_table.rb} +4 -0
- data/db/migrate/{0031_create_ronin_http_response_headers_table.rb → 0033_create_ronin_http_response_headers_table.rb} +4 -0
- data/db/migrate/0034_create_ronin_service_credentials_table.rb +4 -0
- data/db/migrate/0035_create_ronin_web_credentials_table.rb +4 -0
- data/gemspec.yml +1 -1
- data/lib/ronin/db/address.rb +4 -2
- data/lib/ronin/db/advisory.rb +4 -4
- data/lib/ronin/db/asn.rb +5 -5
- 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_query_param_name.rb +1 -1
- data/lib/ronin/db/http_request.rb +1 -1
- data/lib/ronin/db/http_response.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 +4 -4
- data/lib/ronin/db/migrations.rb +11 -8
- data/lib/ronin/db/model/has_unique_name.rb +2 -4
- data/lib/ronin/db/model/importable.rb +3 -0
- data/lib/ronin/db/model/last_scanned_at.rb +4 -1
- data/lib/ronin/db/model.rb +3 -0
- data/lib/ronin/db/models.rb +3 -0
- data/lib/ronin/db/open_port.rb +1 -1
- data/lib/ronin/db/organization.rb +1 -1
- data/lib/ronin/db/os.rb +2 -2
- data/lib/ronin/db/os_guess.rb +1 -1
- data/lib/ronin/db/password.rb +3 -3
- data/lib/ronin/db/software.rb +2 -2
- data/lib/ronin/db/url.rb +21 -24
- 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 +4 -0
- data/ronin-db-activerecord.gemspec +3 -3
- metadata +34 -33
- data/db/migrate/0007_create_ronin_advisories_table.rb +0 -42
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
3
4
|
#
|
@@ -19,6 +20,9 @@
|
|
19
20
|
# along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
|
20
21
|
#
|
21
22
|
|
23
|
+
#
|
24
|
+
# Creates the `ronin_http_requests` table.
|
25
|
+
#
|
22
26
|
class CreateRoninHttpRequestsTable < ActiveRecord::Migration[7.0]
|
23
27
|
|
24
28
|
def change
|
@@ -28,9 +32,7 @@ class CreateRoninHttpRequestsTable < ActiveRecord::Migration[7.0]
|
|
28
32
|
t.string :path, null: false
|
29
33
|
t.text :body
|
30
34
|
|
31
|
-
t.references :response, foreign_key: {
|
32
|
-
to_table: :ronin_http_responses
|
33
|
-
}
|
35
|
+
t.references :response, foreign_key: {to_table: :ronin_http_responses}
|
34
36
|
|
35
37
|
t.datetime :created_at, null: false
|
36
38
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
3
4
|
#
|
@@ -19,6 +20,9 @@
|
|
19
20
|
# along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
|
20
21
|
#
|
21
22
|
|
23
|
+
#
|
24
|
+
# Creates the `ronin_http_query_params` table.
|
25
|
+
#
|
22
26
|
class CreateRoninHttpQueryParamsTable < ActiveRecord::Migration[7.0]
|
23
27
|
|
24
28
|
def change
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
3
4
|
#
|
@@ -19,6 +20,9 @@
|
|
19
20
|
# along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
|
20
21
|
#
|
21
22
|
|
23
|
+
#
|
24
|
+
# Creates the `ronin_http_header_names` table.
|
25
|
+
#
|
22
26
|
class CreateRoninHttpHeaderNamesTable < ActiveRecord::Migration[7.0]
|
23
27
|
|
24
28
|
def change
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
3
4
|
#
|
@@ -19,6 +20,9 @@
|
|
19
20
|
# along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
|
20
21
|
#
|
21
22
|
|
23
|
+
#
|
24
|
+
# Creates the `ronin_http_request_headers` table.
|
25
|
+
#
|
22
26
|
class CreateRoninHttpRequestHeadersTable < ActiveRecord::Migration[7.0]
|
23
27
|
|
24
28
|
def change
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
3
4
|
#
|
@@ -19,6 +20,9 @@
|
|
19
20
|
# along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
|
20
21
|
#
|
21
22
|
|
23
|
+
#
|
24
|
+
# Creates the `ronin_http_response_headers` table.
|
25
|
+
#
|
22
26
|
class CreateRoninHttpResponseHeadersTable < ActiveRecord::Migration[7.0]
|
23
27
|
|
24
28
|
def change
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
3
4
|
#
|
@@ -19,6 +20,9 @@
|
|
19
20
|
# along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
|
20
21
|
#
|
21
22
|
|
23
|
+
#
|
24
|
+
# Creates the `ronin_service_credentials` table.
|
25
|
+
#
|
22
26
|
class CreateRoninServiceCredentialsTable < ActiveRecord::Migration[7.0]
|
23
27
|
|
24
28
|
def change
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
#
|
2
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
3
4
|
#
|
@@ -19,6 +20,9 @@
|
|
19
20
|
# along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
|
20
21
|
#
|
21
22
|
|
23
|
+
#
|
24
|
+
# Creates the `ronin_web_credentials` table.
|
25
|
+
#
|
22
26
|
class CreateRoninWebCredentialsTable < ActiveRecord::Migration[7.0]
|
23
27
|
|
24
28
|
def change
|
data/gemspec.yml
CHANGED
data/lib/ronin/db/address.rb
CHANGED
@@ -58,7 +58,7 @@ module Ronin
|
|
58
58
|
# Tracks when the IP Address was first created
|
59
59
|
#
|
60
60
|
# @return [Time]
|
61
|
-
attribute :created_at, :
|
61
|
+
attribute :created_at, :datetime
|
62
62
|
|
63
63
|
#
|
64
64
|
# Looks up the address.
|
@@ -69,6 +69,8 @@ module Ronin
|
|
69
69
|
# @return [Address, nil]
|
70
70
|
# The found address.
|
71
71
|
#
|
72
|
+
# @api public
|
73
|
+
#
|
72
74
|
def self.lookup(address)
|
73
75
|
find_by(address: address)
|
74
76
|
end
|
@@ -80,7 +82,7 @@ module Ronin
|
|
80
82
|
# The address to parse.
|
81
83
|
#
|
82
84
|
# @return [Address]
|
83
|
-
# The
|
85
|
+
# The imported address.
|
84
86
|
#
|
85
87
|
# @api public
|
86
88
|
#
|
data/lib/ronin/db/advisory.rb
CHANGED
@@ -56,9 +56,9 @@ module Ronin
|
|
56
56
|
attribute :year, :integer
|
57
57
|
validates :year, allow_nil: true,
|
58
58
|
comparison: {
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
greater_than: 1990,
|
60
|
+
less_than_or_equal_to: Date.today.year
|
61
|
+
}
|
62
62
|
|
63
63
|
# @!attribute [rw] identifier
|
64
64
|
# The advisory identifier
|
@@ -84,7 +84,7 @@ module Ronin
|
|
84
84
|
# The ID does not appear to be a valid security ID.
|
85
85
|
#
|
86
86
|
def self.parse(string)
|
87
|
-
if
|
87
|
+
if (match = string.match(/\A([A-Z]+)-(\d{4})[:-]([0-9][0-9-]+)\z/))
|
88
88
|
{
|
89
89
|
id: match[0],
|
90
90
|
prefix: match[1],
|
data/lib/ronin/db/asn.rb
CHANGED
@@ -82,13 +82,13 @@ module Ronin
|
|
82
82
|
# @!attribute [rw] country_code
|
83
83
|
# The country code of the ASN.
|
84
84
|
#
|
85
|
-
# @return [String]
|
85
|
+
# @return [String, nil]
|
86
86
|
attribute :country_code, :string
|
87
87
|
|
88
88
|
# @!attribute [rw] name
|
89
89
|
# The organization the ASN is currently assigned to.
|
90
90
|
#
|
91
|
-
# @return [String]
|
91
|
+
# @return [String, nil]
|
92
92
|
attribute :name, :string
|
93
93
|
|
94
94
|
#
|
@@ -142,7 +142,7 @@ module Ronin
|
|
142
142
|
#
|
143
143
|
# Searches for all ASNs with the matching name.
|
144
144
|
#
|
145
|
-
# @param [String] name
|
145
|
+
# @param [String] name
|
146
146
|
# The name to search for.
|
147
147
|
#
|
148
148
|
# @return [Array<ASN>]
|
@@ -159,11 +159,11 @@ module Ronin
|
|
159
159
|
# @return [ASN, nil]
|
160
160
|
#
|
161
161
|
def self.containing_ip(ip)
|
162
|
-
ip
|
162
|
+
ip = IPAddr.new(ip) unless ip.kind_of?(IPAddr)
|
163
163
|
ip_hton = ip.hton
|
164
164
|
|
165
165
|
range_start_hton = self.arel_table[:range_start_hton]
|
166
|
-
range_end_hton
|
166
|
+
range_end_hton = self.arel_table[:range_end_hton]
|
167
167
|
|
168
168
|
where(range_start_hton.lteq(ip_hton).and(range_end_hton.gteq(ip_hton))).first
|
169
169
|
end
|
data/lib/ronin/db/host_name.rb
CHANGED
data/lib/ronin/db/ip_address.rb
CHANGED
@@ -262,6 +262,7 @@ module Ronin
|
|
262
262
|
begin
|
263
263
|
IPAddr.new(self.address)
|
264
264
|
rescue IPAddr::InvalidAddressError
|
265
|
+
nil
|
265
266
|
end
|
266
267
|
end
|
267
268
|
end
|
@@ -345,7 +346,6 @@ require 'ronin/db/host_name_ip_address'
|
|
345
346
|
require 'ronin/db/host_name'
|
346
347
|
require 'ronin/db/open_port'
|
347
348
|
require 'ronin/db/port'
|
348
|
-
require 'ronin/db/host_name'
|
349
349
|
require 'ronin/db/os_guess'
|
350
350
|
require 'ronin/db/os'
|
351
351
|
require 'ronin/db/asn'
|
data/lib/ronin/db/mac_address.rb
CHANGED
@@ -34,12 +34,12 @@ module Ronin
|
|
34
34
|
# The MAC address.
|
35
35
|
#
|
36
36
|
# @return [String]
|
37
|
-
attribute :address, :string
|
37
|
+
attribute :address, :string
|
38
38
|
validates :address, presence: true,
|
39
39
|
uniqueness: true,
|
40
40
|
length: {maximum: 17},
|
41
41
|
format: {
|
42
|
-
with:
|
42
|
+
with: /\A[0-9a-fA-F]{2}(?::[0-9a-fA-F]{2}){5}\z/,
|
43
43
|
message: 'Must be a valid MAC address'
|
44
44
|
}
|
45
45
|
|
@@ -78,8 +78,8 @@ module Ronin
|
|
78
78
|
# @api public
|
79
79
|
#
|
80
80
|
def to_i
|
81
|
-
self.address.split(':').
|
82
|
-
|
81
|
+
self.address.split(':').reduce(0) do |bits,char|
|
82
|
+
((bits << 8) | char.hex)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
data/lib/ronin/db/migrations.rb
CHANGED
@@ -25,6 +25,9 @@ require 'active_record/migration'
|
|
25
25
|
|
26
26
|
module Ronin
|
27
27
|
module DB
|
28
|
+
#
|
29
|
+
# Handles migrating the database.
|
30
|
+
#
|
28
31
|
module Migrations
|
29
32
|
#
|
30
33
|
# The current migration version of the database.
|
@@ -56,7 +59,7 @@ module Ronin
|
|
56
59
|
context.migrate(target_version)
|
57
60
|
end
|
58
61
|
|
59
|
-
#
|
62
|
+
#
|
60
63
|
# Explicitly migrates up the database to the target version.
|
61
64
|
#
|
62
65
|
# @param [Integer, nil] target_version
|
@@ -68,9 +71,9 @@ module Ronin
|
|
68
71
|
context.up(target_version,&block)
|
69
72
|
end
|
70
73
|
|
71
|
-
#
|
74
|
+
#
|
72
75
|
# Explicitly migrates down the database to the target version.
|
73
|
-
#
|
76
|
+
#
|
74
77
|
# @param [Integer, nil] target_version
|
75
78
|
# The desired target version.
|
76
79
|
#
|
@@ -80,7 +83,7 @@ module Ronin
|
|
80
83
|
context.down(target_version,&block)
|
81
84
|
end
|
82
85
|
|
83
|
-
#
|
86
|
+
#
|
84
87
|
# Rollbacks the last number of migrations.
|
85
88
|
#
|
86
89
|
# @param [Integer] steps
|
@@ -92,7 +95,7 @@ module Ronin
|
|
92
95
|
context.rollback(steps)
|
93
96
|
end
|
94
97
|
|
95
|
-
#
|
98
|
+
#
|
96
99
|
# Applies the next number of migrations.
|
97
100
|
#
|
98
101
|
# @param [Integer] steps
|
@@ -104,8 +107,6 @@ module Ronin
|
|
104
107
|
context.foreward(steps)
|
105
108
|
end
|
106
109
|
|
107
|
-
private
|
108
|
-
|
109
110
|
# Path to the `db/migrate/` directory in `ronin-db-activerecord`.
|
110
111
|
DIR = File.expand_path('../../../db/migrate',__dir__)
|
111
112
|
|
@@ -129,8 +130,10 @@ module Ronin
|
|
129
130
|
#
|
130
131
|
# @return [MigrationContext]
|
131
132
|
#
|
133
|
+
# @api private
|
134
|
+
#
|
132
135
|
def self.context
|
133
|
-
@
|
136
|
+
@context ||= MigrationContext.new
|
134
137
|
end
|
135
138
|
end
|
136
139
|
end
|
@@ -44,11 +44,9 @@ module Ronin
|
|
44
44
|
# @api semipublic
|
45
45
|
#
|
46
46
|
def self.included(base)
|
47
|
-
base.send :include, Model,
|
48
|
-
HasName::InstanceMethods
|
47
|
+
base.send :include, Model, HasName::InstanceMethods
|
49
48
|
|
50
|
-
base.send :extend,
|
51
|
-
HasUniqueName::ClassMethods
|
49
|
+
base.send :extend, HasName::ClassMethods, HasUniqueName::ClassMethods
|
52
50
|
|
53
51
|
base.module_eval do
|
54
52
|
# The name of the model
|
@@ -21,6 +21,9 @@
|
|
21
21
|
module Ronin
|
22
22
|
module DB
|
23
23
|
module Model
|
24
|
+
#
|
25
|
+
# Mixin which adds a `last_scanned_at` attribute to a model.
|
26
|
+
#
|
24
27
|
module LastScannedAt
|
25
28
|
#
|
26
29
|
# @!attribute [rw] last_scanned_at
|
@@ -39,7 +42,7 @@ module Ronin
|
|
39
42
|
#
|
40
43
|
def self.included(model)
|
41
44
|
model.class_eval do
|
42
|
-
attribute :last_scanned_at, :
|
45
|
+
attribute :last_scanned_at, :datetime
|
43
46
|
end
|
44
47
|
end
|
45
48
|
end
|
data/lib/ronin/db/model.rb
CHANGED
data/lib/ronin/db/models.rb
CHANGED
data/lib/ronin/db/open_port.rb
CHANGED
data/lib/ronin/db/os.rb
CHANGED
@@ -51,14 +51,14 @@ module Ronin
|
|
51
51
|
#
|
52
52
|
# @return [String]
|
53
53
|
attribute :version, :string
|
54
|
-
validates :version, presence:
|
54
|
+
validates :version, presence: true,
|
55
55
|
uniqueness: {scope: :name}
|
56
56
|
|
57
57
|
# @!attribute [rw] os_guesses
|
58
58
|
# Any OS guesses for the Operating System.
|
59
59
|
#
|
60
60
|
# @return [Array<OSGuess>]
|
61
|
-
has_many :os_guesses, dependent:
|
61
|
+
has_many :os_guesses, dependent: :destroy,
|
62
62
|
class_name: 'OSGuess'
|
63
63
|
|
64
64
|
# @!attribute [rw] ip_addresses
|
data/lib/ronin/db/os_guess.rb
CHANGED
data/lib/ronin/db/password.rb
CHANGED
@@ -109,13 +109,13 @@ module Ronin
|
|
109
109
|
#
|
110
110
|
# @example
|
111
111
|
# pass = Password.new(plain_text: 'secret')
|
112
|
-
#
|
112
|
+
#
|
113
113
|
# pass.digest(:sha1)
|
114
114
|
# # => "e5e9fa1ba31ecd1ae84f75caaa474f3a663f05f4"
|
115
|
-
#
|
115
|
+
#
|
116
116
|
# pass.digest(:sha1, prepend_salt: "A\x90\x00")
|
117
117
|
# # => "e2817656a48c49f24839ccf9295b389d8f985904"
|
118
|
-
#
|
118
|
+
#
|
119
119
|
# pass.digest(:sha1, append_salt: "BBBB")
|
120
120
|
# # => "aa6ca21e446d425fc044bbb26e950a788444a5b8"
|
121
121
|
#
|
data/lib/ronin/db/software.rb
CHANGED
@@ -49,14 +49,14 @@ module Ronin
|
|
49
49
|
#
|
50
50
|
# @return [String]
|
51
51
|
attribute :version, :string
|
52
|
-
validates :version, presence:
|
52
|
+
validates :version, presence: true,
|
53
53
|
uniqueness: {scope: :name}
|
54
54
|
|
55
55
|
# @!attribute [rw] vendor
|
56
56
|
# The vendor of the software
|
57
57
|
#
|
58
58
|
# @return [SoftwareVendor, nil]
|
59
|
-
belongs_to :vendor, optional:
|
59
|
+
belongs_to :vendor, optional: true,
|
60
60
|
class_name: 'SoftwareVendor'
|
61
61
|
|
62
62
|
# @!attribute [rw] open_ports
|
data/lib/ronin/db/url.rb
CHANGED
@@ -87,7 +87,7 @@ module Ronin
|
|
87
87
|
|
88
88
|
# @!attribute [rw] fragment
|
89
89
|
# The fragment of the URL.
|
90
|
-
#
|
90
|
+
#
|
91
91
|
# @return [String, nil]
|
92
92
|
attribute :fragment, :string
|
93
93
|
|
@@ -95,7 +95,7 @@ module Ronin
|
|
95
95
|
# Defines the created_at timestamp
|
96
96
|
#
|
97
97
|
# @return [Time]
|
98
|
-
attribute :created_at, :
|
98
|
+
attribute :created_at, :datetime
|
99
99
|
|
100
100
|
# @!attribute [rw] query_params
|
101
101
|
# The query params of the URL.
|
@@ -362,33 +362,30 @@ module Ronin
|
|
362
362
|
number: uri.port
|
363
363
|
)
|
364
364
|
end
|
365
|
+
path = normalized_path(uri)
|
366
|
+
query = uri.query
|
367
|
+
fragment = uri.fragment
|
365
368
|
|
366
|
-
|
367
|
-
query
|
368
|
-
fragment = uri.fragment
|
369
|
-
|
370
|
-
query_params = []
|
371
|
-
|
372
|
-
if uri.respond_to?(:query_params)
|
373
|
-
# find or create the URL query params
|
374
|
-
uri.query_params.each do |name,value|
|
375
|
-
query_params << URLQueryParam.new(
|
376
|
-
name: URLQueryParamName.find_or_create_by(name: name),
|
377
|
-
value: value
|
378
|
-
)
|
379
|
-
end
|
380
|
-
end
|
381
|
-
|
382
|
-
# find or create the URL
|
369
|
+
# try to query a pre-existing URI then fallback to creating the URL
|
370
|
+
# with query params.
|
383
371
|
return find_or_create_by(
|
384
372
|
scheme: scheme,
|
385
373
|
host_name: host_name,
|
386
374
|
port: port,
|
387
375
|
path: path,
|
388
376
|
query: query,
|
389
|
-
fragment: fragment
|
390
|
-
|
391
|
-
|
377
|
+
fragment: fragment
|
378
|
+
) do |new_url|
|
379
|
+
if uri.respond_to?(:query_params)
|
380
|
+
# find or create the URL query params
|
381
|
+
uri.query_params.each do |name,value|
|
382
|
+
new_url.query_params << URLQueryParam.new(
|
383
|
+
name: URLQueryParamName.find_or_create_by(name: name),
|
384
|
+
value: value
|
385
|
+
)
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
392
389
|
end
|
393
390
|
|
394
391
|
#
|
@@ -430,9 +427,11 @@ module Ronin
|
|
430
427
|
scheme = if self.scheme
|
431
428
|
self.scheme.name
|
432
429
|
end
|
430
|
+
|
433
431
|
host = if self.host_name
|
434
432
|
self.host_name.name
|
435
433
|
end
|
434
|
+
|
436
435
|
port = if self.port
|
437
436
|
self.port.number
|
438
437
|
end
|
@@ -460,8 +459,6 @@ module Ronin
|
|
460
459
|
self.to_uri.to_s
|
461
460
|
end
|
462
461
|
|
463
|
-
protected
|
464
|
-
|
465
462
|
#
|
466
463
|
# Normalizes the path of a URI.
|
467
464
|
#
|
data/lib/ronin/db/url_scheme.rb
CHANGED
data/lib/ronin/db/user_name.rb
CHANGED