ronin-db 0.1.2-java → 0.2.0.rc1-java

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 (104) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +3 -2
  3. data/.gitignore +1 -0
  4. data/ChangeLog.md +33 -0
  5. data/Gemfile +6 -4
  6. data/README.md +17 -5
  7. data/Rakefile +13 -35
  8. data/data/completions/ronin-db +271 -0
  9. data/gemspec.yml +17 -2
  10. data/lib/ronin/db/cli/command.rb +1 -1
  11. data/lib/ronin/db/cli/commands/add.rb +1 -1
  12. data/lib/ronin/db/cli/commands/asn.rb +12 -2
  13. data/lib/ronin/db/cli/commands/certs.rb +322 -0
  14. data/lib/ronin/db/cli/commands/completion.rb +63 -0
  15. data/lib/ronin/db/cli/commands/creds.rb +2 -1
  16. data/lib/ronin/db/cli/commands/edit.rb +1 -1
  17. data/lib/ronin/db/cli/commands/emails.rb +22 -1
  18. data/lib/ronin/db/cli/commands/hosts.rb +2 -1
  19. data/lib/ronin/db/cli/commands/ips.rb +2 -1
  20. data/lib/ronin/db/cli/commands/irb.rb +8 -4
  21. data/lib/ronin/db/cli/commands/list.rb +1 -1
  22. data/lib/ronin/db/cli/commands/migrate.rb +12 -8
  23. data/lib/ronin/db/cli/commands/open_ports.rb +102 -0
  24. data/lib/ronin/db/cli/commands/oses.rb +95 -0
  25. data/lib/ronin/db/cli/commands/passwords.rb +83 -0
  26. data/lib/ronin/db/cli/commands/people.rb +185 -0
  27. data/lib/ronin/db/cli/commands/phone_numbers.rb +136 -0
  28. data/lib/ronin/db/cli/commands/ports.rb +103 -0
  29. data/lib/ronin/db/cli/commands/remove.rb +1 -1
  30. data/lib/ronin/db/cli/commands/services.rb +102 -0
  31. data/lib/ronin/db/cli/commands/software.rb +95 -0
  32. data/lib/ronin/db/cli/commands/street_addresses.rb +129 -0
  33. data/lib/ronin/db/cli/commands/urls.rb +2 -1
  34. data/lib/ronin/db/cli/commands/web_vulns.rb +235 -0
  35. data/lib/ronin/db/cli/database_options.rb +87 -0
  36. data/lib/ronin/db/cli/deletable.rb +85 -0
  37. data/lib/ronin/db/cli/importable.rb +108 -0
  38. data/lib/ronin/db/cli/model_command.rb +8 -6
  39. data/lib/ronin/db/cli/modifiable.rb +12 -104
  40. data/lib/ronin/db/cli/printing.rb +58 -0
  41. data/lib/ronin/db/cli/ruby_shell.rb +1 -1
  42. data/lib/ronin/db/cli/uri_methods.rb +1 -1
  43. data/lib/ronin/db/cli.rb +3 -1
  44. data/lib/ronin/db/config_file.rb +13 -8
  45. data/lib/ronin/db/exceptions.rb +10 -1
  46. data/lib/ronin/db/home.rb +1 -1
  47. data/lib/ronin/db/root.rb +1 -1
  48. data/lib/ronin/db/tasks.rb +87 -0
  49. data/lib/ronin/db/version.rb +2 -2
  50. data/lib/ronin/db.rb +24 -7
  51. data/man/ronin-db-add.1 +48 -70
  52. data/man/ronin-db-add.1.md +26 -22
  53. data/man/ronin-db-asn.1 +37 -55
  54. data/man/ronin-db-asn.1.md +29 -19
  55. data/man/ronin-db-certs.1 +108 -0
  56. data/man/ronin-db-certs.1.md +106 -0
  57. data/man/ronin-db-completion.1 +76 -0
  58. data/man/ronin-db-completion.1.md +78 -0
  59. data/man/ronin-db-creds.1 +29 -47
  60. data/man/ronin-db-creds.1.md +23 -16
  61. data/man/ronin-db-edit.1 +16 -27
  62. data/man/ronin-db-edit.1.md +11 -7
  63. data/man/ronin-db-emails.1 +37 -50
  64. data/man/ronin-db-emails.1.md +30 -17
  65. data/man/ronin-db-hosts.1 +32 -52
  66. data/man/ronin-db-hosts.1.md +25 -18
  67. data/man/ronin-db-ips.1 +32 -53
  68. data/man/ronin-db-ips.1.md +26 -19
  69. data/man/ronin-db-irb.1 +23 -36
  70. data/man/ronin-db-irb.1.md +17 -10
  71. data/man/ronin-db-list.1 +17 -31
  72. data/man/ronin-db-list.1.md +13 -9
  73. data/man/ronin-db-migrate.1 +23 -36
  74. data/man/ronin-db-migrate.1.md +17 -10
  75. data/man/ronin-db-open-ports.1 +72 -0
  76. data/man/ronin-db-open-ports.1.md +70 -0
  77. data/man/ronin-db-oses.1 +72 -0
  78. data/man/ronin-db-oses.1.md +70 -0
  79. data/man/ronin-db-passwords.1 +75 -0
  80. data/man/ronin-db-passwords.1.md +73 -0
  81. data/man/ronin-db-people.1 +96 -0
  82. data/man/ronin-db-people.1.md +94 -0
  83. data/man/ronin-db-phone-numbers.1 +93 -0
  84. data/man/ronin-db-phone-numbers.1.md +91 -0
  85. data/man/ronin-db-ports.1 +87 -0
  86. data/man/ronin-db-ports.1.md +85 -0
  87. data/man/ronin-db-remove.1 +16 -29
  88. data/man/ronin-db-remove.1.md +12 -8
  89. data/man/ronin-db-services.1 +84 -0
  90. data/man/ronin-db-services.1.md +82 -0
  91. data/man/ronin-db-software.1 +72 -0
  92. data/man/ronin-db-software.1.md +70 -0
  93. data/man/ronin-db-street-addresses.1 +81 -0
  94. data/man/ronin-db-street-addresses.1.md +79 -0
  95. data/man/ronin-db-urls.1 +38 -61
  96. data/man/ronin-db-urls.1.md +28 -21
  97. data/man/ronin-db-web-vulns.1 +87 -0
  98. data/man/ronin-db-web-vulns.1.md +85 -0
  99. data/man/ronin-db.1 +118 -0
  100. data/man/ronin-db.1.md +99 -0
  101. data/scripts/setup +58 -0
  102. metadata +70 -13
  103. data/lib/ronin/db/cli/database_command.rb +0 -71
  104. data/lib/ronin/db/cli/resources_command.rb +0 -118
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-db - A common database library for managing and querying security data.
4
4
  #
