ronin-db-activerecord 0.1.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.github/workflows/ruby.yml +31 -0
  4. data/.gitignore +13 -0
  5. data/.rspec +1 -0
  6. data/.ruby-version +1 -0
  7. data/.yardopts +1 -0
  8. data/COPYING.txt +165 -0
  9. data/ChangeLog.md +39 -0
  10. data/Gemfile +27 -0
  11. data/README.md +143 -0
  12. data/Rakefile +72 -0
  13. data/db/migrate/0001_create_ronin_ip_address_mac_addresses_table.rb +43 -0
  14. data/db/migrate/0002_create_ronin_vulnerabilities_table.rb +61 -0
  15. data/db/migrate/0003_create_ronin_url_schemes_table.rb +32 -0
  16. data/db/migrate/0004_create_ronin_url_query_param_names_table.rb +32 -0
  17. data/db/migrate/0005_create_ronin_user_names_table.rb +33 -0
  18. data/db/migrate/0006_create_ronin_software_vendors_table.rb +32 -0
  19. data/db/migrate/0007_create_ronin_advisories_table.rb +42 -0
  20. data/db/migrate/0008_create_ronin_host_name_ip_addresses_table.rb +43 -0
  21. data/db/migrate/0009_create_ronin_host_names_table.rb +34 -0
  22. data/db/migrate/0010_create_ronin_arches_table.rb +37 -0
  23. data/db/migrate/0011_create_ronin_email_addresses_table.rb +44 -0
  24. data/db/migrate/0012_create_ronin_oses_table.rb +36 -0
  25. data/db/migrate/0013_create_ronin_organizations_table.rb +31 -0
  26. data/db/migrate/0014_create_ronin_ip_addresses_table.rb +35 -0
  27. data/db/migrate/0015_create_ronin_os_guesses_table.rb +40 -0
  28. data/db/migrate/0016_create_ronin_url_query_params_table.rb +42 -0
  29. data/db/migrate/0017_create_ronin_passwords_table.rb +32 -0
  30. data/db/migrate/0018_create_ronin_open_ports_table.rb +46 -0
  31. data/db/migrate/0019_create_ronin_urls_table.rb +50 -0
  32. data/db/migrate/0020_create_ronin_softwares_table.rb +39 -0
  33. data/db/migrate/0021_create_ronin_mac_addresses_table.rb +33 -0
  34. data/db/migrate/0022_create_ronin_countries_table.rb +34 -0
  35. data/db/migrate/0023_create_ronin_services_table.rb +32 -0
  36. data/db/migrate/0024_create_ronin_credentials_table.rb +44 -0
  37. data/db/migrate/0025_create_ronin_ports_table.rb +33 -0
  38. data/db/migrate/0026_create_ronin_asns_table.rb +44 -0
  39. data/db/migrate/0027_create_ronin_http_query_param_names_table.rb +32 -0
  40. data/db/migrate/0028_create_ronin_http_query_params_table.rb +42 -0
  41. data/db/migrate/0029_create_ronin_http_header_names_table.rb +31 -0
  42. data/db/migrate/0030_create_ronin_http_request_headers_table.rb +41 -0
  43. data/db/migrate/0031_create_ronin_http_response_headers_table.rb +41 -0
  44. data/db/migrate/0032_create_ronin_http_requests_table.rb +41 -0
  45. data/db/migrate/0033_create_ronin_http_responses_table.rb +36 -0
  46. data/db/migrate/0034_create_ronin_service_credentials_table.rb +41 -0
  47. data/db/migrate/0035_create_ronin_web_credentials_table.rb +41 -0
  48. data/gemspec.yml +28 -0
  49. data/lib/ronin/db/address.rb +105 -0
  50. data/lib/ronin/db/advisory.rb +169 -0
  51. data/lib/ronin/db/arch.rb +160 -0
  52. data/lib/ronin/db/asn.rb +212 -0
  53. data/lib/ronin/db/credential.rb +248 -0
  54. data/lib/ronin/db/email_address.rb +225 -0
  55. data/lib/ronin/db/host_name.rb +224 -0
  56. data/lib/ronin/db/host_name_ip_address.rb +65 -0
  57. data/lib/ronin/db/http_header_name.rb +75 -0
  58. data/lib/ronin/db/http_query_param.rb +79 -0
  59. data/lib/ronin/db/http_query_param_name.rb +76 -0
  60. data/lib/ronin/db/http_request.rb +120 -0
  61. data/lib/ronin/db/http_request_header.rb +78 -0
  62. data/lib/ronin/db/http_response.rb +91 -0
  63. data/lib/ronin/db/http_response_header.rb +78 -0
  64. data/lib/ronin/db/ip_address.rb +351 -0
  65. data/lib/ronin/db/ip_address_mac_address.rb +62 -0
  66. data/lib/ronin/db/mac_address.rb +91 -0
  67. data/lib/ronin/db/migrations.rb +137 -0
  68. data/lib/ronin/db/model/has_name.rb +102 -0
  69. data/lib/ronin/db/model/has_unique_name.rb +82 -0
  70. data/lib/ronin/db/model/importable.rb +85 -0
  71. data/lib/ronin/db/model/last_scanned_at.rb +48 -0
  72. data/lib/ronin/db/model.rb +37 -0
  73. data/lib/ronin/db/models.rb +108 -0
  74. data/lib/ronin/db/open_port.rb +148 -0
  75. data/lib/ronin/db/organization.rb +50 -0
  76. data/lib/ronin/db/os.rb +183 -0
  77. data/lib/ronin/db/os_guess.rb +67 -0
  78. data/lib/ronin/db/password.rb +167 -0
  79. data/lib/ronin/db/port.rb +123 -0
  80. data/lib/ronin/db/root.rb +28 -0
  81. data/lib/ronin/db/schema_migration.rb +34 -0
  82. data/lib/ronin/db/service.rb +48 -0
  83. data/lib/ronin/db/service_credential.rb +66 -0
  84. data/lib/ronin/db/software.rb +85 -0
  85. data/lib/ronin/db/software_vendor.rb +42 -0
  86. data/lib/ronin/db/url.rb +497 -0
  87. data/lib/ronin/db/url_query_param.rb +79 -0
  88. data/lib/ronin/db/url_query_param_name.rb +76 -0
  89. data/lib/ronin/db/url_scheme.rb +80 -0
  90. data/lib/ronin/db/user_name.rb +96 -0
  91. data/lib/ronin/db/vulnerability.rb +81 -0
  92. data/lib/ronin/db/web_credential.rb +69 -0
  93. data/ronin-db-activerecord.gemspec +61 -0
  94. data/spec/advisory_spec.rb +277 -0
  95. data/spec/arch_spec.rb +228 -0
  96. data/spec/asn_spec.rb +504 -0
  97. data/spec/credential_spec.rb +362 -0
  98. data/spec/email_address_spec.rb +372 -0
  99. data/spec/host_name_ip_address_spec.rb +8 -0
  100. data/spec/host_name_spec.rb +207 -0
  101. data/spec/http_header_name_spec.rb +25 -0
  102. data/spec/http_query_param_name_spec.rb +25 -0
  103. data/spec/http_query_param_spec.rb +104 -0
  104. data/spec/http_request_header_spec.rb +72 -0
  105. data/spec/http_request_spec.rb +168 -0
  106. data/spec/http_response_header_spec.rb +74 -0
  107. data/spec/http_response_spec.rb +103 -0
  108. data/spec/ip_address_mac_addresses_spec.rb +8 -0
  109. data/spec/ip_address_spec.rb +386 -0
  110. data/spec/mac_address_spec.rb +67 -0
  111. data/spec/migrations_spec.rb +122 -0
  112. data/spec/model/has_name_spec.rb +65 -0
  113. data/spec/model/has_unique_name_spec.rb +61 -0
  114. data/spec/model/importable_spec.rb +105 -0
  115. data/spec/models_spec.rb +60 -0
  116. data/spec/open_port_spec.rb +87 -0
  117. data/spec/organization_spec.rb +10 -0
  118. data/spec/os_guess_spec.rb +43 -0
  119. data/spec/os_spec.rb +114 -0
  120. data/spec/password_spec.rb +81 -0
  121. data/spec/port_spec.rb +102 -0
  122. data/spec/schema_migration_spec.rb +8 -0
  123. data/spec/service_credential_spec.rb +43 -0
  124. data/spec/service_spec.rb +39 -0
  125. data/spec/software_spec.rb +76 -0
  126. data/spec/software_vendor_spec.rb +33 -0
  127. data/spec/spec_helper.rb +13 -0
  128. data/spec/url_query_param_name_spec.rb +25 -0
  129. data/spec/url_query_param_spec.rb +110 -0
  130. data/spec/url_scheme_spec.rb +39 -0
  131. data/spec/url_spec.rb +951 -0
  132. data/spec/user_name_spec.rb +54 -0
  133. data/spec/vulnerability_spec.rb +8 -0
  134. data/spec/web_credential_spec.rb +72 -0
  135. metadata +266 -0
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/db/model'
22
+
23
+ require 'active_record'
24
+ require 'uri/query_params'
25
+
26
+ module Ronin
27
+ module DB
28
+ #
29
+ # Represents a query param that belongs to a {URL}.
30
+ #
31
+ class URLQueryParam < ActiveRecord::Base
32
+
33
+ include Model
34
+
35
+ # @!attribute [rw] id
36
+ # The primary-key of the URL query param
37
+ #
38
+ # @return [Integer]
39
+ attribute :id, :integer
40
+
41
+ # @!attribute [rw] name
42
+ # The name of the URL query param.
43
+ #
44
+ # @return [URLQueryParamName]
45
+ belongs_to :name, required: true,
46
+ class_name: 'URLQueryParamName'
47
+ validates :name_id, uniqueness: {scope: :url_id}
48
+
49
+ # @!attribute [rw] value
50
+ # The value of the URL query param
51
+ #
52
+ # @return [String]
53
+ attribute :value, :text
54
+
55
+ # @!attribute [rw] url
56
+ # The URL that the query param belongs to.
57
+ #
58
+ # @return [URL]
59
+ belongs_to :url, required: true,
60
+ class_name: 'URL'
61
+
62
+ #
63
+ # Converts the URL query param to a String.
64
+ #
65
+ # @return [String]
66
+ # The dumped URL query param.
67
+ #
68
+ # @api public
69
+ #
70
+ def to_s
71
+ URI::QueryParams.dump(self.name.to_s => self.value)
72
+ end
73
+
74
+ end
75
+ end
76
+ end
77
+
78
+ require 'ronin/db/url_query_param_name'
79
+ require 'ronin/db/url'
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/db/model/has_unique_name'
22
+ require 'ronin/db/model'
23
+
24
+ require 'active_record'
25
+
26
+ module Ronin
27
+ module DB
28
+ #
29
+ # Represents the name of a {URLQueryParam}.
30
+ #
31
+ class URLQueryParamName < ActiveRecord::Base
32
+
33
+ include Model
34
+ include Model::HasUniqueName
35
+
36
+ # @!attribute [rw] id
37
+ # The primary-key of the URL query param.
38
+ #
39
+ # @return [Integer]
40
+ attribute :id, :integer
41
+
42
+ # @!attribute [rw] name
43
+ # The name of the URL query param.
44
+ #
45
+ # @return [String]
46
+ attribute :name, :string # length: 256
47
+ validates :name, presence: true, uniqueness: true
48
+
49
+ # @!attribute [rw] query_params
50
+ # The URL query params.
51
+ #
52
+ # @return [Array<URLQueryParam>]
53
+ has_many :query_params, class_name: 'URLQueryParam',
54
+ foreign_key: :name_id
55
+
56
+ # @!attribute [r] created_at
57
+ # When the URL query param name was first created.
58
+ #
59
+ # @return [Time]
60
+ attribute :created_at, :time
61
+
62
+ #
63
+ # Converts the URL query param name to a String.
64
+ #
65
+ # @return [String]
66
+ # The name of the URL query param
67
+ #
68
+ # @api public
69
+ #
70
+ def to_s
71
+ self.name.to_s
72
+ end
73
+
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/db/model'
22
+ require 'ronin/db/model/has_unique_name'
23
+
24
+ require 'active_record'
25
+
26
+ module Ronin
27
+ module DB
28
+ #
29
+ # Represents a {URL} scheme.
30
+ #
31
+ class URLScheme < ActiveRecord::Base
32
+
33
+ include Model
34
+ include Model::HasUniqueName
35
+
36
+ self.table_name = 'ronin_url_schemes'
37
+
38
+ # @!attribute [rw] id
39
+ # The primary key of the URL scheme.
40
+ #
41
+ # @return [Integer]
42
+ attribute :id, :integer
43
+
44
+ # @!attribute [rw] urls
45
+ # The URLs that use the scheme.
46
+ #
47
+ # @return [Array<URL>]
48
+ has_many :urls, class_name: 'URL',
49
+ foreign_key: :scheme_id
50
+
51
+ #
52
+ # The HTTP URL Scheme
53
+ #
54
+ # @return [URLScheme]
55
+ #
56
+ def self.http
57
+ where(name: 'http').first
58
+ end
59
+
60
+ #
61
+ # The HTTPS URL Scheme
62
+ #
63
+ # @return [URLScheme]
64
+ #
65
+ def self.https
66
+ where(name: 'https').first
67
+ end
68
+
69
+ #
70
+ # The FTP URL Scheme
71
+ #
72
+ # @return [URLScheme]
73
+ #
74
+ def self.ftp
75
+ where(name: 'ftp').first
76
+ end
77
+
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,96 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/db/model'
22
+ require 'ronin/db/model/importable'
23
+ require 'ronin/db/model/has_unique_name'
24
+
25
+ require 'active_record'
26
+
27
+ module Ronin
28
+ module DB
29
+ #
30
+ # Represents a user name and their associated {Credential credentials}
31
+ # or {EmailAddress email addresses}.
32
+ #
33
+ class UserName < ActiveRecord::Base
34
+
35
+ include Model
36
+ include Model::Importable
37
+ include Model::HasUniqueName
38
+
39
+ self.table_name = 'ronin_user_names'
40
+
41
+ # @!attribute [rw] id
42
+ # The primary key of the user name.
43
+ #
44
+ # @return [Integer]
45
+ attribute :id, :integer
46
+
47
+ # @!attribute [r] created_at
48
+ # Tracks when the user-name was created.
49
+ #
50
+ # @return [Time]
51
+ attribute :created_at, :time
52
+
53
+ # @!attribute [rw] credentials
54
+ # Any credentials belonging to the user.
55
+ #
56
+ # @return [Array<Credential>]
57
+ has_many :credentials, dependent: :destroy
58
+
59
+ # @!attribute [rw] email_addresses
60
+ # The email addresses of the user.
61
+ #
62
+ # @return [Array<EmailAddress>]
63
+ has_many :email_addresses, dependent: :destroy
64
+
65
+ #
66
+ # Looks up the user name.
67
+ #
68
+ # @param [String] name
69
+ # The user name to lookup.
70
+ #
71
+ # @return [UserName, nil]
72
+ # The found user name.
73
+ #
74
+ def self.lookup(name)
75
+ find_by(name: name)
76
+ end
77
+
78
+ #
79
+ # Imports a user name.
80
+ #
81
+ # @param [String] name
82
+ # The user name to import.
83
+ #
84
+ # @return [UserName]
85
+ # The imported user name.
86
+ #
87
+ def self.import(name)
88
+ create(name: name)
89
+ end
90
+
91
+ end
92
+ end
93
+ end
94
+
95
+ require 'ronin/db/credential'
96
+ require 'ronin/db/email_address'
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/db/model'
22
+ require 'ronin/db/advisory'
23
+ require 'ronin/db/address'
24
+ require 'ronin/db/open_port'
25
+ require 'ronin/db/url'
26
+
27
+ require 'active_record'
28
+
29
+ module Ronin
30
+ module DB
31
+ class Vulnerability < ActiveRecord::Base
32
+
33
+ include Model
34
+
35
+ # @!attribute [rw] id
36
+ # The primary key of the vulnerability.
37
+ #
38
+ # @return [Integer]
39
+ attribute :id, :integer
40
+
41
+ # @!attribute [rw] mac_address
42
+ # The MAC address that is vulnerable.
43
+ #
44
+ # @return [MACAddress, nil]
45
+ belongs_to :mac_address, optional: true,
46
+ class_name: 'MACAddress'
47
+
48
+ # @!attribute [rw] ip_address
49
+ # The IP address that is vulnerable.
50
+ #
51
+ # @return [IPAddress, nil]
52
+ belongs_to :ip_address, optional: true,
53
+ class_name: 'IPAddress'
54
+
55
+ # @!attribute [rw] host_name
56
+ # The host name that is vulnerable.
57
+ #
58
+ # @return [HostName, nil]
59
+ belongs_to :host_name, optional: true
60
+
61
+ # @!attribute [rw] open_port
62
+ # The open port that hosts a vulnerable service.
63
+ #
64
+ # @return [OpenPort, nil]
65
+ belongs_to :open_port, optional: true
66
+
67
+ # @!attribute [rw] url
68
+ # The URL that is vulnerable.
69
+ #
70
+ # @return [URL, nil]
71
+ belongs_to :url, optional: true
72
+
73
+ # @!attribute [rw] advisory
74
+ # The vulnerability advisory.
75
+ #
76
+ # @return [Advisory]
77
+ belongs_to :advisory
78
+
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db-activerecord - ActiveRecord backend for the Ronin Database.
4
+ #
5
+ # Copyright (c) 2022 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-db-activerecord is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Lesser General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # ronin-db-activerecord is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Lesser General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Lesser General Public License
18
+ # along with ronin-db-activerecord. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'ronin/db/model'
22
+
23
+ require 'active_record'
24
+
25
+ module Ronin
26
+ module DB
27
+ #
28
+ # Represents Credentials used to access websites at specified {URL}s.
29
+ #
30
+ class WebCredential < ActiveRecord::Base
31
+
32
+ include Model
33
+
34
+ # @!attribute [rw] id
35
+ # Primary key of the service credential.
36
+ #
37
+ # @return [Integer]
38
+ attribute :id, :integer
39
+
40
+ # @!attribute [rw] credential
41
+ #
42
+ # @return [Credential]
43
+ belongs_to :credential
44
+
45
+ # @!attribute [rw] url
46
+ # The URL the credential can be used with.
47
+ #
48
+ # @return [URL, nil]
49
+ belongs_to :url, optional: true,
50
+ class_name: 'URL'
51
+
52
+ #
53
+ # Converts the web credential to a String.
54
+ #
55
+ # @return [String]
56
+ # The user name, clear-text password and the optional URL.
57
+ #
58
+ # @api public
59
+ #
60
+ def to_s
61
+ "#{self.credential} (#{self.url})"
62
+ end
63
+
64
+ end
65
+ end
66
+ end
67
+
68
+ require 'ronin/db/credential'
69
+ require 'ronin/db/url'
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+
3
+ require 'yaml'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gemspec = YAML.load_file('gemspec.yml')
7
+
8
+ gem.name = gemspec.fetch('name')
9
+ gem.version = gemspec.fetch('version') do
10
+ lib_dir = File.join(File.dirname(__FILE__),'lib')
11
+ $LOAD_PATH << lib_dir unless $LOAD_PATH.include?(lib_dir)
12
+
13
+ require 'ronin/db/version'
14
+ Ronin::DB::VERSION
15
+ end
16
+
17
+ gem.summary = gemspec['summary']
18
+ gem.description = gemspec['description']
19
+ gem.licenses = Array(gemspec['license'])
20
+ gem.authors = Array(gemspec['authors'])
21
+ gem.email = gemspec['email']
22
+ gem.homepage = gemspec['homepage']
23
+ gem.metadata = gemspec['metadata'] if gemspec['metadata']
24
+
25
+ glob = lambda { |patterns| gem.files & Dir[*patterns] }
26
+
27
+ gem.files = `git ls-files`.split($/)
28
+ gem.files = glob[gemspec['files']] if gemspec['files']
29
+ gem.files += Array(gemspec['generated_files'])
30
+
31
+ gem.executables = gemspec.fetch('executables') do
32
+ glob['bin/*'].map { |path| File.basename(path) }
33
+ end
34
+
35
+ gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
36
+ gem.test_files = glob[gemspec['test_files'] || 'spec/{**/}*_spec.rb']
37
+ gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
38
+
39
+ gem.require_paths = Array(gemspec.fetch('require_paths') {
40
+ %w[ext lib].select { |dir| File.directory?(dir) }
41
+ })
42
+
43
+ gem.requirements = gemspec['requirements']
44
+ gem.required_ruby_version = gemspec['required_ruby_version']
45
+ gem.required_rubygems_version = gemspec['required_rubygems_version']
46
+ gem.post_install_message = gemspec['post_install_message']
47
+
48
+ split = lambda { |string| string.split(/,\s*/) }
49
+
50
+ if gemspec['dependencies']
51
+ gemspec['dependencies'].each do |name,versions|
52
+ gem.add_dependency(name,split[versions])
53
+ end
54
+ end
55
+
56
+ if gemspec['development_dependencies']
57
+ gemspec['development_dependencies'].each do |name,versions|
58
+ gem.add_development_dependency(name,split[versions])
59
+ end
60
+ end
61
+ end