query_console 0.1.0 → 0.2.1
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/README.md +204 -28
- data/app/controllers/query_console/application_controller.rb +6 -3
- data/app/controllers/query_console/explain_controller.rb +47 -0
- data/app/controllers/query_console/queries_controller.rb +4 -1
- data/app/controllers/query_console/schema_controller.rb +32 -0
- data/app/javascript/query_console/controllers/editor_controller.js +182 -45
- data/app/services/query_console/audit_logger.rb +29 -3
- data/app/services/query_console/explain_runner.rb +137 -0
- data/app/services/query_console/runner.rb +56 -3
- data/app/services/query_console/schema_introspector.rb +244 -0
- data/app/services/query_console/sql_limiter.rb +10 -0
- data/app/services/query_console/sql_validator.rb +33 -6
- data/app/views/query_console/explain/_results.html.erb +89 -0
- data/app/views/query_console/queries/_results.html.erb +40 -4
- data/app/views/query_console/queries/new.html.erb +843 -328
- data/config/importmap.rb +8 -0
- data/config/routes.rb +5 -0
- data/lib/query_console/configuration.rb +21 -1
- data/lib/query_console/version.rb +1 -1
- metadata +16 -14
data/config/importmap.rb
CHANGED
|
@@ -6,6 +6,14 @@ pin "@hotwired/turbo-rails", to: "turbo.min.js"
|
|
|
6
6
|
pin "@hotwired/stimulus", to: "stimulus.min.js"
|
|
7
7
|
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
|
|
8
8
|
|
|
9
|
+
# Pin CodeMirror 6 from CDN
|
|
10
|
+
pin "@codemirror/state", to: "https://cdn.jsdelivr.net/npm/@codemirror/state@6.4.0/+esm"
|
|
11
|
+
pin "@codemirror/view", to: "https://cdn.jsdelivr.net/npm/@codemirror/view@6.23.0/+esm"
|
|
12
|
+
pin "@codemirror/language", to: "https://cdn.jsdelivr.net/npm/@codemirror/language@6.10.0/+esm"
|
|
13
|
+
pin "@codemirror/commands", to: "https://cdn.jsdelivr.net/npm/@codemirror/commands@6.3.3/+esm"
|
|
14
|
+
pin "@codemirror/lang-sql", to: "https://cdn.jsdelivr.net/npm/@codemirror/lang-sql@6.6.0/+esm"
|
|
15
|
+
pin "@codemirror/autocomplete", to: "https://cdn.jsdelivr.net/npm/@codemirror/autocomplete@6.13.0/+esm"
|
|
16
|
+
|
|
9
17
|
# Pin application and controllers
|
|
10
18
|
pin "query_console/application", to: "query_console/application.js"
|
|
11
19
|
pin_all_from File.expand_path("../app/javascript/controllers/query_console", __dir__),
|
data/config/routes.rb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
QueryConsole::Engine.routes.draw do
|
|
2
2
|
root to: "queries#new"
|
|
3
3
|
post "run", to: "queries#run"
|
|
4
|
+
post "explain", to: "explain#create"
|
|
5
|
+
|
|
6
|
+
# Schema introspection endpoints
|
|
7
|
+
get "schema/tables", to: "schema#tables"
|
|
8
|
+
get "schema/tables/:name", to: "schema#show", as: :schema_table
|
|
4
9
|
end
|
|
@@ -6,7 +6,16 @@ module QueryConsole
|
|
|
6
6
|
:authorize,
|
|
7
7
|
:current_actor,
|
|
8
8
|
:forbidden_keywords,
|
|
9
|
-
:allowed_starts_with
|
|
9
|
+
:allowed_starts_with,
|
|
10
|
+
:enable_explain,
|
|
11
|
+
:enable_explain_analyze,
|
|
12
|
+
:enable_dml,
|
|
13
|
+
:schema_explorer,
|
|
14
|
+
:schema_cache_seconds,
|
|
15
|
+
:schema_table_denylist,
|
|
16
|
+
:schema_allowlist,
|
|
17
|
+
:enable_syntax_highlighting,
|
|
18
|
+
:enable_autocomplete
|
|
10
19
|
|
|
11
20
|
def initialize
|
|
12
21
|
@enabled_environments = ["development"]
|
|
@@ -20,6 +29,17 @@ module QueryConsole
|
|
|
20
29
|
shutdown backup restore transaction commit rollback
|
|
21
30
|
]
|
|
22
31
|
@allowed_starts_with = %w[select with]
|
|
32
|
+
|
|
33
|
+
# v0.2.0 additions
|
|
34
|
+
@enable_explain = true
|
|
35
|
+
@enable_explain_analyze = false # ANALYZE can be expensive, disabled by default
|
|
36
|
+
@enable_dml = false # DML queries disabled by default for safety
|
|
37
|
+
@schema_explorer = true
|
|
38
|
+
@schema_cache_seconds = 60
|
|
39
|
+
@schema_table_denylist = ["schema_migrations", "ar_internal_metadata"]
|
|
40
|
+
@schema_allowlist = [] # empty means all tables allowed (except denylist)
|
|
41
|
+
@enable_syntax_highlighting = true
|
|
42
|
+
@enable_autocomplete = true
|
|
23
43
|
end
|
|
24
44
|
end
|
|
25
45
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: query_console
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Johnson Gnanasekar
|
|
@@ -13,9 +13,6 @@ dependencies:
|
|
|
13
13
|
name: rails
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
|
-
- - "~>"
|
|
17
|
-
- !ruby/object:Gem::Version
|
|
18
|
-
version: '7.0'
|
|
19
16
|
- - ">="
|
|
20
17
|
- !ruby/object:Gem::Version
|
|
21
18
|
version: 7.0.0
|
|
@@ -23,9 +20,6 @@ dependencies:
|
|
|
23
20
|
prerelease: false
|
|
24
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
22
|
requirements:
|
|
26
|
-
- - "~>"
|
|
27
|
-
- !ruby/object:Gem::Version
|
|
28
|
-
version: '7.0'
|
|
29
23
|
- - ">="
|
|
30
24
|
- !ruby/object:Gem::Version
|
|
31
25
|
version: 7.0.0
|
|
@@ -77,30 +71,32 @@ dependencies:
|
|
|
77
71
|
requirements:
|
|
78
72
|
- - "~>"
|
|
79
73
|
- !ruby/object:Gem::Version
|
|
80
|
-
version: '
|
|
74
|
+
version: '7.0'
|
|
81
75
|
type: :development
|
|
82
76
|
prerelease: false
|
|
83
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
84
78
|
requirements:
|
|
85
79
|
- - "~>"
|
|
86
80
|
- !ruby/object:Gem::Version
|
|
87
|
-
version: '
|
|
81
|
+
version: '7.0'
|
|
88
82
|
- !ruby/object:Gem::Dependency
|
|
89
83
|
name: sqlite3
|
|
90
84
|
requirement: !ruby/object:Gem::Requirement
|
|
91
85
|
requirements:
|
|
92
86
|
- - "~>"
|
|
93
87
|
- !ruby/object:Gem::Version
|
|
94
|
-
version: '
|
|
88
|
+
version: '2.0'
|
|
95
89
|
type: :development
|
|
96
90
|
prerelease: false
|
|
97
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
98
92
|
requirements:
|
|
99
93
|
- - "~>"
|
|
100
94
|
- !ruby/object:Gem::Version
|
|
101
|
-
version: '
|
|
102
|
-
description: A Rails engine
|
|
103
|
-
|
|
95
|
+
version: '2.0'
|
|
96
|
+
description: 'A Rails engine providing a web-based SQL query console with security-first
|
|
97
|
+
design: read-only by default, optional DML (INSERT/UPDATE/DELETE) with confirmation
|
|
98
|
+
dialogs, flexible authorization, comprehensive audit logging, and query execution
|
|
99
|
+
plans.'
|
|
104
100
|
email:
|
|
105
101
|
- johnson@example.com
|
|
106
102
|
executables: []
|
|
@@ -111,15 +107,20 @@ files:
|
|
|
111
107
|
- README.md
|
|
112
108
|
- Rakefile
|
|
113
109
|
- app/controllers/query_console/application_controller.rb
|
|
110
|
+
- app/controllers/query_console/explain_controller.rb
|
|
114
111
|
- app/controllers/query_console/queries_controller.rb
|
|
112
|
+
- app/controllers/query_console/schema_controller.rb
|
|
115
113
|
- app/javascript/query_console/application.js
|
|
116
114
|
- app/javascript/query_console/controllers/collapsible_controller.js
|
|
117
115
|
- app/javascript/query_console/controllers/editor_controller.js
|
|
118
116
|
- app/javascript/query_console/controllers/history_controller.js
|
|
119
117
|
- app/services/query_console/audit_logger.rb
|
|
118
|
+
- app/services/query_console/explain_runner.rb
|
|
120
119
|
- app/services/query_console/runner.rb
|
|
120
|
+
- app/services/query_console/schema_introspector.rb
|
|
121
121
|
- app/services/query_console/sql_limiter.rb
|
|
122
122
|
- app/services/query_console/sql_validator.rb
|
|
123
|
+
- app/views/query_console/explain/_results.html.erb
|
|
123
124
|
- app/views/query_console/queries/_results.html.erb
|
|
124
125
|
- app/views/query_console/queries/new.html.erb
|
|
125
126
|
- config/importmap.rb
|
|
@@ -155,5 +156,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
155
156
|
requirements: []
|
|
156
157
|
rubygems_version: 3.6.7
|
|
157
158
|
specification_version: 4
|
|
158
|
-
summary:
|
|
159
|
+
summary: Secure, mountable Rails SQL console with read-only enforcement and optional
|
|
160
|
+
DML support
|
|
159
161
|
test_files: []
|