Class: Dbviewer::Configuration
- Inherits:
-
Object
- Object
- Dbviewer::Configuration
- Defined in:
- lib/dbviewer/configuration.rb
Overview
Configuration class for DBViewer engine settings
Instance Attribute Summary collapse
-
#access_control_mode ⇒ Object
Access control mode: :whitelist, :blacklist, or :none :whitelist - only allowed_tables are accessible (most secure) :blacklist - all tables except blocked_tables are accessible :none - all tables accessible (current behavior).
-
#admin_credentials ⇒ Object
Admin access credentials hash with :username and :password keys.
-
#allowed_tables ⇒ Object
Table access control - whitelist approach (more secure) Only tables listed here will be accessible.
-
#blocked_columns ⇒ Object
Column access control - hide sensitive columns }.
-
#blocked_tables ⇒ Object
Table access control - blacklist approach Tables listed here will be blocked from access.
-
#cache_expiry ⇒ Object
Cache expiration time in seconds.
-
#current_connection ⇒ Object
The key of the current active connection.
-
#custom_pii_masks ⇒ Object
Custom PII masking blocks }.
-
#database_connections ⇒ Object
Multiple database connections configuration }.
-
#default_order_column ⇒ Object
Default column to order table details by (e.g., ‘updated_at’).
-
#default_per_page ⇒ Object
Default number of records per page.
-
#disabled ⇒ Object
Completely disable DBViewer access when set to true When enabled, all DBViewer routes will return 404 responses.
-
#enable_data_export ⇒ Object
Allow downloading of data in various formats.
-
#enable_pii_masking ⇒ Object
Enable/disable PII masking globally.
-
#enable_query_logging ⇒ Object
Enable or disable query logging completely.
-
#enable_record_creation ⇒ Object
Enable or disable record creation functionality.
-
#enable_record_deletion ⇒ Object
Enable or disable record deletion functionality.
-
#enable_record_editing ⇒ Object
Enable or disable record editing functionality.
-
#enforce_parameterized_queries ⇒ Object
Enforce parameterized queries when possible.
-
#enhanced_sql_protection ⇒ Object
Enhanced SQL injection detection patterns.
-
#log_queries ⇒ Object
Enable comprehensive security logging for all database operations.
-
#log_security_events ⇒ Object
Log security threats and blocked queries.
-
#max_memory_queries ⇒ Object
Maximum number of queries to keep in memory.
-
#max_query_length ⇒ Object
Maximum SQL query length allowed.
-
#max_records ⇒ Object
Maximum number of records to return in any query.
-
#max_security_events ⇒ Object
Maximum number of security events to keep in memory.
-
#per_page_options ⇒ Object
Default pagination options.
-
#pii_rules ⇒ Object
PII (Personally Identifiable Information) masking configuration Hash of table.column => masking rule }.
-
#query_log_path ⇒ Object
Path for query log file when in :file mode.
-
#query_logging_mode ⇒ Object
Query logging storage mode (:memory or :file).
-
#query_timeout ⇒ Object
Timeout for SQL queries in seconds.
-
#validate_connections_on_startup ⇒ Object
Whether to validate database connections during application startup Set to false in production/CI environments to avoid startup failures.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/dbviewer/configuration.rb', line 129 def initialize @per_page_options = [ 10, 20, 50, 100 ] @default_per_page = 20 @max_records = 10000 @max_query_length = 10000 @cache_expiry = 300 @enable_data_export = false @enable_record_deletion = true @enable_record_editing = true @enable_record_creation = true @query_timeout = 30 @query_logging_mode = :memory @query_log_path = "log/dbviewer.log" @max_memory_queries = 1000 @enable_query_logging = true @admin_credentials = nil @default_order_column = "updated_at" @validate_connections_on_startup = false # Default to false for safer deployments @disabled = false # Default to false - DBViewer is enabled by default @database_connections = { default: { connection_class: "ActiveRecord::Base", name: "Default Database" } } @current_connection = :default @pii_rules = {} @enable_pii_masking = true @custom_pii_masks = {} # Initialize access control settings @allowed_tables = [] @blocked_tables = [] @blocked_columns = {} @access_control_mode = :none # Default to current behavior # Initialize security settings @log_queries = true @log_security_events = true @enhanced_sql_protection = true @enforce_parameterized_queries = false @max_security_events = 1000 end |
Instance Attribute Details
#access_control_mode ⇒ Object
Access control mode: :whitelist, :blacklist, or :none :whitelist - only allowed_tables are accessible (most secure) :blacklist - all tables except blocked_tables are accessible :none - all tables accessible (current behavior)
101 102 103 |
# File 'lib/dbviewer/configuration.rb', line 101 def access_control_mode @access_control_mode end |
#admin_credentials ⇒ Object
Admin access credentials hash with :username and :password keys
39 40 41 |
# File 'lib/dbviewer/configuration.rb', line 39 def admin_credentials @admin_credentials end |
#allowed_tables ⇒ Object
Table access control - whitelist approach (more secure) Only tables listed here will be accessible
83 84 85 |
# File 'lib/dbviewer/configuration.rb', line 83 def allowed_tables @allowed_tables end |
#blocked_columns ⇒ Object
Column access control - hide sensitive columns }
95 96 97 |
# File 'lib/dbviewer/configuration.rb', line 95 def blocked_columns @blocked_columns end |
#blocked_tables ⇒ Object
Table access control - blacklist approach Tables listed here will be blocked from access
88 89 90 |
# File 'lib/dbviewer/configuration.rb', line 88 def blocked_tables @blocked_tables end |
#cache_expiry ⇒ Object
Cache expiration time in seconds
17 18 19 |
# File 'lib/dbviewer/configuration.rb', line 17 def cache_expiry @cache_expiry end |
#current_connection ⇒ Object
The key of the current active connection
52 53 54 |
# File 'lib/dbviewer/configuration.rb', line 52 def current_connection @current_connection end |
#custom_pii_masks ⇒ Object
Custom PII masking blocks }
78 79 80 |
# File 'lib/dbviewer/configuration.rb', line 78 def custom_pii_masks @custom_pii_masks end |
#database_connections ⇒ Object
Multiple database connections configuration }
49 50 51 |
# File 'lib/dbviewer/configuration.rb', line 49 def database_connections @database_connections end |
#default_order_column ⇒ Object
Default column to order table details by (e.g., ‘updated_at’)
42 43 44 |
# File 'lib/dbviewer/configuration.rb', line 42 def default_order_column @default_order_column end |
#default_per_page ⇒ Object
Default number of records per page
8 9 10 |
# File 'lib/dbviewer/configuration.rb', line 8 def default_per_page @default_per_page end |
#disabled ⇒ Object
Completely disable DBViewer access when set to true When enabled, all DBViewer routes will return 404 responses
60 61 62 |
# File 'lib/dbviewer/configuration.rb', line 60 def disabled @disabled end |
#enable_data_export ⇒ Object
Allow downloading of data in various formats
20 21 22 |
# File 'lib/dbviewer/configuration.rb', line 20 def enable_data_export @enable_data_export end |
#enable_pii_masking ⇒ Object
Enable/disable PII masking globally
72 73 74 |
# File 'lib/dbviewer/configuration.rb', line 72 def enable_pii_masking @enable_pii_masking end |
#enable_query_logging ⇒ Object
Enable or disable query logging completely
35 36 37 |
# File 'lib/dbviewer/configuration.rb', line 35 def enable_query_logging @enable_query_logging end |
#enable_record_creation ⇒ Object
Enable or disable record creation functionality
127 128 129 |
# File 'lib/dbviewer/configuration.rb', line 127 def enable_record_creation @enable_record_creation end |
#enable_record_deletion ⇒ Object
Enable or disable record deletion functionality
121 122 123 |
# File 'lib/dbviewer/configuration.rb', line 121 def enable_record_deletion @enable_record_deletion end |
#enable_record_editing ⇒ Object
Enable or disable record editing functionality
124 125 126 |
# File 'lib/dbviewer/configuration.rb', line 124 def enable_record_editing @enable_record_editing end |
#enforce_parameterized_queries ⇒ Object
Enforce parameterized queries when possible
115 116 117 |
# File 'lib/dbviewer/configuration.rb', line 115 def enforce_parameterized_queries @enforce_parameterized_queries end |
#enhanced_sql_protection ⇒ Object
Enhanced SQL injection detection patterns
112 113 114 |
# File 'lib/dbviewer/configuration.rb', line 112 def enhanced_sql_protection @enhanced_sql_protection end |
#log_queries ⇒ Object
Enable comprehensive security logging for all database operations
106 107 108 |
# File 'lib/dbviewer/configuration.rb', line 106 def log_queries @log_queries end |
#log_security_events ⇒ Object
Log security threats and blocked queries
109 110 111 |
# File 'lib/dbviewer/configuration.rb', line 109 def log_security_events @log_security_events end |
#max_memory_queries ⇒ Object
Maximum number of queries to keep in memory
32 33 34 |
# File 'lib/dbviewer/configuration.rb', line 32 def max_memory_queries @max_memory_queries end |
#max_query_length ⇒ Object
Maximum SQL query length allowed
14 15 16 |
# File 'lib/dbviewer/configuration.rb', line 14 def max_query_length @max_query_length end |
#max_records ⇒ Object
Maximum number of records to return in any query
11 12 13 |
# File 'lib/dbviewer/configuration.rb', line 11 def max_records @max_records end |
#max_security_events ⇒ Object
Maximum number of security events to keep in memory
118 119 120 |
# File 'lib/dbviewer/configuration.rb', line 118 def max_security_events @max_security_events end |
#per_page_options ⇒ Object
Default pagination options
5 6 7 |
# File 'lib/dbviewer/configuration.rb', line 5 def @per_page_options end |
#pii_rules ⇒ Object
PII (Personally Identifiable Information) masking configuration Hash of table.column => masking rule }
69 70 71 |
# File 'lib/dbviewer/configuration.rb', line 69 def pii_rules @pii_rules end |
#query_log_path ⇒ Object
Path for query log file when in :file mode
29 30 31 |
# File 'lib/dbviewer/configuration.rb', line 29 def query_log_path @query_log_path end |
#query_logging_mode ⇒ Object
Query logging storage mode (:memory or :file)
26 27 28 |
# File 'lib/dbviewer/configuration.rb', line 26 def query_logging_mode @query_logging_mode end |
#query_timeout ⇒ Object
Timeout for SQL queries in seconds
23 24 25 |
# File 'lib/dbviewer/configuration.rb', line 23 def query_timeout @query_timeout end |
#validate_connections_on_startup ⇒ Object
Whether to validate database connections during application startup Set to false in production/CI environments to avoid startup failures
56 57 58 |
# File 'lib/dbviewer/configuration.rb', line 56 def validate_connections_on_startup @validate_connections_on_startup end |