ronin-app 0.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.dockerignore +3 -0
- data/.document +6 -0
- data/.env.dev +1 -0
- data/.github/workflows/ruby.yml +44 -0
- data/.gitignore +16 -0
- data/.rspec +1 -0
- data/.rubocop.yml +26 -0
- data/.ruby-version +1 -0
- data/.yardopts +1 -0
- data/CONTRIBUTING.md +34 -0
- data/COPYING.txt +661 -0
- data/ChangeLog.md +38 -0
- data/Dockerfile +27 -0
- data/Gemfile +61 -0
- data/Procfile +2 -0
- data/Procfile.dev +2 -0
- data/README.md +215 -0
- data/Rakefile +44 -0
- data/app/db.rb +680 -0
- data/app/scanning.rb +173 -0
- data/app.rb +372 -0
- data/bin/ronin-app +34 -0
- data/config/database.rb +17 -0
- data/config/puma.rb +24 -0
- data/config/redis.rb +4 -0
- data/config/sidekiq.rb +23 -0
- data/config/sidekiq.yml +12 -0
- data/config.ru +33 -0
- data/docker-compose.yml +45 -0
- data/etc/systemd/user/ronin-app-sidekiq.1.service +17 -0
- data/etc/systemd/user/ronin-app-web.1.service +18 -0
- data/etc/systemd/user/ronin-app.target +5 -0
- data/gemspec.yml +55 -0
- data/lib/middleware/sidekiq/active_record_connection_pool.rb +47 -0
- data/lib/ronin/app/cli.rb +197 -0
- data/lib/ronin/app/helpers/html.rb +71 -0
- data/lib/ronin/app/root.rb +28 -0
- data/lib/ronin/app/schemas/params_schema.rb +66 -0
- data/lib/ronin/app/schemas/payloads/build_schema.rb +56 -0
- data/lib/ronin/app/schemas/payloads/encoders/encode_schema.rb +60 -0
- data/lib/ronin/app/types/import.rb +35 -0
- data/lib/ronin/app/types/nmap.rb +81 -0
- data/lib/ronin/app/types/spider.rb +49 -0
- data/lib/ronin/app/types/vulns.rb +69 -0
- data/lib/ronin/app/types.rb +66 -0
- data/lib/ronin/app/validations/import_params.rb +71 -0
- data/lib/ronin/app/validations/install_repo_params.rb +78 -0
- data/lib/ronin/app/validations/masscan_params.rb +122 -0
- data/lib/ronin/app/validations/nmap_params.rb +183 -0
- data/lib/ronin/app/validations/recon_params.rb +86 -0
- data/lib/ronin/app/validations/spider_params.rb +103 -0
- data/lib/ronin/app/validations/vulns_params.rb +83 -0
- data/lib/ronin/app/version.rb +26 -0
- data/log/.gitkeep +0 -0
- data/man/ronin-app.1 +63 -0
- data/man/ronin-app.1.md +61 -0
- data/public/images/favicon.png +0 -0
- data/public/images/favicon.svg +78 -0
- data/public/images/logo.svg +78 -0
- data/public/images/sidekiq.svg +24 -0
- data/public/javascript/app.js +60 -0
- data/public/javascript/notes.js +28 -0
- data/public/javascript/tabs.js +40 -0
- data/public/stylesheets/app.css +216 -0
- data/public/stylesheets/bulma.min.css +1 -0
- data/ronin-app.gemspec +63 -0
- data/scripts/console +7 -0
- data/scripts/server +134 -0
- data/scripts/setup +447 -0
- data/scripts/update +55 -0
- data/tmp/.gitkeep +0 -0
- data/views/_authors.erb +62 -0
- data/views/_delete.erb +4 -0
- data/views/_delete_all.erb +4 -0
- data/views/_encoding_tabs.erb +25 -0
- data/views/_notes.erb +33 -0
- data/views/_pagination.erb +1 -0
- data/views/_param_fields.erb +66 -0
- data/views/_params.erb +35 -0
- data/views/about.erb +30 -0
- data/views/db/advisories/index.erb +30 -0
- data/views/db/advisories/show.erb +105 -0
- data/views/db/asns/index.erb +19 -0
- data/views/db/asns/show.erb +61 -0
- data/views/db/credentials/index.erb +30 -0
- data/views/db/credentials/show.erb +51 -0
- data/views/db/email_addresses/index.erb +30 -0
- data/views/db/email_addresses/show.erb +44 -0
- data/views/db/host_names/index.erb +30 -0
- data/views/db/host_names/show.erb +52 -0
- data/views/db/ip_addresses/index.erb +19 -0
- data/views/db/ip_addresses/show.erb +98 -0
- data/views/db/mac_addresses/index.erb +19 -0
- data/views/db/mac_addresses/show.erb +62 -0
- data/views/db/open_ports/index.erb +19 -0
- data/views/db/open_ports/show.erb +87 -0
- data/views/db/organizations/departments/show.erb +82 -0
- data/views/db/organizations/index.erb +28 -0
- data/views/db/organizations/members/show.erb +87 -0
- data/views/db/organizations/show.erb +111 -0
- data/views/db/oses/index.erb +19 -0
- data/views/db/oses/show.erb +46 -0
- data/views/db/passwords/index.erb +30 -0
- data/views/db/passwords/show.erb +52 -0
- data/views/db/people/index.erb +31 -0
- data/views/db/people/show.erb +120 -0
- data/views/db/phone_numbers/index.erb +30 -0
- data/views/db/phone_numbers/show.erb +63 -0
- data/views/db/ports/index.erb +30 -0
- data/views/db/ports/show.erb +70 -0
- data/views/db/services/index.erb +30 -0
- data/views/db/services/show.erb +65 -0
- data/views/db/software/index.erb +19 -0
- data/views/db/software/show.erb +52 -0
- data/views/db/software_vendors/index.erb +19 -0
- data/views/db/software_vendors/show.erb +36 -0
- data/views/db/street_addresses/index.erb +19 -0
- data/views/db/street_addresses/show.erb +63 -0
- data/views/db/url_query_param_names/index.erb +19 -0
- data/views/db/url_query_param_names/show.erb +50 -0
- data/views/db/url_schemes/index.erb +19 -0
- data/views/db/url_schemes/show.erb +36 -0
- data/views/db/urls/index.erb +30 -0
- data/views/db/urls/show.erb +103 -0
- data/views/db/user_names/index.erb +30 -0
- data/views/db/user_names/show.erb +48 -0
- data/views/db/vulns/index.erb +19 -0
- data/views/db/vulns/show.erb +104 -0
- data/views/db.erb +152 -0
- data/views/exploits/index.erb +9 -0
- data/views/exploits/show.erb +100 -0
- data/views/import.erb +30 -0
- data/views/index.erb +7 -0
- data/views/layout.erb +98 -0
- data/views/masscan.erb +459 -0
- data/views/nmap.erb +1009 -0
- data/views/payloads/build.erb +19 -0
- data/views/payloads/encoders/encode.erb +35 -0
- data/views/payloads/encoders/index.erb +9 -0
- data/views/payloads/encoders/show.erb +47 -0
- data/views/payloads/index.erb +9 -0
- data/views/payloads/show.erb +47 -0
- data/views/queue.erb +28 -0
- data/views/recon.erb +55 -0
- data/views/repos/index.erb +30 -0
- data/views/repos/install.erb +45 -0
- data/views/repos/show.erb +39 -0
- data/views/spider.erb +372 -0
- data/views/vulns.erb +214 -0
- data/workers/import.rb +96 -0
- data/workers/install_repo.rb +40 -0
- data/workers/masscan.rb +135 -0
- data/workers/nmap.rb +216 -0
- data/workers/purge_repos.rb +40 -0
- data/workers/recon.rb +95 -0
- data/workers/remove_repo.rb +40 -0
- data/workers/spider.rb +148 -0
- data/workers/update_repo.rb +42 -0
- data/workers/update_repos.rb +40 -0
- data/workers/vulns.rb +111 -0
- data/workers.rb +37 -0
- metadata +538 -0
data/docker-compose.yml
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
version: '3'
|
3
|
+
services:
|
4
|
+
web:
|
5
|
+
build:
|
6
|
+
context: .
|
7
|
+
privileged: true
|
8
|
+
command: bundle exec puma -C ./config/puma.rb -e production
|
9
|
+
ports:
|
10
|
+
- "1337:1337"
|
11
|
+
volumes:
|
12
|
+
- "./db:/app/db:z"
|
13
|
+
- "./log:/app/log:z"
|
14
|
+
- "./tmp:/app/tmp:z"
|
15
|
+
links:
|
16
|
+
- redis
|
17
|
+
environment:
|
18
|
+
- HOST=0.0.0.0
|
19
|
+
- PORT=1337
|
20
|
+
- REDIS_HOST=redis
|
21
|
+
- REDIS_PORT=6379
|
22
|
+
- DATABASE_URL=sqlite3:/app/db/production.sqlite3
|
23
|
+
|
24
|
+
sidekiq:
|
25
|
+
build:
|
26
|
+
context: .
|
27
|
+
privileged: true
|
28
|
+
cap_add:
|
29
|
+
- "NET_RAW"
|
30
|
+
- "NET_ADMIN"
|
31
|
+
- "NET_BIND_SERVICE"
|
32
|
+
command: bundle exec sidekiq -C ./config/sidekiq.yml -r ./config/sidekiq.rb -r ./workers.rb -e production
|
33
|
+
volumes:
|
34
|
+
- "./db:/app/db:z"
|
35
|
+
- "./log:/app/log:z"
|
36
|
+
- "./tmp:/app/tmp:z"
|
37
|
+
links:
|
38
|
+
- redis
|
39
|
+
environment:
|
40
|
+
- REDIS_HOST=redis
|
41
|
+
- REDIS_PORT=6379
|
42
|
+
- DATABASE_URL=sqlite3:/app/db/production.sqlite3
|
43
|
+
|
44
|
+
redis:
|
45
|
+
image: redis
|
@@ -0,0 +1,17 @@
|
|
1
|
+
[Unit]
|
2
|
+
PartOf=ronin-app.target
|
3
|
+
StopWhenUnneeded=yes
|
4
|
+
|
5
|
+
[Service]
|
6
|
+
User=ronin-app
|
7
|
+
WorkingDirectory=/srv/ronin-app
|
8
|
+
Environment=PS=sidekiq.1
|
9
|
+
ExecStart=/bin/bash -lc 'exec -a "ronin-app-sidekiq.1" bundle exec sidekiq -C ./config/sidekiq.yml -r ./config/sidekiq.rb -r ./workers.rb -e production'
|
10
|
+
Restart=always
|
11
|
+
RestartSec=14s
|
12
|
+
StandardInput=null
|
13
|
+
StandardOutput=syslog
|
14
|
+
StandardError=syslog
|
15
|
+
SyslogIdentifier=%n
|
16
|
+
KillMode=mixed
|
17
|
+
TimeoutStopSec=5
|
@@ -0,0 +1,18 @@
|
|
1
|
+
[Unit]
|
2
|
+
PartOf=ronin-app.target
|
3
|
+
StopWhenUnneeded=yes
|
4
|
+
|
5
|
+
[Service]
|
6
|
+
User=ronin-app
|
7
|
+
WorkingDirectory=/srv/ronin-app
|
8
|
+
Environment=PORT=1337
|
9
|
+
Environment=PS=web.1
|
10
|
+
ExecStart=/bin/bash -lc 'exec -a "ronin-app-web.1" bundle exec puma -C ./config/puma.rb -e production'
|
11
|
+
Restart=always
|
12
|
+
RestartSec=14s
|
13
|
+
StandardInput=null
|
14
|
+
StandardOutput=syslog
|
15
|
+
StandardError=syslog
|
16
|
+
SyslogIdentifier=%n
|
17
|
+
KillMode=mixed
|
18
|
+
TimeoutStopSec=5
|
data/gemspec.yml
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
name: ronin-app
|
2
|
+
summary: A local web interface for Ronin
|
3
|
+
description: |
|
4
|
+
ronin-app is a small web application that is meant to be ran locally by the
|
5
|
+
user. It provides a web interface to ronin-support, ronin-repos, ronin-db,
|
6
|
+
ronin-payloads, ronin-exploits, as well as automating
|
7
|
+
ronin-nmap, ronin-masscan, ronin-web-spider, ronin-recon, and ronin-vulns.
|
8
|
+
|
9
|
+
license: AGPL-3.0
|
10
|
+
authors: Postmodern
|
11
|
+
email: postmodern.mod3@gmail.com
|
12
|
+
homepage: https://ronin-rb.dev/
|
13
|
+
has_yard: true
|
14
|
+
|
15
|
+
metadata:
|
16
|
+
source_code_uri: https://github.com/ronin-rb/ronin-app
|
17
|
+
bug_tracker_uri: https://github.com/ronin-rb/ronin-app/issues
|
18
|
+
changelog_uri: https://github.com/ronin-rb/ronin-app/blob/main/ChangeLog.md
|
19
|
+
rubygems_mfa_required: 'true'
|
20
|
+
|
21
|
+
generated_files:
|
22
|
+
- man/ronin-app.1
|
23
|
+
|
24
|
+
excluded_files:
|
25
|
+
- screenshots/*.svg
|
26
|
+
|
27
|
+
required_ruby_version: ">= 3.1.0"
|
28
|
+
|
29
|
+
dependencies:
|
30
|
+
dry-schema: ~> 1.0
|
31
|
+
dry-validation: ~> 1.0
|
32
|
+
dry-struct: ~> 1.0
|
33
|
+
redis: ~> 5.0
|
34
|
+
redis-namespace: ~> 1.10
|
35
|
+
sinatra: ~> 3.0
|
36
|
+
sinatra-contrib: ~> 3.0
|
37
|
+
pagy: ~> 6.2
|
38
|
+
sinatra-flash: ~> 0.3
|
39
|
+
sidekiq: ~> 7.0
|
40
|
+
puma: ~> 6.0
|
41
|
+
# Ronin dependencies:
|
42
|
+
ronin-support: ~> 1.1.0.rc1
|
43
|
+
ronin-core: ~> 0.2.0.rc1
|
44
|
+
ronin-db-activerecord: ~> 0.2.0.rc1
|
45
|
+
ronin-db: ~> 0.2.0.rc1
|
46
|
+
ronin-payloads: ~> 0.2.0.rc1
|
47
|
+
ronin-exploits: ~> 1.1.0.rc1
|
48
|
+
ronin-vulns: ~> 0.2.0.rc1
|
49
|
+
ronin-web-spider: ~> 0.2.0.rc1
|
50
|
+
ronin-nmap: ~> 0.1.0.rc1
|
51
|
+
ronin-masscan: ~> 0.1.0.rc1
|
52
|
+
ronin-recon: ~> 0.1.0.rc1
|
53
|
+
|
54
|
+
development_dependencies:
|
55
|
+
bundler: ~> 2.0
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# ronin-app - a local web app for Ronin.
|
4
|
+
#
|
5
|
+
# Copyright (C) 2023 Hal Brodigan (postmodern.mod3@gmail.com)
|
6
|
+
#
|
7
|
+
# ronin-app is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Affero General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# ronin-app 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 Affero General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Affero General Public License
|
18
|
+
# along with ronin-app. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'active_record'
|
22
|
+
|
23
|
+
module Middleware
|
24
|
+
module Sidekiq
|
25
|
+
#
|
26
|
+
# Sidekiq middleware to clear the ActiveRecord connection pool after each
|
27
|
+
# job.
|
28
|
+
#
|
29
|
+
class ActiveRecordConnectionPool
|
30
|
+
|
31
|
+
#
|
32
|
+
# Allows the job to be processed, then clears the ActiveRecord connection
|
33
|
+
# pool.
|
34
|
+
#
|
35
|
+
def call(*)
|
36
|
+
yield
|
37
|
+
ensure
|
38
|
+
begin
|
39
|
+
ActiveRecord::Base.connection_handler.clear_active_connections!
|
40
|
+
rescue => error
|
41
|
+
warn error.message
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,197 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# ronin-app - a local web app for Ronin.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
|
6
|
+
#
|
7
|
+
# ronin-app is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Affero General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# ronin-app 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 Affero General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Affero General Public License
|
18
|
+
# along with ronin-app. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'ronin/core/cli/command'
|
22
|
+
require 'ronin/core/cli/logging'
|
23
|
+
require 'ronin/db/config_file'
|
24
|
+
require 'ronin/app/root'
|
25
|
+
require 'ronin/app/version'
|
26
|
+
|
27
|
+
require 'command_kit/options/version'
|
28
|
+
require 'command_kit/open_app'
|
29
|
+
|
30
|
+
module Ronin
|
31
|
+
module App
|
32
|
+
#
|
33
|
+
# Starts the ronin web app.
|
34
|
+
#
|
35
|
+
# ## Usage
|
36
|
+
#
|
37
|
+
# ronin-app [options]
|
38
|
+
#
|
39
|
+
# ## Options
|
40
|
+
#
|
41
|
+
# -V, --version Prints the version and exits
|
42
|
+
# -H, --host IP The host to listen on (Default: localhost)
|
43
|
+
# --db NAME The ronin-db database to connect to
|
44
|
+
# --db-uri URI The ronin-db database URI to connect to
|
45
|
+
# -p, --port PORT The port to listen on (Default: 1337)
|
46
|
+
# -h, --help Print help information
|
47
|
+
#
|
48
|
+
# @api private
|
49
|
+
#
|
50
|
+
class CLI < Core::CLI::Command
|
51
|
+
|
52
|
+
include Core::CLI::Logging
|
53
|
+
include CommandKit::Options::Version
|
54
|
+
include CommandKit::OpenApp
|
55
|
+
|
56
|
+
command_name 'ronin-app'
|
57
|
+
|
58
|
+
option :host, short: '-H',
|
59
|
+
value: {
|
60
|
+
type: String,
|
61
|
+
usage: 'IP',
|
62
|
+
default: 'localhost'
|
63
|
+
},
|
64
|
+
desc: 'The host to listen on'
|
65
|
+
|
66
|
+
option :port, short: '-p',
|
67
|
+
value: {
|
68
|
+
type: Integer,
|
69
|
+
usage: 'PORT',
|
70
|
+
default: 1337
|
71
|
+
},
|
72
|
+
desc: 'The port to listen on'
|
73
|
+
|
74
|
+
option :db, value: {
|
75
|
+
type: DB::ConfigFile.load.keys,
|
76
|
+
usage: 'NAME'
|
77
|
+
},
|
78
|
+
desc: 'The ronin-db database to connect to'
|
79
|
+
|
80
|
+
option :db_uri, value: {
|
81
|
+
type: String,
|
82
|
+
usage: 'URI'
|
83
|
+
},
|
84
|
+
desc: 'The ronin-db database URI to connect to'
|
85
|
+
|
86
|
+
description 'Starts the ronin web app'
|
87
|
+
|
88
|
+
man_dir File.join(ROOT,'man')
|
89
|
+
man_page 'ronin-app.1'
|
90
|
+
|
91
|
+
version VERSION
|
92
|
+
|
93
|
+
#
|
94
|
+
# Runs the `ronin-app` command.
|
95
|
+
#
|
96
|
+
def run
|
97
|
+
host = options[:host]
|
98
|
+
port = options[:port]
|
99
|
+
|
100
|
+
pids = []
|
101
|
+
|
102
|
+
# switch to the app directory
|
103
|
+
Dir.chdir(ROOT)
|
104
|
+
|
105
|
+
begin
|
106
|
+
unless is_redis_running?
|
107
|
+
log_info "Starting Redis server ..."
|
108
|
+
pids << start_redis
|
109
|
+
sleep 1
|
110
|
+
end
|
111
|
+
|
112
|
+
# start the web server process
|
113
|
+
log_info "Starting Web server on #{host}:#{port} ..."
|
114
|
+
pids << start_web_server
|
115
|
+
sleep 1
|
116
|
+
|
117
|
+
# start the sidekiq process
|
118
|
+
log_info "Starting Sidekiq ..."
|
119
|
+
pids << start_sidekiq
|
120
|
+
sleep 1
|
121
|
+
|
122
|
+
open_app_for("http://#{host}:#{port}") if stdout.tty?
|
123
|
+
sleep
|
124
|
+
ensure
|
125
|
+
pids.each do |pid|
|
126
|
+
Process.kill('TERM',pid)
|
127
|
+
Process.kill('HUP',pid)
|
128
|
+
end
|
129
|
+
|
130
|
+
Process.waitall
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
#
|
135
|
+
# Determines if the Redis server is running.
|
136
|
+
#
|
137
|
+
# @return [Boolean]
|
138
|
+
# Specifies whether the `redis-server` process is running or not.
|
139
|
+
#
|
140
|
+
def is_redis_running?
|
141
|
+
!`pgrep redis-server`.empty?
|
142
|
+
end
|
143
|
+
|
144
|
+
#
|
145
|
+
# Starts the Redis server.
|
146
|
+
#
|
147
|
+
# @return [Integer]
|
148
|
+
# The PID of the `redis-server` process.
|
149
|
+
#
|
150
|
+
def start_redis
|
151
|
+
Process.spawn('redis-server')
|
152
|
+
end
|
153
|
+
|
154
|
+
#
|
155
|
+
# Starts the web server process.
|
156
|
+
#
|
157
|
+
# @return [Integer]
|
158
|
+
# The PID of the `puma` web server process.
|
159
|
+
#
|
160
|
+
def start_web_server
|
161
|
+
command = %w[puma -C ./config/puma.rb -e production]
|
162
|
+
command << '-b' << "tcp://#{options[:host]}:#{options[:port]}"
|
163
|
+
|
164
|
+
Process.spawn(app_env,*command)
|
165
|
+
end
|
166
|
+
|
167
|
+
#
|
168
|
+
# Starts the sidekiq background job process.
|
169
|
+
#
|
170
|
+
# @return [Integer]
|
171
|
+
# The PID of the `sidekiq` process.
|
172
|
+
#
|
173
|
+
def start_sidekiq
|
174
|
+
Process.spawn(app_env,"sidekiq -C ./config/sidekiq.yml -e production -r ./config/sidekiq.rb -r ./workers.rb")
|
175
|
+
end
|
176
|
+
|
177
|
+
#
|
178
|
+
# The environment variables Hash for the app processes.
|
179
|
+
#
|
180
|
+
# @return [Hash{String => String}]
|
181
|
+
# The env Hash to pass into the app processes.
|
182
|
+
#
|
183
|
+
def app_env
|
184
|
+
env = {}
|
185
|
+
|
186
|
+
if options[:db_uri]
|
187
|
+
env['DATABASE_URL'] = options[:db_uri]
|
188
|
+
elsif options[:db]
|
189
|
+
env['DATABASE_NAME'] = options[:db].to_s
|
190
|
+
end
|
191
|
+
|
192
|
+
return env
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# ronin-app - a local web app for Ronin.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
|
6
|
+
#
|
7
|
+
# ronin-app is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Affero General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# ronin-app 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 Affero General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Affero General Public License
|
18
|
+
# along with ronin-app. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'rack/utils'
|
22
|
+
|
23
|
+
module Ronin
|
24
|
+
module App
|
25
|
+
module Helpers
|
26
|
+
#
|
27
|
+
# HTML helper methods.
|
28
|
+
#
|
29
|
+
module HTML
|
30
|
+
#
|
31
|
+
# Renders a partial template.
|
32
|
+
#
|
33
|
+
# @param [Symbol] name
|
34
|
+
# The partial template name without the `_`.
|
35
|
+
#
|
36
|
+
# @param [Hash{Symbol => Object}] locals
|
37
|
+
# Additional local variables to pass to the partial.
|
38
|
+
#
|
39
|
+
def partial(name,**locals)
|
40
|
+
erb(:"_#{name}", layout: nil, locals: locals)
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Escapes the text as HTML text.
|
45
|
+
#
|
46
|
+
# @param [String] text
|
47
|
+
# The string to escape.
|
48
|
+
#
|
49
|
+
# @return [String]
|
50
|
+
# The HTML escaped string.
|
51
|
+
#
|
52
|
+
def h(text)
|
53
|
+
Rack::Utils.escape_html(text.to_s) if text
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
# Escapes the text as an HTML attribute value.
|
58
|
+
#
|
59
|
+
# @param [String] text
|
60
|
+
# The string to escape.
|
61
|
+
#
|
62
|
+
# @return [String]
|
63
|
+
# The escaped HTML attribute.
|
64
|
+
#
|
65
|
+
def hattr(text)
|
66
|
+
Rack::Utils.escape_path(text.to_s) if text
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# ronin-app - a local web app for Ronin.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
|
6
|
+
#
|
7
|
+
# ronin-app is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Affero General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# ronin-app 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 Affero General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Affero General Public License
|
18
|
+
# along with ronin-app. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
module Ronin
|
22
|
+
module App
|
23
|
+
# Path to `ronin-app` root directory.
|
24
|
+
#
|
25
|
+
# @api private
|
26
|
+
ROOT = File.expand_path(File.join(__dir__,'..','..','..'))
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# ronin-app - a local web app for Ronin.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
|
6
|
+
#
|
7
|
+
# ronin-app is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Affero General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# ronin-app 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 Affero General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Affero General Public License
|
18
|
+
# along with ronin-app. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'dry-schema'
|
22
|
+
require 'ronin/app/types'
|
23
|
+
|
24
|
+
require 'ronin/core/params/types'
|
25
|
+
|
26
|
+
module Ronin
|
27
|
+
module App
|
28
|
+
#
|
29
|
+
# Contains class methods for building dynamic dry-schemas.
|
30
|
+
#
|
31
|
+
module Schemas
|
32
|
+
#
|
33
|
+
# Builds a `Dry::Schema::Params` schema using a class'es defined params.
|
34
|
+
#
|
35
|
+
# @param [Hash{Symbol => Ronin::Core::Params::Param}] params
|
36
|
+
# The class'es params.
|
37
|
+
#
|
38
|
+
def self.ParamsSchema(params)
|
39
|
+
dsl = Dry::Schema::DSL.new(processor_type: Dry::Schema::Params)
|
40
|
+
|
41
|
+
params.each do |name,param|
|
42
|
+
schema_type = case param.type
|
43
|
+
when Ronin::Core::Params::Types::Enum
|
44
|
+
Types::String.enum(*param.type.values)
|
45
|
+
when Ronin::Core::Params::Types::Boolean
|
46
|
+
:bool
|
47
|
+
when Ronin::Core::Params::Types::Integer
|
48
|
+
:integer
|
49
|
+
when Ronin::Core::Params::Types::Float
|
50
|
+
:float
|
51
|
+
else
|
52
|
+
:string
|
53
|
+
end
|
54
|
+
|
55
|
+
if (param.required? && !param.has_default?)
|
56
|
+
dsl.required(name).filled(schema_type)
|
57
|
+
else
|
58
|
+
dsl.optional(name).maybe(schema_type)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
return dsl.call
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# ronin-app - a local web app for Ronin.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
|
6
|
+
#
|
7
|
+
# ronin-app is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Affero General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# ronin-app 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 Affero General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Affero General Public License
|
18
|
+
# along with ronin-app. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'dry/schema'
|
22
|
+
|
23
|
+
require 'ronin/app/schemas/params_schema'
|
24
|
+
|
25
|
+
module Ronin
|
26
|
+
module App
|
27
|
+
module Schemas
|
28
|
+
#
|
29
|
+
# Contains class methods for building dry-schemas for the `/payloads`
|
30
|
+
# routes.
|
31
|
+
#
|
32
|
+
module Payloads
|
33
|
+
#
|
34
|
+
# Builds a `Dry::Schema::Params` schema for the given payload class and
|
35
|
+
# for the `POST /payloads/.../build` route.
|
36
|
+
#
|
37
|
+
# @param [Class<Ronin::Payloads::Payload>] payload_class
|
38
|
+
# The payload class to build the schema for.
|
39
|
+
#
|
40
|
+
# @return [Dry::Schema::Params]
|
41
|
+
# The built schema.
|
42
|
+
#
|
43
|
+
def self.BuildSchema(payload_class)
|
44
|
+
# dynamically build the dry-schema based on the payload's params
|
45
|
+
params_schema = Schemas::ParamsSchema(payload_class.params)
|
46
|
+
|
47
|
+
return Dry::Schema::Params() do
|
48
|
+
unless payload_class.params.empty?
|
49
|
+
required(:params).hash(params_schema)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# ronin-app - a local web app for Ronin.
|
4
|
+
#
|
5
|
+
# Copyright (c) 2023-2024 Hal Brodigan (postmodern.mod3@gmail.com)
|
6
|
+
#
|
7
|
+
# ronin-app is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU Affero General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# ronin-app 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 Affero General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU Affero General Public License
|
18
|
+
# along with ronin-app. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'dry/schema'
|
22
|
+
|
23
|
+
require 'ronin/app/schemas/params_schema'
|
24
|
+
|
25
|
+
module Ronin
|
26
|
+
module App
|
27
|
+
module Schemas
|
28
|
+
module Payloads
|
29
|
+
#
|
30
|
+
# Contains class methods for building dry-schemas for the
|
31
|
+
# `/payloads/encoders` routes.
|
32
|
+
#
|
33
|
+
module Encoders
|
34
|
+
#
|
35
|
+
# Builds a `Dry::Schema::Params` schema for the given payload encoder
|
36
|
+
# class and for the `POST /payloads/encoders/encode...` route.
|
37
|
+
#
|
38
|
+
# @param [Class<Ronin::Payloads::Encoders::Encode>] encoder_class
|
39
|
+
# The payload encoder class to build the schema for.
|
40
|
+
#
|
41
|
+
# @return [Dry::Schema::Params]
|
42
|
+
# The built schema.
|
43
|
+
#
|
44
|
+
def self.EncodeSchema(encoder_class)
|
45
|
+
# dynamically encode the dry-schema based on the encoder's params
|
46
|
+
params_schema = Schemas::ParamsSchema(encoder_class.params)
|
47
|
+
|
48
|
+
return Dry::Schema::Params() do
|
49
|
+
required(:data).filled(:string)
|
50
|
+
|
51
|
+
unless encoder_class.params.empty?
|
52
|
+
required(:params).hash(params_schema)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|