5
- # Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-db 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
@@ -18,122 +18,30 @@
18
18
  # along with ronin-db. If not, see <https://www.gnu.org/licenses/>.
19
19
  #
20
20
 
21
+ require 'ronin/db/cli/deletable'
22
+ require 'ronin/db/cli/importable'
23
+
21
24
  module Ronin
22
25
  module DB
23
26
  class CLI
24
27
  #
25
- # Allows a {ModelCommand} to add, import, delete, or delete all records.
28
+ # Allows a {ModelCommand} to add, import records from a file, delete
29
+ # individual records, or delete all records.
26
30
  #
27
31
  module Modifiable
28
32
  #
29
- # Adds the `--add`, `--import`, `--delete`, and `--delete-all` options
33
+ # Adds the `--add`, `--import`, `--delete` and `--delete-all` options
30
34
  # to the command.
31
35
  #
32
36
  # @param [Class<ModelCommand>] command
33
37
  # The command class including {Modifiable}.
34
38
  #
35
- def self.included(command)
36
- command.option :add, value: {
37
- type: String,
38
- usage: 'VALUE'
39
- },
40
- desc: 'Adds a value to the database'
41
-
42
- command.option :import, value: {
43
- type: String,
44
- usage: 'FILE'
45
- },
46
- desc: 'Imports the values from the FILE into the database'
47
-
48
- command.option :delete, value: {
49
- type: String,
50
- usage: 'VALUE'
51
- },
52
- desc: 'Deletes a value from the database'
53
-
54
- command.option :delete_all, desc: 'Deletes all values from the database'
55
- end
56
-
39
+ # @see Importable
40
+ # @see Deletable
57
41
  #
