ronin-db 0.1.3-java → 0.2.0.rc1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -0
- data/.gitignore +1 -0
- data/ChangeLog.md +28 -0
- data/Gemfile +6 -4
- data/README.md +17 -5
- data/Rakefile +13 -35
- data/data/completions/ronin-db +271 -0
- data/gemspec.yml +17 -2
- data/lib/ronin/db/cli/command.rb +1 -1
- data/lib/ronin/db/cli/commands/add.rb +1 -1
- data/lib/ronin/db/cli/commands/asn.rb +12 -2
- data/lib/ronin/db/cli/commands/certs.rb +322 -0
- data/lib/ronin/db/cli/commands/completion.rb +63 -0
- data/lib/ronin/db/cli/commands/creds.rb +2 -1
- data/lib/ronin/db/cli/commands/edit.rb +1 -1
- data/lib/ronin/db/cli/commands/emails.rb +22 -1
- data/lib/ronin/db/cli/commands/hosts.rb +2 -1
- data/lib/ronin/db/cli/commands/ips.rb +2 -1
- data/lib/ronin/db/cli/commands/irb.rb +8 -4
- data/lib/ronin/db/cli/commands/list.rb +1 -1
- data/lib/ronin/db/cli/commands/migrate.rb +12 -8
- data/lib/ronin/db/cli/commands/open_ports.rb +102 -0
- data/lib/ronin/db/cli/commands/oses.rb +95 -0
- data/lib/ronin/db/cli/commands/passwords.rb +83 -0
- data/lib/ronin/db/cli/commands/people.rb +185 -0
- data/lib/ronin/db/cli/commands/phone_numbers.rb +136 -0
- data/lib/ronin/db/cli/commands/ports.rb +103 -0
- data/lib/ronin/db/cli/commands/remove.rb +1 -1
- data/lib/ronin/db/cli/commands/services.rb +102 -0
- data/lib/ronin/db/cli/commands/software.rb +95 -0
- data/lib/ronin/db/cli/commands/street_addresses.rb +129 -0
- data/lib/ronin/db/cli/commands/urls.rb +2 -1
- data/lib/ronin/db/cli/commands/web_vulns.rb +235 -0
- data/lib/ronin/db/cli/database_options.rb +87 -0
- data/lib/ronin/db/cli/deletable.rb +85 -0
- data/lib/ronin/db/cli/importable.rb +108 -0
- data/lib/ronin/db/cli/model_command.rb +8 -6
- data/lib/ronin/db/cli/modifiable.rb +12 -104
- data/lib/ronin/db/cli/printing.rb +58 -0
- data/lib/ronin/db/cli/ruby_shell.rb +1 -1
- data/lib/ronin/db/cli/uri_methods.rb +1 -1
- data/lib/ronin/db/cli.rb +3 -1
- data/lib/ronin/db/config_file.rb +1 -1
- data/lib/ronin/db/exceptions.rb +1 -1
- data/lib/ronin/db/home.rb +1 -1
- data/lib/ronin/db/root.rb +1 -1
- data/lib/ronin/db/tasks.rb +87 -0
- data/lib/ronin/db/version.rb +2 -2
- data/lib/ronin/db.rb +15 -7
- data/man/ronin-db-add.1 +47 -69
- data/man/ronin-db-add.1.md +26 -22
- data/man/ronin-db-asn.1 +36 -54
- data/man/ronin-db-asn.1.md +29 -19
- data/man/ronin-db-certs.1 +108 -0
- data/man/ronin-db-certs.1.md +106 -0
- data/man/ronin-db-completion.1 +76 -0
- data/man/ronin-db-completion.1.md +78 -0
- data/man/ronin-db-creds.1 +28 -46
- data/man/ronin-db-creds.1.md +23 -16
- data/man/ronin-db-edit.1 +15 -26
- data/man/ronin-db-edit.1.md +11 -7
- data/man/ronin-db-emails.1 +36 -49
- data/man/ronin-db-emails.1.md +30 -17
- data/man/ronin-db-hosts.1 +31 -51
- data/man/ronin-db-hosts.1.md +25 -18
- data/man/ronin-db-ips.1 +31 -52
- data/man/ronin-db-ips.1.md +26 -19
- data/man/ronin-db-irb.1 +22 -35
- data/man/ronin-db-irb.1.md +17 -10
- data/man/ronin-db-list.1 +16 -30
- data/man/ronin-db-list.1.md +13 -9
- data/man/ronin-db-migrate.1 +22 -35
- data/man/ronin-db-migrate.1.md +17 -10
- data/man/ronin-db-open-ports.1 +72 -0
- data/man/ronin-db-open-ports.1.md +70 -0
- data/man/ronin-db-oses.1 +72 -0
- data/man/ronin-db-oses.1.md +70 -0
- data/man/ronin-db-passwords.1 +75 -0
- data/man/ronin-db-passwords.1.md +73 -0
- data/man/ronin-db-people.1 +96 -0
- data/man/ronin-db-people.1.md +94 -0
- data/man/ronin-db-phone-numbers.1 +93 -0
- data/man/ronin-db-phone-numbers.1.md +91 -0
- data/man/ronin-db-ports.1 +87 -0
- data/man/ronin-db-ports.1.md +85 -0
- data/man/ronin-db-remove.1 +15 -28
- data/man/ronin-db-remove.1.md +12 -8
- data/man/ronin-db-services.1 +84 -0
- data/man/ronin-db-services.1.md +82 -0
- data/man/ronin-db-software.1 +72 -0
- data/man/ronin-db-software.1.md +70 -0
- data/man/ronin-db-street-addresses.1 +81 -0
- data/man/ronin-db-street-addresses.1.md +79 -0
- data/man/ronin-db-urls.1 +37 -60
- data/man/ronin-db-urls.1.md +28 -21
- data/man/ronin-db-web-vulns.1 +87 -0
- data/man/ronin-db-web-vulns.1.md +85 -0
- data/man/ronin-db.1 +118 -0
- data/man/ronin-db.1.md +99 -0
- data/scripts/setup +58 -0
- metadata +70 -13
- data/lib/ronin/db/cli/database_command.rb +0 -71
- 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-
|
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
|
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
|
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
|
-
|
36
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
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-
|
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-
|
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-
|
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
|
data/lib/ronin/db/config_file.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-
|
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/exceptions.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-
|
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/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-
|
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-
|
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
|
data/lib/ronin/db/version.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-
|
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.
|
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-
|
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,7 +92,7 @@ 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.
|
93
96
|
#
|
94
97
|
# @example Connect to the default database (`~/.local/share/ronin-db/default.sqlite3`):
|
95
98
|
# DB.connect
|
@@ -102,10 +105,12 @@ module Ronin
|
|
102
105
|
#
|
103
106
|
# @api semipublic
|
104
107
|
#
|
105
|
-
def self.connect(database=:default,
|
108
|
+
def self.connect(database=:default, pool: nil,
|
109
|
+
migrate: nil,
|
110
|
+
load_models: true)
|
106
111
|
config = case database
|
107
|
-
when Hash
|
108
|
-
|
112
|
+
when Hash then database
|
113
|
+
when String then {url: database}
|
109
114
|
when Symbol
|
110
115
|
self.config.fetch(database) do
|
111
116
|
raise(UnknownDatabase,"unknown database: #{database.inspect}")
|
@@ -114,6 +119,9 @@ module Ronin
|
|
114
119
|
raise(ArgumentError,"#{self}.#{__method__} only accepts a Symbol or a Hash")
|
115
120
|
end
|
116
121
|
|
122
|
+
# set/override the connection pool setting
|
123
|
+
config = config.merge(pool: pool) if pool
|
124
|
+
|
117
125
|
# load activerecord
|
118
126
|
require 'active_record'
|
119
127
|
|
data/man/ronin-db-add.1
CHANGED
@@ -1,130 +1,108 @@
|
|
1
|
-
.\" Generated by kramdown-man 0.1
|
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
|
-
.
|
4
|
+
.SH NAME
|
5
|
+
.PP
|
6
|
+
ronin\-db\-add \- Adds a pre\-existing database to ronin\-db
|
5
7
|
.SH SYNOPSIS
|
6
|
-
.LP
|
7
8
|
.PP
|
8
|
-
\fBronin
|
9
|
-
.LP
|
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
|
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
|
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
|
34
|
-
Alias for \fB
|
35
|
-
.LP
|
26
|
+
\fB\-\-sqlite3\fR \fIFILE\fP
|
27
|
+
Alias for \fB\-\-adapter sqlite3 \-\-database\fR \fIFILE\fP\.
|
36
28
|
.TP
|
37
|
-
\fB
|
38
|
-
Alias for \fB
|
39
|
-
.LP
|
29
|
+
\fB\-\-mysql2\fR
|
30
|
+
Alias for \fB\-\-adapter mysql2\fR\.
|
40
31
|
.TP
|
41
|
-
\fB
|
42
|
-
Alias for \fB
|
43
|
-
.LP
|
32
|
+
\fB\-\-postgresql\fR
|
33
|
+
Alias for \fB\-\-adapter postgresql\fR\.
|
44
34
|
.TP
|
45
|
-
\fB
|
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
|
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
|
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
|
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
|
47
|
+
\fB\-\-read\-password\fR
|
62
48
|
Reads the database password from STDIN\.
|
63
|
-
.LP
|
64
49
|
.TP
|
65
|
-
\fB
|
66
|
-
The database name to connect to\. If \fB
|
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
|
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
|
-
.
|
78
|
-
.
|
79
|
-
|
80
|
-
|
81
|
-
.
|
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
|
-
.
|
85
|
-
.
|
86
|
-
|
87
|
-
|
88
|
-
.
|
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
|
-
.
|
92
|
-
.
|
93
|
-
|
94
|
-
|
95
|
-
.
|
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
|
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
|
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
|
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
|
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
|
-
|
105
|
+
.BR ronin\-db (1)
|
106
|
+
.BR ronin\-db\-list (1)
|
107
|
+
.BR ronin\-db\-edit (1)
|
108
|
+
.BR ronin\-db\-remove (1)
|