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.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/ChangeLog.md +91 -0
  4. data/README.md +51 -2
  5. data/db/migrate/0037_add_created_at_column_to_ronin_ports_table.rb +40 -0
  6. data/db/migrate/0038_add_created_at_column_to_ronin_services_table.rb +40 -0
  7. data/db/migrate/0039_create_ronin_cert_names_table.rb +37 -0
  8. data/db/migrate/0040_create_ronin_cert_issuers_table.rb +52 -0
  9. data/db/migrate/0041_create_ronin_cert_subjects_table.rb +54 -0
  10. data/db/migrate/0042_create_ronin_cert_subject_alt_names_table.rb +42 -0
  11. data/db/migrate/0043_create_ronin_certs_table.rb +61 -0
  12. data/db/migrate/0044_add_cert_id_column_to_ronin_open_ports_table.rb +35 -0
  13. data/db/migrate/0045_create_ronin_notes_table.rb +120 -0
  14. data/db/migrate/0046_create_ronin_web_vulns_table.rb +61 -0
  15. data/db/migrate/0047_create_ronin_phone_numbers_table.rb +47 -0
  16. data/db/migrate/0048_create_ronin_street_addresses_table.rb +46 -0
  17. data/db/migrate/0049_create_ronin_people_table.rb +48 -0
  18. data/db/migrate/0050_create_ronin_personal_connections_table.rb +48 -0
  19. data/db/migrate/0051_create_ronin_personal_phone_numbers_table.rb +48 -0
  20. data/db/migrate/0052_create_ronin_personal_email_addresses_table.rb +45 -0
  21. data/db/migrate/0053_create_ronin_personal_street_addresses_table.rb +47 -0
  22. data/db/migrate/0054_add_type_column_to_ronin_organizations_table.rb +33 -0
  23. data/db/migrate/0055_add_parent_id_column_to_ronin_organizations_table.rb +43 -0
  24. data/db/migrate/0056_create_ronin_organization_departments_table.rb +59 -0
  25. data/db/migrate/0057_create_ronin_organization_members_table.rb +62 -0
  26. data/db/migrate/0058_create_ronin_organization_customers_table.rb +52 -0
  27. data/db/migrate/0059_create_ronin_organization_phone_numbers_table.rb +47 -0
  28. data/db/migrate/0060_create_ronin_organization_email_addresses_table.rb +45 -0
  29. data/db/migrate/0061_create_ronin_organization_street_addresses_table.rb +47 -0
  30. data/db/migrate/0062_add_source_ip_column_to_http_requests_table.rb +30 -0
  31. data/db/migrate/0063_create_ronin_dns_queries_table.rb +41 -0
  32. data/db/migrate/0064_create_ronin_dns_records_table.rb +42 -0
  33. data/db/migrate/0065_create_ronin_organization_host_names_table.rb +43 -0
  34. data/db/migrate/0066_create_ronin_organization_ip_addresses_table.rb +43 -0
  35. data/gemspec.yml +3 -2
  36. data/lib/ronin/db/address.rb +1 -1
  37. data/lib/ronin/db/advisory.rb +66 -1
  38. data/lib/ronin/db/arch.rb +1 -1
  39. data/lib/ronin/db/asn.rb +15 -1
  40. data/lib/ronin/db/cert.rb +501 -0
  41. data/lib/ronin/db/cert_issuer.rb +78 -0
  42. data/lib/ronin/db/cert_name.rb +107 -0
  43. data/lib/ronin/db/cert_organization.rb +127 -0
  44. data/lib/ronin/db/cert_subject.rb +81 -0
  45. data/lib/ronin/db/cert_subject_alt_name.rb +88 -0
  46. data/lib/ronin/db/credential.rb +10 -1
  47. data/lib/ronin/db/dns_query.rb +98 -0
  48. data/lib/ronin/db/dns_record.rb +76 -0
  49. data/lib/ronin/db/email_address.rb +139 -1
  50. data/lib/ronin/db/host_name.rb +45 -1
  51. data/lib/ronin/db/host_name_ip_address.rb +1 -1
  52. data/lib/ronin/db/http_header_name.rb +1 -1
  53. data/lib/ronin/db/http_query_param.rb +1 -1
  54. data/lib/ronin/db/http_query_param_name.rb +1 -1
  55. data/lib/ronin/db/http_request.rb +13 -1
  56. data/lib/ronin/db/http_request_header.rb +1 -1
  57. data/lib/ronin/db/http_response.rb +1 -1
  58. data/lib/ronin/db/http_response_header.rb +1 -1
  59. data/lib/ronin/db/ip_address.rb +46 -1
  60. data/lib/ronin/db/ip_address_mac_address.rb +1 -1
  61. data/lib/ronin/db/mac_address.rb +28 -1
  62. data/lib/ronin/db/migrations.rb +1 -1
  63. data/lib/ronin/db/model/has_name.rb +18 -1
  64. data/lib/ronin/db/model/has_unique_name.rb +1 -1
  65. data/lib/ronin/db/model/importable.rb +1 -1
  66. data/lib/ronin/db/model/last_scanned_at.rb +1 -1
  67. data/lib/ronin/db/model.rb +1 -1
  68. data/lib/ronin/db/models.rb +44 -2
  69. data/lib/ronin/db/note.rb +199 -0
  70. data/lib/ronin/db/open_port.rb +104 -3
  71. data/lib/ronin/db/organization.rb +237 -3
  72. data/lib/ronin/db/organization_customer.rb +73 -0
  73. data/lib/ronin/db/organization_department.rb +97 -0
  74. data/lib/ronin/db/organization_email_address.rb +66 -0
  75. data/lib/ronin/db/organization_host_name.rb +65 -0
  76. data/lib/ronin/db/organization_ip_address.rb +65 -0
  77. data/lib/ronin/db/organization_member.rb +158 -0
  78. data/lib/ronin/db/organization_phone_number.rb +66 -0
  79. data/lib/ronin/db/organization_street_address.rb +66 -0
  80. data/lib/ronin/db/os.rb +35 -1
  81. data/lib/ronin/db/os_guess.rb +1 -1
  82. data/lib/ronin/db/password.rb +84 -1
  83. data/lib/ronin/db/person.rb +455 -0
  84. data/lib/ronin/db/personal_connection.rb +110 -0
  85. data/lib/ronin/db/personal_email_address.rb +66 -0
  86. data/lib/ronin/db/personal_phone_number.rb +76 -0
  87. data/lib/ronin/db/personal_street_address.rb +66 -0
  88. data/lib/ronin/db/phone_number.rb +330 -0
  89. data/lib/ronin/db/port.rb +110 -1
  90. data/lib/ronin/db/service.rb +130 -1
  91. data/lib/ronin/db/service_credential.rb +1 -1
  92. data/lib/ronin/db/software.rb +37 -1
  93. data/lib/ronin/db/software_vendor.rb +1 -1
  94. data/lib/ronin/db/street_address.rb +340 -0
  95. data/lib/ronin/db/url.rb +37 -1
  96. data/lib/ronin/db/url_query_param.rb +1 -1
  97. data/lib/ronin/db/url_query_param_name.rb +9 -1
  98. data/lib/ronin/db/url_scheme.rb +1 -1
  99. data/lib/ronin/db/user_name.rb +58 -1
  100. data/lib/ronin/db/vulnerability.rb +1 -1
  101. data/lib/ronin/db/web_credential.rb +1 -1
  102. data/lib/ronin/db/web_vuln.rb +348 -0
  103. metadata +60 -4
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_organization_members` table.
25
+ #
26
+ class CreateRoninOrganizationMembersTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_organization_members, if_not_exists: true do |t|
30
+ t.boolean :active, default: true
31
+ t.string :type, null: true, length: 12
32
+ t.string :role
33
+ t.string :title
34
+ t.string :rank
35
+
36
+ t.references :person, null: false,
37
+ foreign_key: {
38
+ to_table: :ronin_people
39
+ }
40
+ t.references :department, null: true,
41
+ foreign_key: {
42
+ to_table: :ronin_organization_departments
43
+ }
44
+ t.references :organization, null: false,
45
+ foreign_key: {
46
+ to_table: :ronin_organizations
47
+ }
48
+ t.references :email_address, null: true,
49
+ foreign_key: {
50
+ to_table: :ronin_email_addresses
51
+ }
52
+ t.references :phone_number, null: true,
53
+ foreign_key: {
54
+ to_table: :ronin_phone_numbers
55
+ }
56
+ t.timestamps
57
+
58
+ t.index :type
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_organization_customers` table.
25
+ #
26
+ class CreateRoninOrganizationCustomersTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_organization_customers, if_not_exists: true do |t|
30
+ t.references :vendor, null: false,
31
+ foreign_key: {
32
+ to_table: :ronin_organizations
33
+ }
34
+
35
+ t.references :customer_organization, null: false,
36
+ foreign_key: {
37
+ to_table: :ronin_organizations
38
+ }
39
+
40
+ t.references :customer, null: false,
41
+ foreign_key: {
42
+ to_table: :ronin_people
43
+ }
44
+
45
+ t.datetime :created_at, null: false
46
+
47
+ t.index [:vendor_id, :customer_organization_id, :customer_id], unique: true,
48
+ name: :index_ronin_organization_customers_table_unique
49
+ end
50
+ end
51
+
52
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_organization_phone_numbers` table.
25
+ #
26
+ class CreateRoninOrganizationPhoneNumbersTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_organization_phone_numbers, if_not_exists: true do |t|
30
+ t.references :organization, null: false,
31
+ foreign_key: {
32
+ to_table: :ronin_organizations
33
+ }
34
+
35
+ t.references :phone_number, null: false,
36
+ foreign_key: {
37
+ to_table: :ronin_phone_numbers
38
+ }
39
+
40
+ t.datetime :created_at, null: false
41
+
42
+ t.index [:organization_id, :phone_number_id], unique: true,
43
+ name: :index_ronin_organization_phone_numbers_table_unique
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_organization_email_addresses` table.
25
+ #
26
+ class CreateRoninOrganizationEmailAddressesTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_organization_email_addresses, if_not_exists: true do |t|
30
+ t.references :organization, null: false,
31
+ foreign_key: {
32
+ to_table: :ronin_organizations
33
+ }
34
+ t.references :email_address, null: true,
35
+ foreign_key: {
36
+ to_table: :ronin_email_addresses
37
+ }
38
+ t.datetime :created_at, null: false
39
+
40
+ t.index [:organization_id, :email_address_id], unique: true,
41
+ name: :index_ronin_organization_email_addresses_table_unique
42
+ end
43
+ end
44
+
45
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_organization_street_addresses` table.
25
+ #
26
+ class CreateRoninOrganizationStreetAddressesTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_organization_street_addresses, if_not_exists: true do |t|
30
+ t.references :organization, null: false,
31
+ foreign_key: {
32
+ to_table: :ronin_organizations
33
+ }
34
+
35
+ t.references :street_address, null: false,
36
+ foreign_key: {
37
+ to_table: :ronin_street_addresses
38
+ }
39
+
40
+ t.datetime :created_at, null: false
41
+
42
+ t.index [:organization_id, :street_address_id], unique: true,
43
+ name: :index_ronin_organization_street_addresses_table_unique
44
+ end
45
+ end
46
+
47
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Adds the `source_ip` column to the `ronin_http_requests` table.
25
+ #
26
+ class AddSourceIpColumnToHttpRequestsTable < ActiveRecord::Migration[7.0]
27
+ def change
28
+ add_column :ronin_http_requests, :source_ip, :string, length: 39, null: true
29
+ end
30
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_dns_queries` table.
25
+ #
26
+ class CreateRoninDnsQueriesTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_dns_queries, if_not_exists: true do |t|
30
+ t.string :type, length: 5, null: false
31
+ t.string :label, null: false
32
+ t.string :source_addr, length: 39, null: false
33
+
34
+ t.datetime :created_at, null: false
35
+
36
+ t.index :type
37
+ t.index :label
38
+ t.index :source_addr
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_dns_records` table.
25
+ #
26
+ class CreateRoninDnsRecordsTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_dns_records, if_not_exists: true do |t|
30
+ t.integer :ttl, null: false
31
+ t.string :value, null: false, length: 255
32
+
33
+ t.datetime :created_at, null: false
34
+ t.references :dns_query, null: false,
35
+ foreign_key: {
36
+ to_table: :ronin_dns_queries
37
+ }
38
+
39
+ t.index :value
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_organization_host_names` table.
25
+ #
26
+ class CreateRoninOrganizationHostNamesTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_organization_host_names, if_not_exists: true do |t|
30
+ t.references :organization, null: false,
31
+ foreign_key: {
32
+ to_table: :ronin_organizations
33
+ }
34
+
35
+ t.references :host_name, null: false,
36
+ foreign_key: {
37
+ to_table: :ronin_host_names
38
+ }
39
+
40
+ t.datetime :created_at, null: false
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # This file is part of ronin-db-activerecord.
8
+ #
9
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published
11
+ # by the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
21
+ #
22
+
23
+ #
24
+ # Creates the `ronin_organization_ip_addresses` table.
25
+ #
26
+ class CreateRoninOrganizationIpAddressesTable < ActiveRecord::Migration[7.0]
27
+
28
+ def change
29
+ create_table :ronin_organization_ip_addresses, if_not_exists: true do |t|
30
+ t.references :organization, null: false,
31
+ foreign_key: {
32
+ to_table: :ronin_organizations
33
+ }
34
+
35
+ t.references :ip_address, null: false,
36
+ foreign_key: {
37
+ to_table: :ronin_ip_addresses
38
+ }
39
+
40
+ t.datetime :created_at, null: false
41
+ end
42
+ end
43
+ end
data/gemspec.yml CHANGED
@@ -1,9 +1,10 @@
1
1
  name: ronin-db-activerecord