58
- # Runs the command.
59
- #
60
- def run
61
- connect
62
-
63
- if options[:add]
64
- add(options[:add])
65
- elsif options[:import]
66
- import_file(options[:import])
67
- elsif options[:delete]
68
- delete(options[:delete])
69
- elsif options[:delete_all]
70
- delete_all
71
- else
72
- list
73
- end
74
- end
75
-
76
- #
77
- # Adds a value to the database.
78
- #
79
- # @param [String] value
80
- # The value to add.
81
- #
82
- def add(value)
83
- record = model.import(value)
84
-
85
- unless record.valid?
86
- print_error "failed to import #{value}!"
87
-
88
- record.errors.full_messages.each do |message|
89
- print_error " - #{message}"
90
- end
91
- end
92
- end
93
-
94
- #
95
- # Imports the values from the given file.
96
- #
97
- # @param [String] path
98
- # The path to the file.
99
- #
100
- def import_file(path)
101
- unless File.file?(path)
102
- print_error "no such file or directory: #{path}"
103
- exit(-1)
104
- end
105
-
106
- File.open(path) do |file|
107
- model.transaction do
108
- file.each_line(chomp: true) do |value|
109
- log_info "Importing #{value} ..." if verbose?
110
-
111
- add(value)
112
- end
113
- end
114
- end
115
- end
116
-
117
- #
118
- # Deletes a value from the database.
119
- #
120
- # @param [String] value
121
- # The value to lookup and delete.
122
- #
123
- def delete(value)
124
- if (record = model.lookup(value))
125
- record.destroy
126
- else
127
- print_error "value does not exist in the database: #{value}"
128
- exit(-1)
129
- end
130
- end
131
-
132
- #
133
- # Deletes all values from the database.
134
- #
135
- def delete_all
136
- model.destroy_all
42
+ def self.included(command)
43
+ command.include Deletable
44
+ command.include Importable
137
45
  end
138
46
  end
139
47
  end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db - A common database library for managing and querying security data.
4
+ #
5
+ # Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-db 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 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. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ module Ronin
22
+ module DB
23
+ class CLI
24
+ #
25
+ # Helper methods for printing {Ronin::DB} records.
26
+ #
27
+ # @since 0.2.0
28
+ #
29
+ # @api semipublic
30
+ #
31
+ module Printing
32
+ #
33
+ # Maps a record to a human readable display name.
34
+ #
35
+ # @param [Ronin::DB::IPAddress,
36
+ # Ronin::DB::MACAddress,
37
+ # Ronin::DB::HostName,
38
+ # Ronin::DB::Port,
39
+ # Ronin::DB::Service,
40
+ # Ronin::DB::OpenPort] record
41
+ #
42
+ # @return [String, nil]
43
+ # The human readable type or `nil` if the record model is unknown.
44
+ #
45
+ def record_type(record)
46
+ case record
47
+ when HostName then 'host'
48
+ when IPAddress then 'IP'
49
+ when MACAddress then 'MAC'
50
+ when Port then 'port'
51
+ when Service then 'service'
52
+ when OpenPort then 'open port'
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-db - A common database library for managing and querying security data.
4
4
  #
5
- # Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-db 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 - A common database library for managing and querying security data.
4
4
  #
5
- # Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-db 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/cli.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-db - A common database library for managing and querying security data.
4
4
  #
5
- # Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-db 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
@@ -43,6 +43,8 @@ module Ronin
43
43
  command_name 'ronin-db'
44
44
  version Ronin::DB::VERSION
45
45
 
46
+ command_aliases['console'] = 'irb'
47
+
46
48
  end
47
49
  end
48
50
  end
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-db - A common database library for managing and querying security data.
4
4
  #
