ronin-db-activerecord 0.1.6 → 0.2.0.rc1
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 +4 -4
- data/ChangeLog.md +91 -0
- data/README.md +49 -1
- 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 +1 -1
- 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 +57 -2
@@ -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-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
|
+
# Represents an association between an {Organization} and a {IPAddress}.
|
29
|
+
#
|
30
|
+
# @since 0.2.0
|
31
|
+
#
|
32
|
+
class OrganizationIPAddress < ActiveRecord::Base
|
33
|
+
|
34
|
+
include Model
|
35
|
+
|
36
|
+
# @!attribute [rw] id
|
37
|
+
# Primary key of the organization IP address.
|
38
|
+
#
|
39
|
+
# @return [Integer]
|
40
|
+
attribute :id, :integer
|
41
|
+
|
42
|
+
# @!attribute [rw] organization
|
43
|
+
# The organization that owns the IP address.
|
44
|
+
#
|
45
|
+
# @return [Organization]
|
46
|
+
belongs_to :organization
|
47
|
+
|
48
|
+
# @!attribute [rw] ip_address
|
49
|
+
# The IP address that the organization owns.
|
50
|
+
#
|
51
|
+
# @return [IPAddress]
|
52
|
+
belongs_to :ip_address, class_name: 'IPAddress'
|
53
|
+
|
54
|
+
# @!attribute [r] created_at
|
55
|
+
# Tracks when the organization claimed ownership of the IP address.
|
56
|
+
#
|
57
|
+
# @return [Time]
|
58
|
+
attribute :created_at, :datetime
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
require 'ronin/db/organization'
|
65
|
+
require 'ronin/db/ip_address'
|
@@ -0,0 +1,158 @@
|
|
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
|
+
# Represents a member of an {Organization}.
|
29
|
+
#
|
30
|
+
# @since 0.2.0
|
31
|
+
#
|
32
|
+
class OrganizationMember < ActiveRecord::Base
|
33
|
+
|
34
|
+
include Model
|
35
|
+
|
36
|
+
# NOTE: disable STI so we can use the type column as an enum.
|
37
|
+
self.inheritance_column = nil
|
38
|
+
|
39
|
+
# @!attribute [rw] id
|
40
|
+
# Primary key of the member.
|
41
|
+
#
|
42
|
+
# @return [Integer]
|
43
|
+
attribute :id, :integer
|
44
|
+
|
45
|
+
# @!attribute [rw] active
|
46
|
+
# Specifies whether the member is active or not.
|
47
|
+
#
|
48
|
+
# @return [Boolean]
|
49
|
+
attribute :active, :boolean, default: true
|
50
|
+
|
51
|
+
# @!attribute [rw] type
|
52
|
+
# The type of organization membership.
|
53
|
+
#
|
54
|
+
# @return ["advisor", "volunteer", "employee", "contractor", "intern", "board_member", nil]
|
55
|
+
enum :type, {
|
56
|
+
advisor: 'advisor',
|
57
|
+
volunteer: 'volunteer',
|
58
|
+
employee: 'employee',
|
59
|
+
contractor: 'contractor',
|
60
|
+
intern: 'intern',
|
61
|
+
board_member: 'board member'
|
62
|
+
}
|
63
|
+
|
64
|
+
# @!attribute [rw] role
|
65
|
+
# The member's role within the organization.
|
66
|
+
#
|
67
|
+
# @return [String, nil]
|
68
|
+
attribute :role, :string
|
69
|
+
|
70
|
+
# @!attribute [rw] title
|
71
|
+
# The member's title.
|
72
|
+
#
|
73
|
+
# @return [String, nil]
|
74
|
+
attribute :title, :string
|
75
|
+
|
76
|
+
# @!attribute [rw] rank
|
77
|
+
# The member's rank.
|
78
|
+
#
|
79
|
+
# @return [String, nil]
|
80
|
+
attribute :rank, :string
|
81
|
+
|
82
|
+
# @!attribute [rw] person
|
83
|
+
# The person that belongs to the organization.
|
84
|
+
#
|
85
|
+
# @return [Person]
|
86
|
+
belongs_to :person
|
87
|
+
|
88
|
+
# @!attribute [rw] department
|
89
|
+
# The department that belongs to within the organization.
|
90
|
+
#
|
91
|
+
# @return [Department, nil]
|
92
|
+
belongs_to :department, optional: true
|
93
|
+
|
94
|
+
# @!attribute [rw] organization
|
95
|
+
# The organization that the member belongs to.
|
96
|
+
#
|
97
|
+
# @return [Organization]
|
98
|
+
belongs_to :organization
|
99
|
+
|
100
|
+
# @!attribute [rw] email_address
|
101
|
+
# The member's organization email address.
|
102
|
+
#
|
103
|
+
# @return [EmailAddress, nil]
|
104
|
+
belongs_to :email_address, optional: true
|
105
|
+
|
106
|
+
# @!attribute [rw] phone_number
|
107
|
+
# The member's organization phone number.
|
108
|
+
#
|
109
|
+
# @return [EmailAddress, nil]
|
110
|
+
belongs_to :phone_number, optional: true
|
111
|
+
|
112
|
+
# @!attribute [r] created_at
|
113
|
+
# Tracks when the member was first created.
|
114
|
+
#
|
115
|
+
# @return [Time]
|
116
|
+
attribute :created_at, :datetime
|
117
|
+
|
118
|
+
# @!attribute [r] updated_at
|
119
|
+
# Tracks when the member was last updated.
|
120
|
+
#
|
121
|
+
# @return [Time]
|
122
|
+
attribute :updated_at, :datetime
|
123
|
+
|
124
|
+
#
|
125
|
+
# Queries members that are currently active.
|
126
|
+
#
|
127
|
+
# @return [Array<Member>]
|
128
|
+
#
|
129
|
+
def self.active
|
130
|
+
where(active: true)
|
131
|
+
end
|
132
|
+
|
133
|
+
#
|
134
|
+
# Queries former members.
|
135
|
+
#
|
136
|
+
# @return [Array<Member>]
|
137
|
+
#
|
138
|
+
def self.former
|
139
|
+
where(active: false)
|
140
|
+
end
|
141
|
+
|
142
|
+
#
|
143
|
+
# Converts the organization member to a String.
|
144
|
+
#
|
145
|
+
# @return [String]
|
146
|
+
#
|
147
|
+
def to_s
|
148
|
+
person.to_s
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
require 'ronin/db/organization'
|
156
|
+
require 'ronin/db/person'
|
157
|
+
require 'ronin/db/email_address'
|
158
|
+
require 'ronin/db/phone_number'
|
@@ -0,0 +1,66 @@
|
|
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
|
+
# Represents a {Organization}'s {PhoneNumber phone number}.
|
29
|
+
#
|
30
|
+
# @since 0.2.0
|
31
|
+
#
|
32
|
+
class OrganizationPhoneNumber < ActiveRecord::Base
|
33
|
+
|
34
|
+
include Model
|
35
|
+
|
36
|
+
# @!attribute [rw] id
|
37
|
+
# The primary key of the organization phone number.
|
38
|
+
#
|
39
|
+
# @return [Integer]
|
40
|
+
attribute :id, :integer
|
41
|
+
|
42
|
+
# @!attribute [rw] organization
|
43
|
+
# The organization.
|
44
|
+
#
|
45
|
+
# @return [Organization]
|
46
|
+
belongs_to :organization
|
47
|
+
|
48
|
+
# @!attribute [rw] phone_number
|
49
|
+
# The phone number.
|
50
|
+
#
|
51
|
+
# @return [PhoneNumber]
|
52
|
+
belongs_to :phone_number
|
53
|
+
validates :phone_number, uniqueness: {scope: :organization_id}
|
54
|
+
|
55
|
+
# @!attribute [rw] created_at
|
56
|
+
# Tracks when the organization phone number was first created.
|
57
|
+
#
|
58
|
+
# @return [Time]
|
59
|
+
attribute :created_at, :datetime
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
require 'ronin/db/organization'
|
66
|
+
require 'ronin/db/phone_number'
|
@@ -0,0 +1,66 @@
|
|
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
|
+
# Represents a {Organization}'s {StreetAddress street address}.
|
29
|
+
#
|
30
|
+
# @since 0.2.0
|
31
|
+
#
|
32
|
+
class OrganizationStreetAddress < ActiveRecord::Base
|
33
|
+
|
34
|
+
include Model
|
35
|
+
|
36
|
+
# @!attribute [rw] id
|
37
|
+
# The primary key of the organization street address.
|
38
|
+
#
|
39
|
+
# @return [Integer]
|
40
|
+
attribute :id, :integer
|
41
|
+
|
42
|
+
# @!attribute [rw] organization
|
43
|
+
# The organization.
|
44
|
+
#
|
45
|
+
# @return [Organization]
|
46
|
+
belongs_to :organization
|
47
|
+
|
48
|
+
# @!attribute [rw] street_address
|
49
|
+
# The street address.
|
50
|
+
#
|
51
|
+
# @return [StreetAddress]
|
52
|
+
belongs_to :street_address
|
53
|
+
validates :street_address, uniqueness: {scope: :organization_id}
|
54
|
+
|
55
|
+
# @!attribute [rw] created_at
|
56
|
+
# Tracks when the organization street address was first created.
|
57
|
+
#
|
58
|
+
# @return [Time]
|
59
|
+
attribute :created_at, :datetime
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
require 'ronin/db/organization'
|
66
|
+
require 'ronin/db/street_address'
|
data/lib/ronin/db/os.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
|
@@ -68,6 +68,40 @@ module Ronin
|
|
68
68
|
has_many :ip_addresses, through: :os_guesses,
|
69
69
|
class_name: 'IPAddress'
|
70
70
|
|
71
|
+
#
|
72
|
+
# Queries all OSes with the matching flavor.
|
73
|
+
#
|
74
|
+
# @param [:linux, :bsd] flavor
|
75
|
+
# The flavor to search for.
|
76
|
+
#
|
77
|
+
# @return [Array<OS>]
|
78
|
+
# The matching OSes.
|
79
|
+
#
|
80
|
+
# @api public
|
81
|
+
#
|
82
|
+
# @since 0.2.0
|
83
|
+
#
|
84
|
+
def self.with_flavor(flavor)
|
85
|
+
where(flavor: flavor)
|
86
|
+
end
|
87
|
+
|
88
|
+
#
|
89
|
+
# Queries all OSes with the matching version.
|
90
|
+
#
|
91
|
+
# @param [String] version
|
92
|
+
# The version number to search for.
|
93
|
+
#
|
94
|
+
# @return [Array<OS>]
|
95
|
+
# The matching OSes.
|
96
|
+
#
|
97
|
+
# @api public
|
98
|
+
#
|
99
|
+
# @since 0.2.0
|
100
|
+
#
|
101
|
+
def self.with_version(version)
|
102
|
+
where(version: version)
|
103
|
+
end
|
104
|
+
|
71
105
|
#
|
72
106
|
# The Linux OS
|
73
107
|
#
|
data/lib/ronin/db/os_guess.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/password.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
|
@@ -59,6 +59,88 @@ module Ronin
|
|
59
59
|
# @return [Array<UserName>]
|
60
60
|
has_many :user_names, through: :credentials
|
61
61
|
|
62
|
+
# @!attribute [rw] email_addresses
|
63
|
+
# The email addresses which use the password.
|
64
|
+
#
|
65
|
+
# @return [Array<EmailAddress>]
|
66
|
+
#
|
67
|
+
# @since 0.2.0
|
68
|
+
has_many :email_addresses, through: :credentials
|
69
|
+
|
70
|
+
# @!attribute [rw] service_credentials
|
71
|
+
# The service credentials that use the password.
|
72
|
+
#
|
73
|
+
# @return [Array<ServiceCredential>]
|
74
|
+
#
|
75
|
+
# @since 0.2.0
|
76
|
+
has_many :service_credentials, through: :credentials
|
77
|
+
|
78
|
+
# @!attribute [rw] web_credentials
|
79
|
+
# Any web credentials that use the password.
|
80
|
+
#
|
81
|
+
# @return [Array<WebCredential>]
|
82
|
+
#
|
83
|
+
# @since 0.2.0
|
84
|
+
has_many :web_credentials, through: :credentials
|
85
|
+
|
86
|
+
# @!attribute [rw] notes
|
87
|
+
# The associated notes.
|
88
|
+
#
|
89
|
+
# @return [Array<Note>]
|
90
|
+
#
|
91
|
+
# @since 0.2.0
|
92
|
+
has_many :notes, dependent: :destroy
|
93
|
+
|
94
|
+
#
|
95
|
+
# Searches for all passwords used by a specific user.
|
96
|
+
#
|
97
|
+
# @param [String] name
|
98
|
+
# The name of the user.
|
99
|
+
#
|
100
|
+
# @return [Array<Password>]
|
101
|
+
# The passwords for the user.
|
102
|
+
#
|
103
|
+
# @api public
|
104
|
+
#
|
105
|
+
# @since 0.2.0
|
106
|
+
#
|
107
|
+
def self.for_user(name)
|
108
|
+
joins(credentials: :user_name).where(credentials: {ronin_user_names: {name: name}})
|
109
|
+
end
|
110
|
+
|
111
|
+
#
|
112
|
+
# Searches all passwords that are associated with an email address.
|
113
|
+
#
|
114
|
+
# @param [String] email
|
115
|
+
# The email address to search for.
|
116
|
+
#
|
117
|
+
# @return [Array<Password>]
|
118
|
+
# The passwords associated with the email address.
|
119
|
+
#
|
120
|
+
# @raise [ArgumentError]
|
121
|
+
# The given email address was not a valid email address.
|
122
|
+
#
|
123
|
+
# @api public
|
124
|
+
#
|
125
|
+
# @since 0.2.0
|
126
|
+
#
|
127
|
+
def self.with_email_address(email)
|
128
|
+
unless email.include?('@')
|
129
|
+
raise(ArgumentError,"invalid email address #{email.inspect}")
|
130
|
+
end
|
131
|
+
|
132
|
+
user, domain = email.split('@',2)
|
133
|
+
|
134
|
+
return joins(credentials: {email_address: [:user_name, :host_name]}).where(
|
135
|
+
credentials: {
|
136
|
+
email_address: {
|
137
|
+
ronin_user_names: {name: user},
|
138
|
+
ronin_host_names: {name: domain}
|
139
|
+
}
|
140
|
+
}
|
141
|
+
)
|
142
|
+
end
|
143
|
+
|
62
144
|
#
|
63
145
|
# Looks up the password.
|
64
146
|
#
|
@@ -165,3 +247,4 @@ module Ronin
|
|
165
247
|
end
|
166
248
|
|
167
249
|
require 'ronin/db/credential'
|
250
|
+
require 'ronin/db/note'
|