2
- version: 0.1.6
2
+ version: 0.2.0
3
3
  summary: ActiveRecord backend for the Ronin Database
4
4
  description:
5
5
  ronin-db-activerecord contains ActiveRecord models and migrations for the
6
- Ronin Database.
6
+ Ronin Database. Provides database models storing and querying network data,
7
+ advisory data, credentials, and OSINT data.
7
8
 
8
9
  license: LGPL-3.0
9
10
  authors: Postmodern
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
4
  #
5
- # Copyright (c) 2022-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
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-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
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
@@ -67,6 +67,63 @@ module Ronin
67
67
  attribute :identifier, :string
68
68
  validates :identifier, presence: true
69
69
 
70
+ # @!attribute [rw] vulnerabilities
71
+ # The vulnerabilities which reference the advisory.
72
+ #
73
+ # @return [Array<Vulnerability>]
74
+ #
75
+ # @since 0.2.0
76
+ has_many :vulnerabilities, dependent: :destroy
77
+
78
+ # @!attribute [rw] mac_addresses
79
+ # The MAC Addresses that are vulnerable to this advisory.
80
+ #
81
+ # @return [Array<MACAddress>]
82
+ #
83
+ # @since 0.2.0
84
+ has_many :mac_addresses, through: :vulnerabilities
85
+
86
+ # @!attribute [rw] ip_addresses
87
+ # The IP Addresses that are vulnerable to this advisory.
88
+ #
89
+ # @return [Array<IPAddress>]
90
+ #
91
+ # @since 0.2.0
92
+ has_many :ip_addresses, through: :vulnerabilities
93
+
94
+ # @!attribute [rw] open_ports
95
+ # The open ports that are vulnerable to this advisory.
96
+ #
97
+ # @return [Array<OpenPort>]
98
+ #
99
+ # @since 0.2.0
100
+ has_many :open_ports, through: :vulnerabilities
101
+
102
+ # @!attribute [rw] host_names
103
+ # The host names that are vulnerable to this advisory.
104
+ #
105
+ # @return [Array<HostName>]
106
+ #
107
+ # @since 0.2.0
108
+ has_many :host_names, through: :vulnerabilities
109
+
110
+ # @!attribute [rw] urls
111
+ # The URLs that are vulnerable to this advisory.
112
+ #
113
+ # @return [Array<URL>]
114
+ #
115
+ # @since 0.2.0
116
+ has_many :urls, through: :vulnerabilities,
117
+ class_name: 'URL'
118
+
119
+ # @!attribute [rw] notes
120
+ # The associated notes.
121
+ #
122
+ # @return [Array<Note>]
123
+ #
124
+ # @since 0.2.0
125
+ has_many :notes, dependent: :destroy
126
+
70
127
  #