5
- # Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-db 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/exceptions'
22
22
  require 'ronin/db/home'
23
23
 
24
+ require 'fileutils'
24
25
  require 'yaml'
25
26
  require 'yaml/store'
26
27
 
@@ -65,21 +66,21 @@ module Ronin
65
66
  #
66
67
  def self.validate(path,data)
67
68
  unless data.kind_of?(Hash)
68
- raise(InvalidConfig)
69
+ raise(InvalidConfig,"config data must be a Hash: #{data.inspect}")
69
70
  end
70
71
 
71
72
  data.each do |key,value|
72
- unless (key.kind_of?(Symbol) || key.kind_of?(String))
73
- raise(InvalidConfig)
73
+ unless key.kind_of?(Symbol)
74
+ raise(InvalidConfig,"all Hash keys must be a Symbol: #{key.inspect}")
74
75
  end
75
76
 
76
77
  unless value.kind_of?(Hash)
77
- raise(InvalidConfig)
78
+ raise(InvalidConfig,"all Hash values must also be a Hash: #{value.inspect}")
78
79
  end
79
80
 
80
81
  value.each_key do |sub_key|
81
- unless (sub_key.kind_of?(Symbol) || sub_key.kind_of?(String))
82
- raise(InvalidConfig)
82
+ unless sub_key.kind_of?(Symbol)
83
+ raise(InvalidConfig,"all sub-keys must be a Symbol: #{sub_key.inspect}")
83
84
  end
84
85
  end
85
86
  end
@@ -124,8 +125,12 @@ module Ronin
124
125
  # The loaded YAML configuration data.
125
126
  #
126
127
  def self.edit(path=PATH,&block)
127
- store = YAML::Store.new(path)
128
+ unless File.file?(path)
129
+ # create the parent directory for YAML::Store
130
+ FileUtils.mkdir_p(File.dirname(path))
131
+ end
128
132
 
133
+ store = YAML::Store.new(path)
129
134
  store.transaction(&block)
130
135
  end
131
136
  end
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-db - A common database library for managing and querying security data.
4
4
  #
5
- # Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-db 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
@@ -20,7 +20,16 @@
20
20
 
21
21
  module Ronin
22
22
  module DB
23
+ #
24
+ # Indicates that the given database name is not in the config file.
25
+ #
23
26
  class UnknownDatabase < RuntimeError
24
27
  end
28
+
29
+ #
30
+ # Indicates that the config file is corrupted.
31
+ #
32
+ class InvalidConfig < RuntimeError
33
+ end
25
34
  end
26
35
  end
data/lib/ronin/db/home.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-db - A common database library for managing and querying security data.
4
4
  #
5
- # Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-db 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/root.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-db - A common database library for managing and querying security data.
4
4
  #
5
- # Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-db 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
@@ -0,0 +1,87 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # ronin-db - A common database library for managing and querying security data.
4
+ #
5
+ # Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
+ #
7
+ # ronin-db 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 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. If not, see <https://www.gnu.org/licenses/>.
19
+ #
20
+
21
+ require 'rake/tasklib'
22
+
23
+ module Ronin
24
+ module DB
25
+ #
26
+ # Defines `ronin:db` tasks in a `Rakefile`.
27
+ #
28
+ # ## Example
29
+ #
30
+ # require 'ronin/db/tasks'
31
+ # Ronin::DB::Tasks.new
32
+ #
33
+ class Tasks < Rake::TaskLib
34
+
35
+ # The database to connect to.
36
+ #
37
+ # @return [Symbol, Hash]
38
+ attr_reader :database
39
+
40
+ #
41
+ # Initializes the tasks.
42
+ #
43
+ # @param [Symbol, Hash] database
44
+ # The database name or Hash to connect to.
45
+ #
46
+ # @api public
47
+ #
48
+ def initialize(database: :default)
49
+ super()
50
+
51
+ @database = database
52
+
53
+ define
54
+ end
55
+
56
+ #
57
+ # Defines the `ronin:db` tasks.
58
+ #
59
+ # @api private
60
+ #
61
+ def define
62
+ namespace :db do
63
+ task :connect do
64
+ require 'ronin/db'
65
+ DB.connect(@database)
66
+ end
67
+
68
+ desc 'Migrates the development database'
69
+ task :migrate => :connect do
70
+ require 'ronin/db/migrations'
71
+ DB::Migrations.up
72
+ end
73
+
74
+ desc 'Starts an interactive database console'
75
+ task :console => :connect do
76
+ require 'logger'
77
+ DB.logger = Logger.new($stderr,:debug)
78
+
79
+ require 'ronin/db/cli/ruby_shell'
80
+ DB::CLI::RubyShell.start
81
+ end
82
+ end
83
+ end
84
+
85
+ end
86
+ end
87
+ end
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-db - A common database library for managing and querying security data.
4
4
  #
