ronin-db 0.1.0.beta1-java → 0.1.0.beta2-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.
- checksums.yaml +4 -4
- data/.yardopts +1 -1
- data/Gemfile +1 -6
- data/README.md +3 -3
- data/gemspec.yml +8 -1
- 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 +1 -1
- data/lib/ronin/db/cli/commands/creds.rb +1 -1
- data/lib/ronin/db/cli/commands/edit.rb +1 -1
- data/lib/ronin/db/cli/commands/emails.rb +1 -1
- data/lib/ronin/db/cli/commands/hosts.rb +1 -1
- data/lib/ronin/db/cli/commands/ips.rb +2 -2
- data/lib/ronin/db/cli/commands/irb.rb +1 -1
- data/lib/ronin/db/cli/commands/list.rb +1 -1
- data/lib/ronin/db/cli/commands/migrate.rb +1 -1
- data/lib/ronin/db/cli/commands/remove.rb +1 -1
- data/lib/ronin/db/cli/commands/urls.rb +1 -1
- data/lib/ronin/db/cli/database_command.rb +1 -1
- data/lib/ronin/db/cli/model_command.rb +1 -1
- data/lib/ronin/db/cli/modifiable.rb +1 -1
- data/lib/ronin/db/cli/resources_command.rb +1 -1
- 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 +6 -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/version.rb +2 -2
- data/lib/ronin/db.rb +3 -3
- data/ronin-db.gemspec +2 -1
- metadata +9 -19
- data/spec/cli/commands/add_spec.rb +0 -220
- data/spec/cli/commands/edit_spec.rb +0 -12
- data/spec/cli/commands/irb_spec.rb +0 -26
- data/spec/cli/database_command_spec.rb +0 -53
- data/spec/cli/model_command_spec.rb +0 -237
- data/spec/cli/ruby_shell_spec.rb +0 -14
- data/spec/cli/uri_methods_spec.rb +0 -190
- data/spec/spec_helper.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a7bd725d5d4c65c237cf90b8740e68d0ca6bfefefff00c5e9aa878bb3aacce0
|
4
|
+
data.tar.gz: dcb49fc79a5ac5d0c937edb5465478fa8b0e035d170f95cdaff9ede1cc6e51a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 62f2d7d0d837c5754f974674e2fb668076533f44164999ff52e8bdf01f0ac524898902900ec3597825f4333dc2bccbb11ac140ab441c4cfa878bf3ff87736565
|
7
|
+
data.tar.gz: a9fadcf60d1ac739caac77e192c92731fbc7e39fb0fd08d9804160579102613eeb7e3d58c72b04a4cbaa9f27fac7dfa6116fff5e492078cf42663a0074545d10
|
data/.yardopts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--markup markdown --title 'Ronin
|
1
|
+
--markup markdown --title 'Ronin::DB Documentation' --protected
|
data/Gemfile
CHANGED
@@ -2,12 +2,7 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem '
|
6
|
-
|
7
|
-
platform :jruby do
|
8
|
-
gem 'jruby-openssl', '~> 0.7'
|
9
|
-
gem 'activerecord-jdbcsqlite3-adapter', '~> 70.0.pre'
|
10
|
-
end
|
5
|
+
gem 'jruby-openssl', '~> 0.7', platform: :jruby
|
11
6
|
|
12
7
|
# gem 'command_kit', '0.4.0', github: 'postmodern/command_kit',
|
13
8
|
# branch: 'main'
|
data/README.md
CHANGED
@@ -204,8 +204,8 @@ and [ronin-db-activerecord].
|
|
204
204
|
## Requirements
|
205
205
|
|
206
206
|
* [Ruby] >= 3.0.0
|
207
|
-
* [libsqlite3][sqlite]
|
208
|
-
|
207
|
+
* [libsqlite3][sqlite]
|
208
|
+
* [sqlite3] (or [activerecord-jdbcsqlite3-adapter] ~> 70.0.pre on JRuby)
|
209
209
|
* [ronin-db-activerecord] ~> 0.1
|
210
210
|
* [ronin-support] ~> 1.0
|
211
211
|
* [ronin-core] ~> 0.1
|
@@ -244,7 +244,7 @@ local database console.
|
|
244
244
|
|
245
245
|
## License
|
246
246
|
|
247
|
-
Copyright (c) 2006-
|
247
|
+
Copyright (c) 2006-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
248
248
|
|
249
249
|
ronin-db is free software: you can redistribute it and/or modify
|
250
250
|
it under the terms of the GNU Lesser General Public License as published
|
data/gemspec.yml
CHANGED
@@ -13,6 +13,13 @@ email: postmodern.mod3@gmail.com
|
|
13
13
|
homepage: https://ronin-rb.dev
|
14
14
|
has_yard: true
|
15
15
|
|
16
|
+
metadata:
|
17
|
+
documentation_uri: https://ronin-rb.dev/docs/ronin-db
|
18
|
+
source_code_uri: https://github.com/ronin-rb/ronin-db
|
19
|
+
bug_tracker_uri: https://github.com/ronin-rb/ronin-db/issues
|
20
|
+
changelog_uri: https://github.com/ronin-rb/ronin-db/blob/main/ChangeLog.md
|
21
|
+
rubygems_mfa_required: 'true'
|
22
|
+
|
16
23
|
generated_files:
|
17
24
|
- man/ronin-db-add.1
|
18
25
|
- man/ronin-db-asn.1
|
@@ -31,7 +38,7 @@ generated_files:
|
|
31
38
|
required_ruby_version: ">= 3.0.0"
|
32
39
|
|
33
40
|
ruby_dependencies:
|
34
|
-
|
41
|
+
sqlite3: ~> 1.0
|
35
42
|
|
36
43
|
jruby_dependencies:
|
37
44
|
activerecord-jdbcsqlite3-adapter: ~> 70.0.pre
|
data/lib/ronin/db/cli/command.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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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
|
@@ -26,7 +26,7 @@ module Ronin
|
|
26
26
|
class CLI
|
27
27
|
module Commands
|
28
28
|
#
|
29
|
-
# Manages
|
29
|
+
# Manages IP addresses in the database.
|
30
30
|
#
|
31
31
|
# ## Usage
|
32
32
|
#
|
@@ -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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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-2023 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,8 +18,11 @@
|
|
18
18
|
# along with ronin-db. If not, see <https://www.gnu.org/licenses/>.
|
19
19
|
#
|
20
20
|
|
21
|
+
require 'ronin/db/version'
|
22
|
+
|
21
23
|
require 'command_kit/commands'
|
22
24
|
require 'command_kit/commands/auto_load'
|
25
|
+
require 'command_kit/options/version'
|
23
26
|
|
24
27
|
module Ronin
|
25
28
|
module DB
|
@@ -30,8 +33,10 @@ module Ronin
|
|
30
33
|
dir: "#{__dir__}/cli/commands",
|
31
34
|
namespace: "#{self}::Commands"
|
32
35
|
)
|
36
|
+
include CommandKit::Options::Version
|
33
37
|
|
34
38
|
command_name 'ronin-db'
|
39
|
+
version Ronin::DB::VERSION
|
35
40
|
|
36
41
|
end
|
37
42
|
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-2023 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-2023 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-2023 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-2023 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/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-2023 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.0.
|
24
|
+
VERSION = '0.1.0.beta2'
|
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-2023 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
|
@@ -73,8 +73,8 @@ module Ronin
|
|
73
73
|
#
|
74
74
|
# Connects to the Database.
|
75
75
|
#
|
76
|
-
# @param [Symbol, Hash]
|
77
|
-
# The optional
|
76
|
+
# @param [Symbol, Hash] database
|
77
|
+
# The optional database name or Hash of database information.
|
78
78
|
#
|
79
79
|
# @param [Boolean] migrate
|
80
80
|
# Specifies whether to hard or lazy migrate the database.
|
data/ronin-db.gemspec
CHANGED
@@ -27,6 +27,8 @@ Gem::Specification.new do |gem|
|
|
27
27
|
gem.files = `git ls-files`.split($/)
|
28
28
|
gem.files = glob[gemspec['files']] if gemspec['files']
|
29
29
|
gem.files += Array(gemspec['generated_files'])
|
30
|
+
# exclude test files from the packages gem
|
31
|
+
gem.files -= glob[gemspec['test_files'] || 'spec/{**/}*']
|
30
32
|
|
31
33
|
gem.executables = gemspec.fetch('executables') do
|
32
34
|
glob['bin/*'].map { |path| File.basename(path) }
|
@@ -34,7 +36,6 @@ Gem::Specification.new do |gem|
|
|
34
36
|
gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
|
35
37
|
|
36
38
|
gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
|
37
|
-
gem.test_files = glob[gemspec['test_files'] || 'spec/{**/}*_spec.rb']
|
38
39
|
gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
|
39
40
|
|
40
41
|
gem.require_paths = Array(gemspec.fetch('require_paths') {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ronin-db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.beta2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -159,18 +159,15 @@ files:
|
|
159
159
|
- man/ronin-db-urls.1
|
160
160
|
- man/ronin-db-urls.1.md
|
161
161
|
- ronin-db.gemspec
|
162
|
-
- spec/cli/commands/add_spec.rb
|
163
|
-
- spec/cli/commands/edit_spec.rb
|
164
|
-
- spec/cli/commands/irb_spec.rb
|
165
|
-
- spec/cli/database_command_spec.rb
|
166
|
-
- spec/cli/model_command_spec.rb
|
167
|
-
- spec/cli/ruby_shell_spec.rb
|
168
|
-
- spec/cli/uri_methods_spec.rb
|
169
|
-
- spec/spec_helper.rb
|
170
162
|
homepage: https://ronin-rb.dev
|
171
163
|
licenses:
|
172
164
|
- LGPL-3.0
|
173
|
-
metadata:
|
165
|
+
metadata:
|
166
|
+
documentation_uri: https://ronin-rb.dev/docs/ronin-db
|
167
|
+
source_code_uri: https://github.com/ronin-rb/ronin-db
|
168
|
+
bug_tracker_uri: https://github.com/ronin-rb/ronin-db/issues
|
169
|
+
changelog_uri: https://github.com/ronin-rb/ronin-db/blob/main/ChangeLog.md
|
170
|
+
rubygems_mfa_required: 'true'
|
174
171
|
post_install_message:
|
175
172
|
rdoc_options: []
|
176
173
|
require_paths:
|
@@ -190,11 +187,4 @@ rubygems_version: 3.3.25
|
|
190
187
|
signing_key:
|
191
188
|
specification_version: 4
|
192
189
|
summary: A common database library for managing and querying security data
|
193
|
-
test_files:
|
194
|
-
- spec/cli/commands/add_spec.rb
|
195
|
-
- spec/cli/commands/edit_spec.rb
|
196
|
-
- spec/cli/commands/irb_spec.rb
|
197
|
-
- spec/cli/database_command_spec.rb
|
198
|
-
- spec/cli/model_command_spec.rb
|
199
|
-
- spec/cli/ruby_shell_spec.rb
|
200
|
-
- spec/cli/uri_methods_spec.rb
|
190
|
+
test_files: []
|
@@ -1,220 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/db/cli/commands/add'
|
3
|
-
|
4
|
-
describe Ronin::DB::CLI::Commands::Add do
|
5
|
-
describe "options" do
|
6
|
-
before { subject.parse_options(argv) }
|
7
|
-
|
8
|
-
describe "--adapter" do
|
9
|
-
let(:adapter) { 'sqlite3' }
|
10
|
-
let(:argv) { ['--adapter', adapter] }
|
11
|
-
|
12
|
-
it "must set #config[:adapter]" do
|
13
|
-
expect(subject.config[:adapter]).to eq(adapter)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "--sqlite3" do
|
18
|
-
let(:database) { '/path/to/file.sqlite3' }
|
19
|
-
let(:argv) { ['--sqlite3', database] }
|
20
|
-
|
21
|
-
it "must set #config[:adapter] to 'sqlite3'" do
|
22
|
-
expect(subject.config[:adapter]).to eq('sqlite3')
|
23
|
-
end
|
24
|
-
|
25
|
-
it "must set #config[:database] to the given path" do
|
26
|
-
expect(subject.config[:database]).to eq(database)
|
27
|
-
end
|
28
|
-
|
29
|
-
context "when the argument is a relative path" do
|
30
|
-
let(:database) { 'file.sqlite3' }
|
31
|
-
|
32
|
-
it "must expand the relative path before setting #config[:database]" do
|
33
|
-
expect(subject.config[:database]).to eq(File.expand_path(database))
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe "--mysql2" do
|
39
|
-
let(:argv) { ['--mysql2'] }
|
40
|
-
|
41
|
-
it "must set #config[:adapter] to 'mysql2'" do
|
42
|
-
expect(subject.config[:adapter]).to eq('mysql2')
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "--postgresql" do
|
47
|
-
let(:argv) { ['--postgresql'] }
|
48
|
-
|
49
|
-
it "must set #config[:adapter] to 'postgresql'" do
|
50
|
-
expect(subject.config[:adapter]).to eq('postgresql')
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "--host" do
|
55
|
-
let(:host) { 'example.com' }
|
56
|
-
let(:argv) { ['--host', host] }
|
57
|
-
|
58
|
-
it "must set #config[:host]" do
|
59
|
-
expect(subject.config[:host]).to eq(host)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "--port" do
|
64
|
-
let(:port) { 1234 }
|
65
|
-
let(:argv) { ['--port', port.to_s] }
|
66
|
-
|
67
|
-
it "must set #config[:port]" do
|
68
|
-
expect(subject.config[:port]).to eq(port)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "--username" do
|
73
|
-
let(:username) { 'foo' }
|
74
|
-
let(:argv) { ['--username', username] }
|
75
|
-
|
76
|
-
it "must set #config[:username]" do
|
77
|
-
expect(subject.config[:username]).to eq(username)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe "--password" do
|
82
|
-
let(:password) { 'secret' }
|
83
|
-
let(:argv) { ['--password', password] }
|
84
|
-
|
85
|
-
it "must set #config[:password]" do
|
86
|
-
expect(subject.config[:password]).to eq(password)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "--database" do
|
91
|
-
let(:database) { 'foo' }
|
92
|
-
let(:argv) { ['--database', database] }
|
93
|
-
|
94
|
-
it "must set #config[:database]" do
|
95
|
-
expect(subject.config[:database]).to eq(database)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe "#initialize" do
|
101
|
-
it "must initialize #config to an empty Hash" do
|
102
|
-
expect(subject.config).to eq({})
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "#run" do
|
107
|
-
let(:adapter) { 'sqlite3' }
|
108
|
-
let(:database) { '/path/to/test.sqlite3' }
|
109
|
-
let(:name) { 'test' }
|
110
|
-
|
111
|
-
let(:config_file_hash) { {} }
|
112
|
-
|
113
|
-
context "when given a URI argument" do
|
114
|
-
let(:uri) { "#{adapter}:#{database}" }
|
115
|
-
|
116
|
-
it "must parse the URI, call ConfigFile.edit, and add #config to it with the given NAME argument" do
|
117
|
-
expect(Ronin::DB::ConfigFile).to receive(:edit).and_yield(config_file_hash)
|
118
|
-
|
119
|
-
subject.run(name,uri)
|
120
|
-
|
121
|
-
expect(config_file_hash[name]).to eq(
|
122
|
-
{
|
123
|
-
adapter: adapter,
|
124
|
-
database: database
|
125
|
-
}
|
126
|
-
)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
context "when given options instead of a URI argument" do
|
131
|
-
let(:argv) do
|
132
|
-
[
|
133
|
-
'--adapter', adapter,
|
134
|
-
'--database', database
|
135
|
-
]
|
136
|
-
end
|
137
|
-
|
138
|
-
before { subject.parse_options(argv) }
|
139
|
-
|
140
|
-
it "must call ConfigFile.edit and add #config to it with the given NAME argument" do
|
141
|
-
expect(Ronin::DB::ConfigFile).to receive(:edit).and_yield(config_file_hash)
|
142
|
-
|
143
|
-
subject.run(name)
|
144
|
-
|
145
|
-
expect(config_file_hash[name]).to eq(
|
146
|
-
{
|
147
|
-
adapter: adapter,
|
148
|
-
database: database
|
149
|
-
}
|
150
|
-
)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
context "when #config[:adapter] is not set" do
|
155
|
-
let(:argv) { ['--database', '/path/to/db.sqlite3'] }
|
156
|
-
|
157
|
-
before { subject.parse_options(argv) }
|
158
|
-
|
159
|
-
it "must print an error message and exit with 1" do
|
160
|
-
expect {
|
161
|
-
subject.run(name)
|
162
|
-
}.to output("add: must specify a URI or the --adapter option#{$/}").to_stderr.and(raise_error(SystemExit))
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
context "when #config[:database] is not set" do
|
167
|
-
let(:argv) { ['--adapter', 'sqlite3'] }
|
168
|
-
|
169
|
-
before { subject.parse_options(argv) }
|
170
|
-
|
171
|
-
it "must print an error message and exit with 1" do
|
172
|
-
expect {
|
173
|
-
subject.run(name)
|
174
|
-
}.to output("add: must specify a URI or the --database option#{$/}").to_stderr.and(raise_error(SystemExit))
|
175
|
-
end
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
describe "#read_password" do
|
180
|
-
let(:password) { 'secret' }
|
181
|
-
|
182
|
-
it "must call #ask_secret with 'Password' and set config[:password]" do
|
183
|
-
expect(subject).to receive(:ask_secret).with('Password').and_return(password)
|
184
|
-
|
185
|
-
subject.read_password
|
186
|
-
|
187
|
-
expect(subject.config[:password]).to eq(password)
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
describe "#validate_config!" do
|
192
|
-
context "when #config[:adapter] is not set" do
|
193
|
-
before do
|
194
|
-
subject.config[:database] = '/path/to/db.sqlite3'
|
195
|
-
end
|
196
|
-
|
197
|
-
it "must print an error message and exit with 1" do
|
198
|
-
expect(subject).to receive(:exit).with(1)
|
199
|
-
|
200
|
-
expect {
|
201
|
-
subject.validate_config!
|
202
|
-
}.to output("add: must specify a URI or the --adapter option#{$/}").to_stderr
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
context "when #config[:database] is not set" do
|
207
|
-
before do
|
208
|
-
subject.config[:adapter] = 'sqlite3'
|
209
|
-
end
|
210
|
-
|
211
|
-
it "must print an error message and exit with 1" do
|
212
|
-
expect(subject).to receive(:exit).with(1)
|
213
|
-
|
214
|
-
expect {
|
215
|
-
subject.validate_config!
|
216
|
-
}.to output("add: must specify a URI or the --database option#{$/}").to_stderr
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
220
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/db/cli/commands/edit'
|
3
|
-
|
4
|
-
describe Ronin::DB::CLI::Commands::Edit do
|
5
|
-
describe "#run" do
|
6
|
-
it "must edit the ConfigFile::PATH" do
|
7
|
-
expect(subject).to receive(:edit).with(Ronin::DB::ConfigFile::PATH)
|
8
|
-
|
9
|
-
subject.run
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/db/cli/commands/irb'
|
3
|
-
|
4
|
-
describe Ronin::DB::CLI::Commands::Irb do
|
5
|
-
describe "#run" do
|
6
|
-
it "must call #connet, then #load_models, then CLI::RubyShell.start" do
|
7
|
-
expect(subject).to receive(:connect)
|
8
|
-
expect(subject).to receive(:load_models)
|
9
|
-
expect(Ronin::DB::CLI::RubyShell).to receive(:start)
|
10
|
-
|
11
|
-
subject.run
|
12
|
-
end
|
13
|
-
|
14
|
-
context "when #options[:no_connect] is set" do
|
15
|
-
before { subject.options[:no_connect] = true }
|
16
|
-
|
17
|
-
it "must not call #connet or #load_models" do
|
18
|
-
expect(subject).to_not receive(:connect)
|
19
|
-
expect(subject).to_not receive(:load_models)
|
20
|
-
expect(Ronin::DB::CLI::RubyShell).to receive(:start)
|
21
|
-
|
22
|
-
subject.run
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/db/cli/database_command'
|
3
|
-
|
4
|
-
describe Ronin::DB::CLI::DatabaseCommand do
|
5
|
-
describe "#config" do
|
6
|
-
context "when neither options[:db] nor options[:db_uri] are set" do
|
7
|
-
it "must default to connecting to the :default database" do
|
8
|
-
expect(subject.config).to eq(Ronin::DB.config[:default])
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
context "when options[:db] is set" do
|
13
|
-
let(:db_name) { :test }
|
14
|
-
let(:config) do
|
15
|
-
{
|
16
|
-
db_name => {
|
17
|
-
adapter: 'sqlite3',
|
18
|
-
database: '/path/to/db.sqlite3'
|
19
|
-
}
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
before do
|
24
|
-
allow(Ronin::DB).to receive(:config).and_return(config)
|
25
|
-
|
26
|
-
subject.options[:db] = db_name
|
27
|
-
end
|
28
|
-
|
29
|
-
it "must return the database configuration for options[:db]" do
|
30
|
-
expect(subject.config).to eq(Ronin::DB.config[db_name])
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
context "when options[:db_uri] is set" do
|
35
|
-
let(:db_uri) { "postgres://user:password@host:1234/database" }
|
36
|
-
let(:parsed_uri) { subject.parse_uri(subject.options[:db_uri]) }
|
37
|
-
|
38
|
-
before { subject.options[:db_uri] = db_uri }
|
39
|
-
|
40
|
-
it "must return the parsed URI for options[:db_uri]" do
|
41
|
-
expect(subject.config).to eq(parsed_uri)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "#connect" do
|
47
|
-
it "must call ActiveRecord::Base.establish_connection with #config" do
|
48
|
-
expect(ActiveRecord::Base).to receive(:establish_connection).with(subject.config)
|
49
|
-
|
50
|
-
subject.connect
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,237 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/db/cli/model_command'
|
3
|
-
require 'ronin/db/ip_address'
|
4
|
-
require 'ronin/db/host_name'
|
5
|
-
|
6
|
-
describe Ronin::DB::CLI::ModelCommand do
|
7
|
-
it "must inherit from Ronin::DB::CLI::DatabaseCommand" do
|
8
|
-
expect(described_class).to be < Ronin::DB::CLI::DatabaseCommand
|
9
|
-
end
|
10
|
-
|
11
|
-
describe ".model_file" do
|
12
|
-
subject { test_class }
|
13
|
-
|
14
|
-
context "and when model_file is not set in the class" do
|
15
|
-
module TestModelCommand
|
16
|
-
class WithNoModelFileSet < Ronin::DB::CLI::ModelCommand
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
let(:test_class) { TestModelCommand::WithNoModelFileSet }
|
21
|
-
|
22
|
-
it do
|
23
|
-
expect {
|
24
|
-
subject.model_file
|
25
|
-
}.to raise_error(NotImplementedError,"#{subject} did not define model_file")
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "and when model_file is set in the class" do
|
30
|
-
module TestModelCommand
|
31
|
-
class WithModelFileSet < Ronin::DB::CLI::ModelCommand
|
32
|
-
model_file 'ronin/db/test'
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
let(:test_class) { TestModelCommand::WithModelFileSet }
|
37
|
-
|
38
|
-
it "must return the set model_file" do
|
39
|
-
expect(subject.model_file).to eq('ronin/db/test')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
context "but when the model_file was set in the superclass" do
|
44
|
-
module TestModelCommand
|
45
|
-
class InheritsItsModelFile < WithModelFileSet
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
let(:test_class) { TestModelCommand::InheritsItsModelFile }
|
50
|
-
|
51
|
-
it "must return the model_file set in the superclass" do
|
52
|
-
expect(subject.model_file).to eq('ronin/db/test')
|
53
|
-
end
|
54
|
-
|
55
|
-
context "but the model_file is overridden in the sub-class" do
|
56
|
-
module TestModelCommand
|
57
|
-
class OverridesItsInheritedModelFile < WithModelFileSet
|
58
|
-
model_file 'ronin/db/test2'
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
let(:test_class) do
|
63
|
-
TestModelCommand::OverridesItsInheritedModelFile
|
64
|
-
end
|
65
|
-
|
66
|
-
it "must return the model_file set in the sub-class" do
|
67
|
-
expect(subject.model_file).to eq('ronin/db/test2')
|
68
|
-
end
|
69
|
-
|
70
|
-
it "must not modify the superclass'es model_file" do
|
71
|
-
expect(subject.superclass.model_file).to eq('ronin/db/test')
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe ".model_name" do
|
78
|
-
subject { test_class }
|
79
|
-
|
80
|
-
context "and when model_name is not set in the class" do
|
81
|
-
module TestModelCommand
|
82
|
-
class WithNoModelNameSet < Ronin::DB::CLI::ModelCommand
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
let(:test_class) { TestModelCommand::WithNoModelNameSet }
|
87
|
-
|
88
|
-
it do
|
89
|
-
expect {
|
90
|
-
subject.model_name
|
91
|
-
}.to raise_error(NotImplementedError,"#{subject} did not define model_name")
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
context "and when model_name is set in the class" do
|
96
|
-
module TestModelCommand
|
97
|
-
class WithModelNameSet < Ronin::DB::CLI::ModelCommand
|
98
|
-
model_name 'Test'
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
let(:test_class) { TestModelCommand::WithModelNameSet }
|
103
|
-
|
104
|
-
it "must return the set model_name" do
|
105
|
-
expect(subject.model_name).to eq('Test')
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
context "but when the model_name was set in the superclass" do
|
110
|
-
module TestModelCommand
|
111
|
-
class InheritsItsModelName < WithModelNameSet
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
let(:test_class) { TestModelCommand::InheritsItsModelName }
|
116
|
-
|
117
|
-
it "must return the model_name set in the superclass" do
|
118
|
-
expect(subject.model_name).to eq('Test')
|
119
|
-
end
|
120
|
-
|
121
|
-
context "but the model_name is overridden in the sub-class" do
|
122
|
-
module TestModelCommand
|
123
|
-
class OverridesItsInheritedModelName < WithModelNameSet
|
124
|
-
model_name 'Test2'
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
let(:test_class) do
|
129
|
-
TestModelCommand::OverridesItsInheritedModelName
|
130
|
-
end
|
131
|
-
|
132
|
-
it "must return the model_name set in the sub-class" do
|
133
|
-
expect(subject.model_name).to eq('Test2')
|
134
|
-
end
|
135
|
-
|
136
|
-
it "must not modify the superclass'es model_name" do
|
137
|
-
expect(subject.superclass.model_name).to eq('Test')
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
describe ".model_name" do
|
144
|
-
end
|
145
|
-
|
146
|
-
module TestModelCommand
|
147
|
-
class TestCommand < Ronin::DB::CLI::ModelCommand
|
148
|
-
model_file 'ronin/db/ip_address'
|
149
|
-
model_name 'IPAddress'
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
let(:test_command) { TestModelCommand::TestCommand }
|
154
|
-
subject { test_command.new }
|
155
|
-
|
156
|
-
describe "#initialize" do
|
157
|
-
it "must initialize #query_method_calls to an empty Array" do
|
158
|
-
expect(subject.query_method_calls).to eq([])
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
describe "#model" do
|
163
|
-
it "must resolve the class for the model within Ronin::DB::" do
|
164
|
-
expect(subject.model).to be(Ronin::DB.const_get(subject.class.model_name))
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe "#query" do
|
169
|
-
let(:host) { 'example.com' }
|
170
|
-
let(:ipv4) { '93.184.216.34' }
|
171
|
-
let(:ipv6) { '2606:2800:220:1:248:1893:25c8:1946' }
|
172
|
-
|
173
|
-
before do
|
174
|
-
host_name = Ronin::DB::HostName.create(name: host)
|
175
|
-
|
176
|
-
Ronin::DB::IPAddress.create(address: '127.0.0.1', version: 4)
|
177
|
-
Ronin::DB::IPAddress.create(
|
178
|
-
address: ipv4,
|
179
|
-
version: 4,
|
180
|
-
host_names: [host_name]
|
181
|
-
)
|
182
|
-
Ronin::DB::IPAddress.create(
|
183
|
-
address: ipv6,
|
184
|
-
version: 6,
|
185
|
-
host_names: [host_name]
|
186
|
-
)
|
187
|
-
Ronin::DB::IPAddress.create(address: '::1', version: 6)
|
188
|
-
end
|
189
|
-
|
190
|
-
context "when #query_method_calls is empty" do
|
191
|
-
it "must return a ActiveRecord_Relation object" do
|
192
|
-
expect(subject.query).to be_kind_of(
|
193
|
-
subject.model.const_get('ActiveRecord_Relation')
|
194
|
-
)
|
195
|
-
end
|
196
|
-
end
|
197
|
-
|
198
|
-
context "when #query_method_calls contains a :where method call" do
|
199
|
-
before do
|
200
|
-
subject.query_method_calls << [:where, [], {version: 4}]
|
201
|
-
end
|
202
|
-
|
203
|
-
it "must invoke #where with the given arguments on the query" do
|
204
|
-
expect(subject.query).to eq(
|
205
|
-
Ronin::DB::IPAddress.where(version: 4)
|
206
|
-
)
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
context "when #query_method_calls contains a scoped query method call" do
|
211
|
-
before do
|
212
|
-
subject.query_method_calls << [:with_host_name, [host]]
|
213
|
-
end
|
214
|
-
|
215
|
-
it "must invoke the scoped query method on the query" do
|
216
|
-
expect(subject.query).to eq(
|
217
|
-
Ronin::DB::IPAddress.with_host_name(host)
|
218
|
-
)
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
after do
|
223
|
-
Ronin::DB::IPAddress.destroy_all
|
224
|
-
Ronin::DB::HostName.destroy_all
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
describe "#print_record" do
|
229
|
-
let(:record) { Ronin::DB::IPAddress.new(address: '127.0.0.1') }
|
230
|
-
|
231
|
-
it "must print the record using #puts" do
|
232
|
-
expect {
|
233
|
-
subject.print_record(record)
|
234
|
-
}.to output("#{record}#{$/}").to_stdout
|
235
|
-
end
|
236
|
-
end
|
237
|
-
end
|
data/spec/cli/ruby_shell_spec.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/db/cli/ruby_shell'
|
3
|
-
|
4
|
-
describe Ronin::DB::CLI::RubyShell do
|
5
|
-
describe "#initialize" do
|
6
|
-
it "must default #name to 'ronin-db'" do
|
7
|
-
expect(subject.name).to eq('ronin-db')
|
8
|
-
end
|
9
|
-
|
10
|
-
it "must default #context to Ronin::DB" do
|
11
|
-
expect(subject.context).to be(Ronin::DB)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,190 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/db/cli/uri_methods'
|
3
|
-
|
4
|
-
describe Ronin::DB::CLI::URIMethods do
|
5
|
-
subject do
|
6
|
-
obj = Object.new
|
7
|
-
obj.extend described_class
|
8
|
-
obj
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "#normalize_adapter" do
|
12
|
-
context "when given 'sqlite'" do
|
13
|
-
it "must return 'sqlite3'" do
|
14
|
-
expect(subject.normalize_adapter('sqlite')).to eq('sqlite3')
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context "when given 'sqlite3'" do
|
19
|
-
it "must return 'sqlite3'" do
|
20
|
-
expect(subject.normalize_adapter('sqlite3')).to eq('sqlite3')
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "when given 'mysql'" do
|
25
|
-
it "must return 'mysql2'" do
|
26
|
-
expect(subject.normalize_adapter('mysql')).to eq('mysql2')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context "when given 'mysql2'" do
|
31
|
-
it "must return 'mysql2'" do
|
32
|
-
expect(subject.normalize_adapter('mysql2')).to eq('mysql2')
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "when given 'postgresql'" do
|
37
|
-
it "must return 'postgresql'" do
|
38
|
-
expect(subject.normalize_adapter('postgresql')).to eq('postgresql')
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
context "when given 'postgres'" do
|
43
|
-
it "must return 'postgresql'" do
|
44
|
-
expect(subject.normalize_adapter('postgres')).to eq('postgresql')
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context "when given 'psql'" do
|
49
|
-
it "must return 'postgresql'" do
|
50
|
-
expect(subject.normalize_adapter('psql')).to eq('postgresql')
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context "when given 'pg'" do
|
55
|
-
it "must return 'postgresql'" do
|
56
|
-
expect(subject.normalize_adapter('pg')).to eq('postgresql')
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "#normalize_sqlite3_path" do
|
62
|
-
context "when given a relative path" do
|
63
|
-
let(:path) { 'file.sqlite3' }
|
64
|
-
|
65
|
-
it "must return an absolute path" do
|
66
|
-
expect(subject.normalize_sqlite3_path(path)).to eq(
|
67
|
-
File.expand_path(path)
|
68
|
-
)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context "when given an absolute path" do
|
73
|
-
let(:path) { '/path/to/file.sqlite3' }
|
74
|
-
|
75
|
-
it "must return the absolute path" do
|
76
|
-
expect(subject.normalize_sqlite3_path(path)).to eq(path)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context "when given ':memory:'" do
|
81
|
-
let(:path) { ':memory:' }
|
82
|
-
|
83
|
-
it "must return ':memory:'" do
|
84
|
-
expect(subject.normalize_sqlite3_path(path)).to eq(path)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe "#parse_uri" do
|
90
|
-
[:sqlite3, :sqlite].each do |adapter|
|
91
|
-
let(:adapter) { adapter }
|
92
|
-
|
93
|
-
context "when given '#{adapter}:path'" do
|
94
|
-
let(:path) { "db.sqlite3" }
|
95
|
-
let(:uri) { "#{adapter}:#{path}" }
|
96
|
-
|
97
|
-
it "must return {adapter: 'sqlite3', database: absolute_path}" do
|
98
|
-
expect(subject.parse_uri(uri)).to eq(
|
99
|
-
{
|
100
|
-
adapter: 'sqlite3',
|
101
|
-
database: File.expand_path(path)
|
102
|
-
}
|
103
|
-
)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
context "when given '#{adapter}:/path'" do
|
108
|
-
let(:path) { "/db.sqlite3" }
|
109
|
-
let(:uri) { "#{adapter}:#{path}" }
|
110
|
-
|
111
|
-
it "must return {adapter: 'sqlite3', database: '/path'}" do
|
112
|
-
expect(subject.parse_uri(uri)).to eq(
|
113
|
-
{
|
114
|
-
adapter: 'sqlite3',
|
115
|
-
database: path
|
116
|
-
}
|
117
|
-
)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
context "when given '#{adapter}::memory:'" do
|
122
|
-
let(:path) { ":memory:" }
|
123
|
-
let(:uri) { "#{adapter}:#{path}" }
|
124
|
-
|
125
|
-
it "must return {adapter: 'sqlite3', database: ':memory:'}" do
|
126
|
-
expect(subject.parse_uri(uri)).to eq(
|
127
|
-
{
|
128
|
-
adapter: 'sqlite3',
|
129
|
-
database: path
|
130
|
-
}
|
131
|
-
)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
[:mysql2, :mysql].each do |adapter|
|
137
|
-
context "when given '#{adapter}://user:password@host:port/database'" do
|
138
|
-
let(:adapter) { adapter }
|
139
|
-
let(:user) { 'foo' }
|
140
|
-
let(:password) { 'secret' }
|
141
|
-
let(:host) { 'example.com' }
|
142
|
-
let(:port) { 1234 }
|
143
|
-
let(:database) { 'test' }
|
144
|
-
let(:uri) do
|
145
|
-
"#{adapter}://#{user}:#{password}@#{host}:#{port}/#{database}"
|
146
|
-
end
|
147
|
-
|
148
|
-
it "must return {adapter: 'mysql2', username: '...', password: '...', host: '...', port: ..., database: 'database'}" do
|
149
|
-
expect(subject.parse_uri(uri)).to eq(
|
150
|
-
{
|
151
|
-
adapter: 'mysql2',
|
152
|
-
username: user,
|
153
|
-
password: password,
|
154
|
-
host: host,
|
155
|
-
port: port,
|
156
|
-
database: database
|
157
|
-
}
|
158
|
-
)
|
159
|
-
end
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
[:postgresql, :postgres, :psql, :pg].each do |adapter|
|
164
|
-
context "when given '#{adapter}://user:password@host:port/database'" do
|
165
|
-
let(:adapter) { adapter }
|
166
|
-
let(:user) { 'foo' }
|
167
|
-
let(:password) { 'secret' }
|
168
|
-
let(:host) { 'example.com' }
|
169
|
-
let(:port) { 1234 }
|
170
|
-
let(:database) { 'test' }
|
171
|
-
let(:uri) do
|
172
|
-
"#{adapter}://#{user}:#{password}@#{host}:#{port}/#{database}"
|
173
|
-
end
|
174
|
-
|
175
|
-
it "must return {adapter: 'postgresql', username: '...', password: '...', host: '...', port: ..., database: 'database'}" do
|
176
|
-
expect(subject.parse_uri(uri)).to eq(
|
177
|
-
{
|
178
|
-
adapter: 'postgresql',
|
179
|
-
username: user,
|
180
|
-
password: password,
|
181
|
-
host: host,
|
182
|
-
port: port,
|
183
|
-
database: database
|
184
|
-
}
|
185
|
-
)
|
186
|
-
end
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'simplecov'
|
3
|
-
SimpleCov.start
|
4
|
-
|
5
|
-
require 'active_record'
|
6
|
-
ActiveRecord::Base.establish_connection(
|
7
|
-
adapter: 'sqlite3', database: ':memory:'
|
8
|
-
)
|
9
|
-
|
10
|
-
RSpec.configure do |specs|
|
11
|
-
specs.before(:suite) do
|
12
|
-
require 'ronin/db/migrations'
|
13
|
-
Ronin::DB::Migrations.migrate
|
14
|
-
end
|
15
|
-
end
|