ronin-db-activerecord 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/ChangeLog.md +91 -0
- data/README.md +51 -2
- data/db/migrate/0037_add_created_at_column_to_ronin_ports_table.rb +40 -0
- data/db/migrate/0038_add_created_at_column_to_ronin_services_table.rb +40 -0
- data/db/migrate/0039_create_ronin_cert_names_table.rb +37 -0
- data/db/migrate/0040_create_ronin_cert_issuers_table.rb +52 -0
- data/db/migrate/0041_create_ronin_cert_subjects_table.rb +54 -0
- data/db/migrate/0042_create_ronin_cert_subject_alt_names_table.rb +42 -0
- data/db/migrate/0043_create_ronin_certs_table.rb +61 -0
- data/db/migrate/0044_add_cert_id_column_to_ronin_open_ports_table.rb +35 -0
- data/db/migrate/0045_create_ronin_notes_table.rb +120 -0
- data/db/migrate/0046_create_ronin_web_vulns_table.rb +61 -0
- data/db/migrate/0047_create_ronin_phone_numbers_table.rb +47 -0
- data/db/migrate/0048_create_ronin_street_addresses_table.rb +46 -0
- data/db/migrate/0049_create_ronin_people_table.rb +48 -0
- data/db/migrate/0050_create_ronin_personal_connections_table.rb +48 -0
- data/db/migrate/0051_create_ronin_personal_phone_numbers_table.rb +48 -0
- data/db/migrate/0052_create_ronin_personal_email_addresses_table.rb +45 -0
- data/db/migrate/0053_create_ronin_personal_street_addresses_table.rb +47 -0
- data/db/migrate/0054_add_type_column_to_ronin_organizations_table.rb +33 -0
- data/db/migrate/0055_add_parent_id_column_to_ronin_organizations_table.rb +43 -0
- data/db/migrate/0056_create_ronin_organization_departments_table.rb +59 -0
- data/db/migrate/0057_create_ronin_organization_members_table.rb +62 -0
- data/db/migrate/0058_create_ronin_organization_customers_table.rb +52 -0
- data/db/migrate/0059_create_ronin_organization_phone_numbers_table.rb +47 -0
- data/db/migrate/0060_create_ronin_organization_email_addresses_table.rb +45 -0
- data/db/migrate/0061_create_ronin_organization_street_addresses_table.rb +47 -0
- data/db/migrate/0062_add_source_ip_column_to_http_requests_table.rb +30 -0
- data/db/migrate/0063_create_ronin_dns_queries_table.rb +41 -0
- data/db/migrate/0064_create_ronin_dns_records_table.rb +42 -0
- data/db/migrate/0065_create_ronin_organization_host_names_table.rb +43 -0
- data/db/migrate/0066_create_ronin_organization_ip_addresses_table.rb +43 -0
- data/gemspec.yml +3 -2
- data/lib/ronin/db/address.rb +1 -1
- data/lib/ronin/db/advisory.rb +66 -1
- data/lib/ronin/db/arch.rb +1 -1
- data/lib/ronin/db/asn.rb +15 -1
- data/lib/ronin/db/cert.rb +501 -0
- data/lib/ronin/db/cert_issuer.rb +78 -0
- data/lib/ronin/db/cert_name.rb +107 -0
- data/lib/ronin/db/cert_organization.rb +127 -0
- data/lib/ronin/db/cert_subject.rb +81 -0
- data/lib/ronin/db/cert_subject_alt_name.rb +88 -0
- data/lib/ronin/db/credential.rb +10 -1
- data/lib/ronin/db/dns_query.rb +98 -0
- data/lib/ronin/db/dns_record.rb +76 -0
- data/lib/ronin/db/email_address.rb +139 -1
- data/lib/ronin/db/host_name.rb +45 -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 +13 -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 +46 -1
- data/lib/ronin/db/ip_address_mac_address.rb +1 -1
- data/lib/ronin/db/mac_address.rb +28 -1
- data/lib/ronin/db/migrations.rb +1 -1
- data/lib/ronin/db/model/has_name.rb +18 -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 +44 -2
- data/lib/ronin/db/note.rb +199 -0
- data/lib/ronin/db/open_port.rb +104 -3
- data/lib/ronin/db/organization.rb +237 -3
- data/lib/ronin/db/organization_customer.rb +73 -0
- data/lib/ronin/db/organization_department.rb +97 -0
- data/lib/ronin/db/organization_email_address.rb +66 -0
- data/lib/ronin/db/organization_host_name.rb +65 -0
- data/lib/ronin/db/organization_ip_address.rb +65 -0
- data/lib/ronin/db/organization_member.rb +158 -0
- data/lib/ronin/db/organization_phone_number.rb +66 -0
- data/lib/ronin/db/organization_street_address.rb +66 -0
- data/lib/ronin/db/os.rb +35 -1
- data/lib/ronin/db/os_guess.rb +1 -1
- data/lib/ronin/db/password.rb +84 -1
- data/lib/ronin/db/person.rb +455 -0
- data/lib/ronin/db/personal_connection.rb +110 -0
- data/lib/ronin/db/personal_email_address.rb +66 -0
- data/lib/ronin/db/personal_phone_number.rb +76 -0
- data/lib/ronin/db/personal_street_address.rb +66 -0
- data/lib/ronin/db/phone_number.rb +330 -0
- data/lib/ronin/db/port.rb +110 -1
- data/lib/ronin/db/service.rb +130 -1
- data/lib/ronin/db/service_credential.rb +1 -1
- data/lib/ronin/db/software.rb +37 -1
- data/lib/ronin/db/software_vendor.rb +1 -1
- data/lib/ronin/db/street_address.rb +340 -0
- data/lib/ronin/db/url.rb +37 -1
- data/lib/ronin/db/url_query_param.rb +1 -1
- data/lib/ronin/db/url_query_param_name.rb +9 -1
- data/lib/ronin/db/url_scheme.rb +1 -1
- data/lib/ronin/db/user_name.rb +58 -1
- data/lib/ronin/db/vulnerability.rb +1 -1
- data/lib/ronin/db/web_credential.rb +1 -1
- data/lib/ronin/db/web_vuln.rb +348 -0
- metadata +60 -4
data/lib/ronin/db/host_name.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -101,6 +101,46 @@ module Ronin
|
|
101
101
|
has_many :urls, dependent: :destroy,
|
102
102
|
class_name: 'URL'
|
103
103
|
|
104
|
+
# @!attribute [rw] vulnerabilities
|
105
|
+
# The vulnerabilities which reference the host name.
|
106
|
+
#
|
107
|
+
# @return [Array<Vulnerability>]
|
108
|
+
#
|
109
|
+
# @since 0.2.0
|
110
|
+
has_many :vulnerabilities, dependent: :destroy
|
111
|
+
|
112
|
+
# @!attribute [rw] advisories
|
113
|
+
# The advisories that the host names is vulnerable to.
|
114
|
+
#
|
115
|
+
# @return [Array<Advisory>]
|
116
|
+
#
|
117
|
+
# @since 0.2.0
|
118
|
+
has_many :advisories, through: :vulnerabilities
|
119
|
+
|
120
|
+
# @!attribute [rw] organization_host_names
|
121
|
+
# The association of host names and organizations.
|
122
|
+
#
|
123
|
+
# @return [Array<OrganizationHostName>]
|
124
|
+
#
|
125
|
+
# @since 0.2.0
|
126
|
+
has_many :organization_host_names, dependent: :destroy
|
127
|
+
|
128
|
+
# @!attribute [rw] organizations
|
129
|
+
# The organizations that claim ownership of the host name.
|
130
|
+
#
|
131
|
+
# @return [Array<Organization>]
|
132
|
+
#
|
133
|
+
# @since 0.2.0
|
134
|
+
has_many :organizations, through: :organization_host_names
|
135
|
+
|
136
|
+
# @!attribute [rw] notes
|
137
|
+
# The associated notes.
|
138
|
+
#
|
139
|
+
# @return [Array<Note>]
|
140
|
+
#
|
141
|
+
# @since 0.2.0
|
142
|
+
has_many :notes, dependent: :destroy
|
143
|
+
|
104
144
|
#
|
105
145
|
# Looks up the host name.
|
106
146
|
#
|
@@ -223,3 +263,7 @@ end
|
|
223
263
|
|
224
264
|
require 'ronin/db/host_name_ip_address'
|
225
265
|
require 'ronin/db/ip_address'
|
266
|
+
require 'ronin/db/vulnerability'
|
267
|
+
require 'ronin/db/advisory'
|
268
|
+
require 'ronin/db/organization_host_name'
|
269
|
+
require 'ronin/db/note'
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -21,6 +21,7 @@
|
|
21
21
|
require 'ronin/db/model'
|
22
22
|
|
23
23
|
require 'active_record'
|
24
|
+
require 'resolv'
|
24
25
|
|
25
26
|
module Ronin
|
26
27
|
module DB
|
@@ -115,6 +116,17 @@ module Ronin
|
|
115
116
|
# @return [Time]
|
116
117
|
attribute :created_at, :datetime
|
117
118
|
|
119
|
+
# @!attribute [rw] source_ip
|
120
|
+
# The source IP Address.
|
121
|
+
#
|
122
|
+
# @return [String, nil]
|
123
|
+
attribute :source_ip, :string
|
124
|
+
validates :source_ip, length: { maximum: 39 },
|
125
|
+
format: {
|
126
|
+
with: /#{Resolv::IPv4::Regex}|#{Resolv::IPv6::Regex}/,
|
127
|
+
message: 'Must be a valid IP address'
|
128
|
+
},
|
129
|
+
allow_nil: true
|
118
130
|
end
|
119
131
|
end
|
120
132
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
data/lib/ronin/db/ip_address.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -112,6 +112,47 @@ module Ronin
|
|
112
112
|
has_many :oses, through: :os_guesses,
|
113
113
|
class_name: 'OS'
|
114
114
|
|
115
|
+
# @!attribute [rw] vulnerabilities
|
116
|
+
# The vulnerabilities which reference the IP Address.
|
117
|
+
#
|
118
|
+
# @return [Array<Vulnerability>]
|
119
|
+
#
|
120
|
+
# @since 0.2.0
|
121
|
+
has_many :vulnerabilities, dependent: :destroy
|
122
|
+
|
123
|
+
# @!attribute [rw] advisories
|
124
|
+
# The advisories that the IP Address is vulnerable to.
|
125
|
+
#
|
126
|
+
# @return [Array<Advisory>]
|
127
|
+
#
|
128
|
+
# @since 0.2.0
|
129
|
+
has_many :advisories, through: :vulnerabilities
|
130
|
+
|
131
|
+
# @!attribute [rw] organization_ip_addresses
|
132
|
+
# The association of IP addresses and organizations.
|
133
|
+
#
|
134
|
+
# @return [Array<OrganizationIPAddress>]
|
135
|
+
#
|
136
|
+
# @since 0.2.0
|
137
|
+
has_many :organization_ip_addresses, class_name: 'OrganizationIPAddress',
|
138
|
+
dependent: :destroy
|
139
|
+
|
140
|
+
# @!attribute [rw] organizations
|
141
|
+
# The organizations that claim ownership of the IP address.
|
142
|
+
#
|
143
|
+
# @return [Array<Organization>]
|
144
|
+
#
|
145
|
+
# @since 0.2.0
|
146
|
+
has_many :organizations, through: :organization_ip_addresses
|
147
|
+
|
148
|
+
# @!attribute [rw] notes
|
149
|
+
# The associated notes.
|
150
|
+
#
|
151
|
+
# @return [Array<Note>]
|
152
|
+
#
|
153
|
+
# @since 0.2.0
|
154
|
+
has_many :notes, dependent: :destroy
|
155
|
+
|
115
156
|
#
|
116
157
|
# Searches for all IPv4 addresses.
|
117
158
|
#
|
@@ -349,3 +390,7 @@ require 'ronin/db/port'
|
|
349
390
|
require 'ronin/db/os_guess'
|
350
391
|
require 'ronin/db/os'
|
351
392
|
require 'ronin/db/asn'
|
393
|
+
require 'ronin/db/vulnerability'
|
394
|
+
require 'ronin/db/advisory'
|
395
|
+
require 'ronin/db/organization_ip_address'
|
396
|
+
require 'ronin/db/note'
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
data/lib/ronin/db/mac_address.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -57,6 +57,30 @@ module Ronin
|
|
57
57
|
has_many :ip_addresses, through: :ip_address_mac_addresses,
|
58
58
|
class_name: 'IPAddress'
|
59
59
|
|
60
|
+
# @!attribute [rw] vulnerabilities
|
61
|
+
# The vulnerabilities which reference the MAC Address.
|
62
|
+
#
|
63
|
+
# @return [Array<Vulnerability>]
|
64
|
+
#
|
65
|
+
# @since 0.2.0
|
66
|
+
has_many :vulnerabilities, dependent: :destroy
|
67
|
+
|
68
|
+
# @!attribute [rw] advisories
|
69
|
+
# The advisories that the MAC Address is vulnerable to.
|
70
|
+
#
|
71
|
+
# @return [Array<Advisory>]
|
72
|
+
#
|
73
|
+
# @since 0.2.0
|
74
|
+
has_many :advisories, through: :vulnerabilities
|
75
|
+
|
76
|
+
# @!attribute [rw] notes
|
77
|
+
# The associated notes.
|
78
|
+
#
|
79
|
+
# @return [Array<Note>]
|
80
|
+
#
|
81
|
+
# @since 0.2.0
|
82
|
+
has_many :notes, dependent: :destroy
|
83
|
+
|
60
84
|
#
|
61
85
|
# The IP Address that most recently used the MAC Address.
|
62
86
|
#
|
@@ -89,3 +113,6 @@ end
|
|
89
113
|
|
90
114
|
require 'ronin/db/ip_address_mac_address'
|
91
115
|
require 'ronin/db/ip_address'
|
116
|
+
require 'ronin/db/vulnerability'
|
117
|
+
require 'ronin/db/advisory'
|
118
|
+
require 'ronin/db/note'
|
data/lib/ronin/db/migrations.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -77,6 +77,23 @@ module Ronin
|
|
77
77
|
|
78
78
|
where(name_column.matches("%#{sanitize_sql_like(fragment)}%"))
|
79
79
|
end
|
80
|
+
|
81
|
+
#
|
82
|
+
# Finds all models with the matching name.
|
83
|
+
#
|
84
|
+
# @param [String] name
|
85
|
+
# The name to search for.
|
86
|
+
#
|
87
|
+
# @return [Array<Model>]
|
88
|
+
# The found models.
|
89
|
+
#
|
90
|
+
# @api public
|
91
|
+
#
|
92
|
+
# @since 0.2.0
|
93
|
+
#
|
94
|
+
def with_name(name)
|
95
|
+
where(name: name)
|
96
|
+
end
|
80
97
|
end
|
81
98
|
|
82
99
|
#
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
data/lib/ronin/db/model.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
data/lib/ronin/db/models.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2022-
|
5
|
+
# Copyright (c) 2022-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
|
6
6
|
#
|
7
7
|
# ronin-db-activerecord is free software: you can redistribute it and/or modify
|
8
8
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -29,9 +29,21 @@ require 'ronin/db/ip_address_mac_address'
|
|
29
29
|
require 'ronin/db/mac_address'
|
30
30
|
require 'ronin/db/open_port'
|
31
31
|
require 'ronin/db/organization'
|
32
|
+
require 'ronin/db/organization_street_address'
|
33
|
+
require 'ronin/db/organization_customer'
|
34
|
+
require 'ronin/db/organization_department'
|
35
|
+
require 'ronin/db/organization_phone_number'
|
36
|
+
require 'ronin/db/organization_email_address'
|
37
|
+
require 'ronin/db/organization_host_name'
|
38
|
+
require 'ronin/db/organization_ip_address'
|
32
39
|
require 'ronin/db/os'
|
33
40
|
require 'ronin/db/os_guess'
|
34
41
|
require 'ronin/db/password'
|
42
|
+
require 'ronin/db/person'
|
43
|
+
require 'ronin/db/personal_phone_number'
|
44
|
+
require 'ronin/db/personal_email_address'
|
45
|
+
require 'ronin/db/personal_street_address'
|
46
|
+
require 'ronin/db/personal_connection'
|
35
47
|
require 'ronin/db/port'
|
36
48
|
require 'ronin/db/service'
|
37
49
|
require 'ronin/db/service_credential'
|
@@ -40,6 +52,7 @@ require 'ronin/db/url_query_param_name'
|
|
40
52
|
require 'ronin/db/url_query_param'
|
41
53
|
require 'ronin/db/url_scheme'
|
42
54
|
require 'ronin/db/url'
|
55
|
+
require 'ronin/db/web_vuln'
|
43
56
|
require 'ronin/db/user_name'
|
44
57
|
require 'ronin/db/software_vendor'
|
45
58
|
require 'ronin/db/web_credential'
|
@@ -53,6 +66,14 @@ require 'ronin/db/http_request'
|
|
53
66
|
require 'ronin/db/http_response'
|
54
67
|
require 'ronin/db/advisory'
|
55
68
|
require 'ronin/db/vulnerability'
|
69
|
+
require 'ronin/db/cert_name'
|
70
|
+
require 'ronin/db/cert_issuer'
|
71
|
+
require 'ronin/db/cert_subject'
|
72
|
+
require 'ronin/db/cert_subject_alt_name'
|
73
|
+
require 'ronin/db/cert'
|
74
|
+
require 'ronin/db/dns_query'
|
75
|
+
require 'ronin/db/dns_record'
|
76
|
+
require 'ronin/db/note'
|
56
77
|
|
57
78
|
module Ronin
|
58
79
|
module DB
|
@@ -74,7 +95,19 @@ module Ronin
|
|
74
95
|
OSGuess,
|
75
96
|
OpenPort,
|
76
97
|
Organization,
|
98
|
+
OrganizationStreetAddress,
|
99
|
+
OrganizationCustomer,
|
100
|
+
OrganizationDepartment,
|
101
|
+
OrganizationPhoneNumber,
|
102
|
+
OrganizationEmailAddress,
|
103
|
+
OrganizationHostName,
|
104
|
+
OrganizationIPAddress,
|
77
105
|
Password,
|
106
|
+
Person,
|
107
|
+
PersonalPhoneNumber,
|
108
|
+
PersonalEmailAddress,
|
109
|
+
PersonalStreetAddress,
|
110
|
+
PersonalConnection,
|
78
111
|
Port,
|
79
112
|
Service,
|
80
113
|
ServiceCredential,
|
@@ -83,6 +116,7 @@ module Ronin
|
|
83
116
|
URLQueryParam,
|
84
117
|
URLScheme,
|
85
118
|
URL,
|
119
|
+
WebVuln,
|
86
120
|
UserName,
|
87
121
|
SoftwareVendor,
|
88
122
|
WebCredential,
|
@@ -95,7 +129,15 @@ module Ronin
|
|
95
129
|
HTTPRequest,
|
96
130
|
HTTPResponse,
|
97
131
|
Advisory,
|
98
|
-
Vulnerability
|
132
|
+
Vulnerability,
|
133
|
+
CertName,
|
134
|
+
CertIssuer,
|
135
|
+
CertSubject,
|
136
|
+
CertSubjectAltName,
|
137
|
+
Cert,
|
138
|
+
DNSQuery,
|
139
|
+
DNSRecord,
|
140
|
+
Note
|
99
141
|
]
|
100
142
|
|
101
143
|
#
|
@@ -0,0 +1,199 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2022-2024 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
|
+
# A model for associating notes with other models.
|
29
|
+
#
|
30
|
+
# @since 0.2.0
|
31
|
+
#
|
32
|
+
class Note < ActiveRecord::Base
|
33
|
+
|
34
|
+
include Model
|
35
|
+
|
36
|
+
# @!attribute [rw] id
|
37
|
+
# The primary key of the Note.
|
38
|
+
#
|
39
|
+
# @return [Integer]
|
40
|
+
attribute :id, :integer
|
41
|
+
|
42
|
+
# @!attribute [rw] body
|
43
|
+
# The note text.
|
44
|
+
#
|
45
|
+
# @return [String]
|
46
|
+
attribute :body, :text
|
47
|
+
validates :body, presence: true
|
48
|
+
|
49
|
+
# @!attribute [rw] created_at
|
50
|
+
# Tracks when the note was created.
|
51
|
+
#
|
52
|
+
# @return [Time]
|
53
|
+
attribute :created_at, :datetime
|
54
|
+
|
55
|
+
# @!attribute [rw] updated_at
|
56
|
+
# Tracks when the note was last edited.
|
57
|
+
#
|
58
|
+
# @return [Time]
|
59
|
+
attribute :updated_at, :datetime
|
60
|
+
|
61
|
+
# @!attribute [rw] mac_address
|
62
|
+
# The associated MAC address.
|
63
|
+
#
|
64
|
+
# @return [MACAddress, nil]
|
65
|
+
belongs_to :mac_address, optional: true,
|
66
|
+
class_name: 'MACAddress'
|
67
|
+
|
68
|
+
# @!attribute [rw] ip_address
|
69
|
+
# The associated IP address.
|
70
|
+
#
|
71
|
+
# @return [IPAddress, nil]
|
72
|
+
belongs_to :ip_address, optional: true,
|
73
|
+
class_name: 'IPAddress'
|
74
|
+
|
75
|
+
# @!attribute [rw] host_name
|
76
|
+
# The associated host name.
|
77
|
+
#
|
78
|
+
# @return [HostName, nil]
|
79
|
+
belongs_to :host_name, optional: true
|
80
|
+
|
81
|
+
# @!attribute [rw] port
|
82
|
+
# The associated port.
|
83
|
+
#
|
84
|
+
# @return [Port, nil]
|
85
|
+
belongs_to :port, optional: true
|
86
|
+
|
87
|
+
# @!attribute [rw] service
|
88
|
+
# The associated service.
|
89
|
+
#
|
90
|
+
# @return [Service, nil]
|
91
|
+
belongs_to :service, optional: true
|
92
|
+
|
93
|
+
# @!attribute [rw] open_port
|
94
|
+
# The associated open port.
|
95
|
+
#
|
96
|
+
# @return [OpenPort, nil]
|
97
|
+
belongs_to :open_port, optional: true
|
98
|
+
|
99
|
+
# @!attribute [rw] cert
|
100
|
+
# The associated certificate.
|
101
|
+
#
|
102
|
+
# @return [Cert, nil]
|
103
|
+
belongs_to :cert, optional: true
|
104
|
+
|
105
|
+
# @!attribute [rw] url
|
106
|
+
# The associated URL.
|
107
|
+
#
|
108
|
+
# @return [URL, nil]
|
109
|
+
belongs_to :url, optional: true,
|
110
|
+
class_name: 'URL'
|
111
|
+
|
112
|
+
# @!attribute [rw] user_name
|
113
|
+
# The associated user name.
|
114
|
+
#
|
115
|
+
# @return [UserName, nil]
|
116
|
+
belongs_to :user_name, optional: true
|
117
|
+
|
118
|
+
# @!attribute [rw] email_address
|
119
|
+
# The associated email address.
|
120
|
+
#
|
121
|
+
# @return [EmailAddress, nil]
|
122
|
+
belongs_to :email_address, optional: true
|
123
|
+
|
124
|
+
# @!attribute [rw] password
|
125
|
+
# The associated password.
|
126
|
+
#
|
127
|
+
# @return [Password, nil]
|
128
|
+
belongs_to :password, optional: true
|
129
|
+
|
130
|
+
# @!attribute [rw] credential
|
131
|
+
# The associated credential.
|
132
|
+
#
|
133
|
+
# @return [Credential, nil]
|
134
|
+
belongs_to :credential, optional: true
|
135
|
+
|
136
|
+
# @!attribute [rw] advisory
|
137
|
+
# The associated advisory.
|
138
|
+
#
|
139
|
+
# @return [Advisory, nil]
|
140
|
+
belongs_to :advisory, optional: true
|
141
|
+
|
142
|
+
# @!attribute [rw] phone_number
|
143
|
+
# The associated phone number.
|
144
|
+
#
|
145
|
+
# @return [PhoneNumber, nil]
|
146
|
+
belongs_to :phone_number, optional: true
|
147
|
+
|
148
|
+
# @!attribute [rw] street_address
|
149
|
+
# The associated street address.
|
150
|
+
#
|
151
|
+
# @return [StreetAddress, nil]
|
152
|
+
belongs_to :street_address, optional: true
|
153
|
+
|
154
|
+
# @!attribute [rw] person
|
155
|
+
# The associated person.
|
156
|
+
#
|
157
|
+
# @return [Person, nil]
|
158
|
+
belongs_to :person, optional: true
|
159
|
+
|
160
|
+
# @!attribute [rw] organization
|
161
|
+
# The associated organization.
|
162
|
+
#
|
163
|
+
# @return [Organization, nil]
|
164
|
+
belongs_to :organization, optional: true
|
165
|
+
|
166
|
+
validate :validate_at_least_one_belongs_to_set
|
167
|
+
|
168
|
+
private
|
169
|
+
|
170
|
+
#
|
171
|
+
# Validates that at least one of the `belongs_to` associations is set.
|
172
|
+
#
|
173
|
+
def validate_at_least_one_belongs_to_set
|
174
|
+
unless (mac_address || ip_address || host_name || port || service || open_port || cert || url || user_name || email_address || password || credential || advisory || phone_number || street_address || person || organization)
|
175
|
+
errors.add(:base, 'note must be associated with a MACAddress, IPAddress, HostName, Port, Service, OpenPort, Cert, URL, UserName, EmailAddress, Password, Credential, Advisory, PhoneNumber, StreetAddress, Person, or Organization')
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
require 'ronin/db/mac_address'
|
184
|
+
require 'ronin/db/ip_address'
|
185
|
+
require 'ronin/db/host_name'
|
186
|
+
require 'ronin/db/port'
|
187
|
+
require 'ronin/db/service'
|
188
|
+
require 'ronin/db/open_port'
|
189
|
+
require 'ronin/db/cert'
|
190
|
+
require 'ronin/db/url'
|
191
|
+
require 'ronin/db/user_name'
|
192
|
+
require 'ronin/db/email_address'
|
193
|
+
require 'ronin/db/password'
|
194
|
+
require 'ronin/db/credential'
|
195
|
+
require 'ronin/db/advisory'
|
196
|
+
require 'ronin/db/street_address'
|
197
|
+
require 'ronin/db/phone_number'
|
198
|
+
require 'ronin/db/person'
|
199
|
+
require 'ronin/db/organization'
|