5
- # Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-db 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,6 @@
21
21
  module Ronin
22
22
  module DB
23
23
  # ronin-db version
24
- VERSION = '0.1.2'
24
+ VERSION = '0.2.0.rc1'
25
25
  end
26
26
  end
data/lib/ronin/db.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ronin-db - A common database library for managing and querying security data.
4
4
  #
5
- # Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
5
+ # Copyright (c) 2006-2024 Hal Brodigan (postmodern.mod3 at gmail.com)
6
6
  #
7
7
  # ronin-db 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
@@ -76,8 +76,11 @@ module Ronin
76
76
  #
77
77
  # Connects to the Database.
78
78
  #
79
- # @param [Symbol, Hash] database
80
- # The optional database name or Hash of database information.
79
+ # @param [Symbol, String, Hash] database
80
+ # The optional database name, String URL, or Hash of database information.
81
+ #
82
+ # @param [Integer, nil] pool
83
+ # Sets the connection pool for the database.
81
84
  #
82
85
  # @param [Boolean] migrate
83
86
  # Specifies whether to hard or lazy migrate the database.
@@ -89,14 +92,25 @@ module Ronin
89
92
  # The database name was not listed in the config file.
90
93
  #
91
94
  # @raise [ArgumentError]
92
- # The given database was not a Symbol or a Hash.
95
+ # The given database was not a Symbol, String, or a Hash.
96
+ #
97
+ # @example Connect to the default database (`~/.local/share/ronin-db/default.sqlite3`):
98
+ # DB.connect
99
+ #
100
+ # @example Connect to a specific database from the configuration file (`~/.config/ronin-db/databases.yml`):
101
+ # DB.connect(:my_database)
102
+ #
103
+ # @example Connect to an arbitrary database:
104
+ # Db.connect({adapter: 'sqlite3', database: '/path/to/database.sqlite3'})
93
105
  #
94
106
  # @api semipublic
95
107
  #
96
- def self.connect(database=:default, migrate: nil, load_models: true)
108
+ def self.connect(database=:default, pool: nil,
109
+ migrate: nil,
110
+ load_models: true)
97
111
  config = case database
98
- when Hash
99
- database
112
+ when Hash then database
113
+ when String then {url: database}
100
114
  when Symbol
101
115
  self.config.fetch(database) do
102
116
  raise(UnknownDatabase,"unknown database: #{database.inspect}")
@@ -105,6 +119,9 @@ module Ronin
105
119
  raise(ArgumentError,"#{self}.#{__method__} only accepts a Symbol or a Hash")
106
120
  end
107
121
 
122
+ # set/override the connection pool setting
123
+ config = config.merge(pool: pool) if pool
124
+
108
125
  # load activerecord
109
126
  require 'active_record'
110
127
 
data/man/ronin-db-add.1 CHANGED
@@ -1,130 +1,108 @@
1
- .\" Generated by kramdown-man 0.1.8
1
+ .\" Generated by kramdown-man 1.0.1
2
2
  .\" https://github.com/postmodern/kramdown-man#readme
3
3
  .TH ronin-db-add 1 "2023-02-01" Ronin DB "User Manuals"
4
- .LP
4
+ .SH NAME
5
+ .PP
6
+ ronin\-db\-add \- Adds a pre\-existing database to ronin\-db
5
7
  .SH SYNOPSIS
