Class: Pgsqlarbiter::Verdict
- Inherits:
-
Data
- Object
- Data
- Pgsqlarbiter::Verdict
- Defined in:
- lib/pgsqlarbiter/verdict.rb
Overview
Instance Attribute Summary collapse
-
#allowed ⇒ Boolean
(also: #allowed?)
readonly
truewhen the query passes all checks. -
#disallowed_functions ⇒ Array<String>
readonly
Functions called by the query that are not whitelisted.
-
#disallowed_tables ⇒ Array<String>
readonly
Tables referenced by the query that are not whitelisted.
-
#statement_type ⇒ Symbol
readonly
The query's actual statement type.
-
#statement_type_allowed ⇒ Boolean
(also: #statement_type_allowed?)
readonly
truewhen the statement type is in the whitelist.
Instance Method Summary collapse
-
#reasons ⇒ Array<String>
Human-readable denial reasons.
Instance Attribute Details
#allowed ⇒ Boolean (readonly) Also known as: allowed?
Returns true when the query passes all checks.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pgsqlarbiter/verdict.rb', line 21 Verdict = Data.define(:allowed, :statement_type_allowed, :statement_type, :disallowed_tables, :disallowed_functions) do alias_method :allowed?, :allowed alias_method :statement_type_allowed?, :statement_type_allowed # Human-readable denial reasons. Empty when the query is allowed. # # @return [Array<String>] frozen list of reason strings def reasons r = [] r << "statement type :#{statement_type} is not allowed" unless statement_type_allowed disallowed_tables.each { |t| r << "table #{t.inspect} is not allowed" } disallowed_functions.each { |f| r << "function #{f.inspect} is not allowed" } r.freeze end end |
#disallowed_functions ⇒ Array<String> (readonly)
Returns functions called by the query that are not whitelisted.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pgsqlarbiter/verdict.rb', line 21 Verdict = Data.define(:allowed, :statement_type_allowed, :statement_type, :disallowed_tables, :disallowed_functions) do alias_method :allowed?, :allowed alias_method :statement_type_allowed?, :statement_type_allowed # Human-readable denial reasons. Empty when the query is allowed. # # @return [Array<String>] frozen list of reason strings def reasons r = [] r << "statement type :#{statement_type} is not allowed" unless statement_type_allowed disallowed_tables.each { |t| r << "table #{t.inspect} is not allowed" } disallowed_functions.each { |f| r << "function #{f.inspect} is not allowed" } r.freeze end end |
#disallowed_tables ⇒ Array<String> (readonly)
Returns tables referenced by the query that are not whitelisted.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pgsqlarbiter/verdict.rb', line 21 Verdict = Data.define(:allowed, :statement_type_allowed, :statement_type, :disallowed_tables, :disallowed_functions) do alias_method :allowed?, :allowed alias_method :statement_type_allowed?, :statement_type_allowed # Human-readable denial reasons. Empty when the query is allowed. # # @return [Array<String>] frozen list of reason strings def reasons r = [] r << "statement type :#{statement_type} is not allowed" unless statement_type_allowed disallowed_tables.each { |t| r << "table #{t.inspect} is not allowed" } disallowed_functions.each { |f| r << "function #{f.inspect} is not allowed" } r.freeze end end |
#statement_type ⇒ Symbol (readonly)
Returns the query's actual statement type.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pgsqlarbiter/verdict.rb', line 21 Verdict = Data.define(:allowed, :statement_type_allowed, :statement_type, :disallowed_tables, :disallowed_functions) do alias_method :allowed?, :allowed alias_method :statement_type_allowed?, :statement_type_allowed # Human-readable denial reasons. Empty when the query is allowed. # # @return [Array<String>] frozen list of reason strings def reasons r = [] r << "statement type :#{statement_type} is not allowed" unless statement_type_allowed disallowed_tables.each { |t| r << "table #{t.inspect} is not allowed" } disallowed_functions.each { |f| r << "function #{f.inspect} is not allowed" } r.freeze end end |
#statement_type_allowed ⇒ Boolean (readonly) Also known as: statement_type_allowed?
Returns true when the statement type is in the whitelist.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pgsqlarbiter/verdict.rb', line 21 Verdict = Data.define(:allowed, :statement_type_allowed, :statement_type, :disallowed_tables, :disallowed_functions) do alias_method :allowed?, :allowed alias_method :statement_type_allowed?, :statement_type_allowed # Human-readable denial reasons. Empty when the query is allowed. # # @return [Array<String>] frozen list of reason strings def reasons r = [] r << "statement type :#{statement_type} is not allowed" unless statement_type_allowed disallowed_tables.each { |t| r << "table #{t.inspect} is not allowed" } disallowed_functions.each { |f| r << "function #{f.inspect} is not allowed" } r.freeze end end |
Instance Method Details
#reasons ⇒ Array<String>
Human-readable denial reasons. Empty when the query is allowed.
29 30 31 32 33 34 35 |
# File 'lib/pgsqlarbiter/verdict.rb', line 29 def reasons r = [] r << "statement type :#{statement_type} is not allowed" unless statement_type_allowed disallowed_tables.each { |t| r << "table #{t.inspect} is not allowed" } disallowed_functions.each { |f| r << "function #{f.inspect} is not allowed" } r.freeze end |