71
128
  # @api private
72
129
  #
@@ -167,3 +224,11 @@ module Ronin
167
224
  end
168
225
  end
169
226
  end
227
+
228
+ require 'ronin/db/vulnerability'
229
+ require 'ronin/db/mac_address'
230
+ require 'ronin/db/ip_address'
231
+ require 'ronin/db/open_port'
232
+ require 'ronin/db/host_name'
233
+ require 'ronin/db/url'
234
+ require 'ronin/db/note'
data/lib/ronin/db/arch.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-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
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/asn.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-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
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
@@ -19,6 +19,7 @@
19
19
  #
20
20
 
21
21
  require 'ronin/db/model'
22
+ require 'ronin/db/model/has_name'
22
23
 
23
24
  module Ronin
24
25
  module DB
@@ -28,6 +29,7 @@ module Ronin
28
29
  class ASN < ActiveRecord::Base
29
30
 
30
31
  include Model
32
+ extend Model::HasName::ClassMethods
31
33
 
32
34
  # @!attribute [rw] id
33
35
  # The primary key of the ASN range.
@@ -195,6 +197,18 @@ module Ronin
195
197
  IPAddress.between(range_start,range_end)
196
198
  end
197
199
 
200
+ #
201
+ # Converts the ASN to a String.
202
+ #
203
+ # @return [String]
204
+ # The `AS<number>` String.
205
+ #
206
+ # @since 0.2.0
207
+ #
208
+ def to_s
209
+ "AS#{self.number}"
210
+ end
211
+
198
212
  private
199
213
 
200
214
  #