6
- .LP
7
- .HP
8
- \fBronin-db add\fR \[lB]\fIoptions\fP\[rB] \fINAME\fP \[lB]\fIURI\fP\[rB]
9
- .LP
8
+ .PP
9
+ \fBronin\-db add\fR \[lB]\fIoptions\fP\[rB] \fINAME\fP \[lB]\fIURI\fP\[rB]
10
10
  .SH DESCRIPTION
11
- .LP
12
11
  .PP
13
- Adds a pre\-existing database to the \fB~/.config/ronin-db/database.yml\fR
12
+ Adds a pre\-existing database to the \fB\[ti]\[sl]\.config\[sl]ronin\-db\[sl]database\.yml\fR
14
13
  configuration file\.
15
- .LP
16
14
  .SH ARGUMENTS
17
- .LP
18
15
  .TP
19
16
  \fINAME\fP
20
17
  The name of the database to add\.
21
- .LP
22
18
  .TP
23
19
  \fIURI\fP
24
20
  The optional URI to the database to add\.
25
- .LP
26
21
  .SH OPTIONS
27
- .LP
28
22
  .TP
29
- \fB-A\fR, \fB--adapter\fR \fBsqlite3|mysql2|postgres|...\fR
23
+ \fB\-A\fR, \fB\-\-adapter\fR \fBsqlite3\[or]mysql2\[or]postgres\[or]\.\.\.\fR
30
24
  The adapter of the database to add\.
31
- .LP
32
25
  .TP
33
- \fB--sqlite3\fR \fIFILE\fP
34
- Alias for \fB--adapter sqlite3 --database\fR \fIFILE\fP\.
35
- .LP
26
+ \fB\-\-sqlite3\fR \fIFILE\fP
27
+ Alias for \fB\-\-adapter sqlite3 \-\-database\fR \fIFILE\fP\.
36
28
  .TP
37
- \fB--mysql2\fR
38
- Alias for \fB--adapter mysql2\fR\.
39
- .LP
29
+ \fB\-\-mysql2\fR
30
+ Alias for \fB\-\-adapter mysql2\fR\.
40
31
  .TP
41
- \fB--postgresql\fR
42
- Alias for \fB--adapter postgresql\fR\.
43
- .LP
32
+ \fB\-\-postgresql\fR
33
+ Alias for \fB\-\-adapter postgresql\fR\.
44
34
  .TP
45
- \fB-H\fR, \fB--host\fR \fIHOST\fP
35
+ \fB\-H\fR, \fB\-\-host\fR \fIHOST\fP
46
36
  The host of the database to add\.
47
- .LP
48
37
  .TP
49
- \fB-p\fR, \fB--port\fR \fIPORT\fP
38
+ \fB\-p\fR, \fB\-\-port\fR \fIPORT\fP
50
39
  The port of the database to add\.
51
- .LP
52
40
  .TP
53
- \fB-u\fR, \fB--username\fR \fIUSER\fP
41
+ \fB\-u\fR, \fB\-\-username\fR \fIUSER\fP
54
42
  The username to authenticate with for the database\.
55
- .LP
56
43
  .TP
57
- \fB-P\fR, \fB--password\fR \fIPASSWORD\fP
44
+ \fB\-P\fR, \fB\-\-password\fR \fIPASSWORD\fP
58
45
  The password to authenticate with for the database\.
59
- .LP
60
46
  .TP
61
- \fB--read-password\fR
47
+ \fB\-\-read\-password\fR
62
48
  Reads the database password from STDIN\.
63
- .LP
64
49
  .TP
65
- \fB-D\fR, \fB--database\fR \fINAME\fP\[or]\fIPATH\fP
66
- The database name to connect to\. If \fB--adapter sqlite3\fR is given then a path
50
+ \fB\-D\fR, \fB\-\-database\fR \fINAME\fP\[or]\fIPATH\fP
51
+ The database name to connect to\. If \fB\-\-adapter sqlite3\fR is given then a path
67
52
  may be given instead\.
