dbviewer 0.9.0 → 0.9.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/lib/dbviewer/security/access_control.rb +0 -8
- data/lib/dbviewer/version.rb +1 -1
- data/lib/dbviewer.rb +3 -71
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 897715943af7ce5d339aebb00b03bc13e1abc728c5e09d9615ec7189555cf014
|
4
|
+
data.tar.gz: 3ee632c6e1a6cc9fe5e5df08277520a0ea6a705e20a84bcab1756acd27a0f031
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 010a246eb09d2a6841c01bb3b87553b89ed4050a8781572a5b016894b208688d495744a1539636e8655c6ea7778449a2d0b9c0e204b0be5d7b68c2ee6ac883e3
|
7
|
+
data.tar.gz: e4142876a0867ebc55655469e8b85f240cc5a48b9b45ffb1d5bec89ab38939b95e996dcba1fa9b2555658cd1276415d24d14ae57ad98554b4f1a852beb8e0632
|
@@ -75,14 +75,6 @@ module Dbviewer
|
|
75
75
|
"Access denied: Table access is restricted"
|
76
76
|
end
|
77
77
|
end
|
78
|
-
|
79
|
-
private
|
80
|
-
|
81
|
-
# For backwards compatibility, we keep this method but delegate to SqlParser
|
82
|
-
# @deprecated Use SqlParser.extract_table_names directly
|
83
|
-
def extract_table_names_from_sql(sql)
|
84
|
-
@sql_parser.extract_table_names(sql)
|
85
|
-
end
|
86
78
|
end
|
87
79
|
end
|
88
80
|
end
|
data/lib/dbviewer/version.rb
CHANGED
data/lib/dbviewer.rb
CHANGED
@@ -84,26 +84,6 @@ module Dbviewer
|
|
84
84
|
@configuration = Configuration.new
|
85
85
|
end
|
86
86
|
|
87
|
-
# This class method will be called by the engine when it's appropriate
|
88
|
-
def setup
|
89
|
-
configure_query_logger
|
90
|
-
# Database connections will be validated when first accessed
|
91
|
-
Rails.logger.info "DBViewer: Initialized successfully (database connections will be validated on first access)"
|
92
|
-
end
|
93
|
-
|
94
|
-
# Validate database connections on-demand (called when first accessing DBViewer)
|
95
|
-
def validate_connections!
|
96
|
-
connection_errors = configuration.database_connections.filter_map do |key, config|
|
97
|
-
validate_single_connection(key, config)
|
98
|
-
end
|
99
|
-
|
100
|
-
if connection_errors.length == configuration.database_connections.length
|
101
|
-
raise "DBViewer could not connect to any configured database. Please check your database configuration."
|
102
|
-
end
|
103
|
-
|
104
|
-
connection_errors
|
105
|
-
end
|
106
|
-
|
107
87
|
# Configure PII masking rules using a block
|
108
88
|
#
|
109
89
|
# @example
|
@@ -120,62 +100,14 @@ module Dbviewer
|
|
120
100
|
yield(PiiConfigurator.new(configuration)) if block_given?
|
121
101
|
end
|
122
102
|
|
123
|
-
|
124
|
-
|
125
|
-
# Configure the query logger with current configuration settings
|
126
|
-
def configure_query_logger
|
103
|
+
# This class method will be called by the engine when it's appropriate
|
104
|
+
def setup
|
127
105
|
Dbviewer::Query::Logger.configure(
|
128
106
|
enable_query_logging: configuration.enable_query_logging,
|
129
107
|
query_logging_mode: configuration.query_logging_mode
|
130
108
|
)
|
131
|
-
end
|
132
|
-
|
133
|
-
# Validate a single database connection
|
134
|
-
# @param key [Symbol] The connection key
|
135
|
-
# @param config [Hash] The connection configuration
|
136
|
-
# @return [Hash, nil] Error hash if validation failed, nil if successful
|
137
|
-
def validate_single_connection(key, config)
|
138
|
-
connection_class = resolve_connection_class(config)
|
139
|
-
return { key: key, error: "No valid connection configuration found for #{key}" } unless connection_class
|
140
|
-
|
141
|
-
test_connection(connection_class, config, key)
|
142
|
-
store_resolved_connection(config, connection_class)
|
143
|
-
nil
|
144
|
-
rescue => e
|
145
|
-
Rails.logger.error "DBViewer could not connect to #{config[:name] || key.to_s} database: #{e.message}"
|
146
|
-
{ key: key, error: e.message }
|
147
|
-
end
|
148
|
-
|
149
|
-
# Resolve the connection class from configuration
|
150
|
-
# @param config [Hash] The connection configuration
|
151
|
-
# @return [Class, nil] The resolved connection class or nil
|
152
|
-
def resolve_connection_class(config)
|
153
|
-
return config[:connection] if config[:connection]
|
154
|
-
return nil unless config[:connection_class].is_a?(String)
|
155
|
-
|
156
|
-
begin
|
157
|
-
config[:connection_class].constantize
|
158
|
-
rescue NameError => e
|
159
|
-
Rails.logger.warn "DBViewer could not load connection class #{config[:connection_class]}: #{e.message}"
|
160
|
-
nil
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
# Test the database connection
|
165
|
-
# @param connection_class [Class] The connection class
|
166
|
-
# @param config [Hash] The connection configuration
|
167
|
-
# @param key [Symbol] The connection key
|
168
|
-
def test_connection(connection_class, config, key)
|
169
|
-
connection = connection_class.connection
|
170
|
-
adapter_name = connection.adapter_name
|
171
|
-
Rails.logger.info "DBViewer successfully connected to #{config[:name] || key.to_s} database (#{adapter_name})"
|
172
|
-
end
|
173
109
|
|
174
|
-
|
175
|
-
# @param config [Hash] The connection configuration
|
176
|
-
# @param connection_class [Class] The resolved connection class
|
177
|
-
def store_resolved_connection(config, connection_class)
|
178
|
-
config[:connection] = connection_class
|
110
|
+
Rails.logger.info "DBViewer: Initialized successfully"
|
179
111
|
end
|
180
112
|
end
|
181
113
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbviewer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wailan Tirajoh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-06-
|
11
|
+
date: 2025-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|