68
- .LP
69
53
  .TP
70
- \fB-h\fR, \fB--help\fR
54
+ \fB\-h\fR, \fB\-\-help\fR
71
55
  Print help information\.
72
- .LP
73
56
  .SH EXAMPLES
74
- .LP
75
57
  .PP
76
58
  Add a sqlite3 database file:
77
- .LP
78
- .nf
79
- \[Do] ronin\-db add other\[ru]db \-\-sqlite3 path\[sl]to\[sl]db\.sqlite3
80
- .fi
81
- .LP
59
+ .PP
60
+ .RS 4
61
+ .EX
62
+ \[Do] ronin\-db add other\[ru]db \-\-sqlite3 path\[sl]to\[sl]db\.sqlite3
63
+ .EE
64
+ .RE
82
65
  .PP
83
66
  Add a PostgeSQL database:
84
- .LP
85
- .nf
86
- \[Do] ronin\-db add other\[ru]db \-\-postgres \-\-host example\.com \-\-port 5432 \-\-username ronin \-\-password s3r3t \-\-database ronin\[ru]db
87
- .fi
88
- .LP
67
+ .PP
68
+ .RS 4
69
+ .EX
70
+ \[Do] ronin\-db add other\[ru]db \-\-postgres \-\-host example\.com \-\-port 5432 \-\-username ronin \-\-password s3r3t \-\-database ronin\[ru]db
71
+ .EE
72
+ .RE
89
73
  .PP
90
74
  Add a MySQL database:
91
- .LP
92
- .nf
93
- \[Do] ronin\-db add other\[ru]db \-\-mysql2 \-\-host example\.com \-\-port 3306 \-\-username ronin \-\-password s3r3t \-\-database ronin\[ru]db
94
- .fi
95
- .LP
75
+ .PP
76
+ .RS 4
77
+ .EX
78
+ \[Do] ronin\-db add other\[ru]db \-\-mysql2 \-\-host example\.com \-\-port 3306 \-\-username ronin \-\-password s3r3t \-\-database ronin\[ru]db
79
+ .EE
80
+ .RE
96
81
  .SH ENVIRONMENT
97
- .LP
98
82
  .TP
99
83
  \fIHOME\fP
100
84
  Alternate location for the user\[cq]s home directory\.
101
- .LP
102
85
  .TP
103
86
  \fIXDG\[ru]CONFIG\[ru]HOME\fP
104
- Alternate location for the \fB~/.config\fR directory\.
105
- .LP
87
+ Alternate location for the \fB\[ti]\[sl]\.config\fR directory\.
106
88
  .TP
107
89
  \fIXDG\[ru]DATA\[ru]HOME\fP
108
- Alternate location for the \fB~/.local/share\fR directory\.
109
- .LP
90
+ Alternate location for the \fB\[ti]\[sl]\.local\[sl]share\fR directory\.
110
91
  .SH FILES
111
- .LP
112
92
  .TP
113
- \fB~/.local/share/ronin-db/database.sqlite3\fR
93
+ \fB\[ti]\[sl]\.local\[sl]share\[sl]ronin\-db\[sl]database\.sqlite3\fR
114
94
  The default sqlite3 database file\.
115
- .LP
116
95
  .TP
117
- \fB~/.config/ronin-db/database.yml\fR
96
+ \fB\[ti]\[sl]\.config\[sl]ronin\-db\[sl]database\.yml\fR
118
97
  Optional database configuration\.
119
- .LP
120
98
  .SH AUTHOR
121
- .LP
122
99
  .PP
123
100
  Postmodern
124
101
  .MT postmodern\.mod3\[at]gmail\.com
125
102
  .ME
126
- .LP
127
103
  .SH SEE ALSO
128
- .LP
129
104
  .PP
130
- ronin\-db(1) ronin\-db\-list(1) ronin\-db\-edit(1) ronin\-db\-remove(1)
105
+ .BR ronin\-db (1)
106
+ .BR ronin\-db\-list (1)
107
+ .BR ronin\-db\-edit (1)
108
+ .BR ronin\-db\-remove (1)