mikras_utils 0.11.0 → 0.12.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d40acc7f4c2837481e47b7f46cc1dbcb79af1259fbafc8ad48284592da8f585e
4
- data.tar.gz: 7d1a196b2b3a56394c7359877386eb4fd4cd7c5e54867754c2b8d94d9f51582a
3
+ metadata.gz: a44bca0af7912d71f10ef67bcf012cc512c2ccd012890e4ceb4eacf40551405c
4
+ data.tar.gz: 322c7e7b028af1c29285f5d0724957d278d4311726d238282c6f7cbb74283ce2
5
5
  SHA512:
6
- metadata.gz: 4134754e87c32513569e8f2050da0fb0ce9518cb0ab17a105c84e48a55449a5de59389a0e5a711e6076fb6228f8d471dbe03b3ff1a1a665b63b242787737a7f8
7
- data.tar.gz: f84cbcdf08dab513d0dcc8a129e122444ccf46b6e5018012ce8f944660b48d2346f80e4b8aa2f3e4c4f72d9210e8e5c55176de5cd2b17659a4b6e5aaa9087cb1
6
+ metadata.gz: d8df11f86fad23e4cdeb3c4c61f46f7e49fd05289adc0ed27224e28d7da5e63224e5c7225a434fbbbe81f3f3f3732119cf3b7bfa19e329d9a46af67e754761cb
7
+ data.tar.gz: e283d2a1591f25d52e45156b53c45556b20e434ac931ea29914ad31eb6d0540a4473941a4de358cfee9031106a7aef6f07a815b7050891f9eccf75afe84f172c
@@ -66,6 +66,17 @@ module MkAcl
66
66
  end
67
67
  }
68
68
 
69
+ # Set mutation to nil select/attach/detach actions
70
+ spec.tables.each { |table|
71
+ table.actions.each { |name, action|
72
+ if %w(select attach detach).include?(name)
73
+ action.rules.each { |rule|
74
+ rule.mutation = nil
75
+ }
76
+ end
77
+ }
78
+ }
79
+
69
80
  # Resolve domains
70
81
  spec.tables.select(&:acl).each { |t| resolve_domain(t) }
71
82
 
@@ -58,10 +58,11 @@ module MkAcl
58
58
  puts
59
59
 
60
60
  action.rules.each { |rule|
61
- fields = %w(roles filter assert fields tables ordinal)
61
+ fields = %w(roles filter assert mutation fields tables ordinal)
62
62
  values = fields.map { |field| conn.quote_value(rule.send(field.to_sym), elem_type: :text) }
63
63
  puts %(
64
- insert into acl_portal.acl_rules (acl_action_id, roles, filter, assert, fields, tables, ordinal)
64
+ insert into acl_portal.acl_rules (
65
+ acl_action_id, roles, filter, assert, mutation, fields, tables, ordinal)
65
66
  values (:action_id, #{values.join(', ')});
66
67
  ).align
67
68
  puts
@@ -59,6 +59,7 @@ module MkAcl
59
59
  constrain?(action_name, :insert, :select, :update, :delete, :attach, :detach) or
60
60
  error "Illegal action '#{action_name}'"
61
61
 
62
+ # real_action_names break :attach into both :attach and :detach
62
63
  for real_action_name in (action_name == :attach ? [:attach, :detach] : [action_name])
63
64
  constrain?(entries, String, Array, Hash) or
64
65
  error "Illegal value for #{action_name} entry '#{entries}'"
@@ -72,6 +73,7 @@ module MkAcl
72
73
  when String
73
74
  entries = [{ roles: entries }]
74
75
  when Array
76
+ # Arrays can't specify mutations (for now)
75
77
  entries.reject! { |element|
76
78
  timestamps = element.delete(:timestamps) and parse_timestamps(action, timestamps)
77
79
  }
@@ -127,6 +129,7 @@ module MkAcl
127
129
  when :roles; rule.roles = norm_array(value)
128
130
  when :filter; rule.filter = norm_value(value)
129
131
  when :assert; rule.assert = norm_value(value)
132
+ when :mutation; rule.mutation = value.nil? ? nil : norm_value(value)
130
133
  when :fields; rule.fields = value.nil? ? nil : norm_array(value)
131
134
  when :tables; rule.tables = norm_array(value)
132
135
  else
@@ -140,4 +143,27 @@ module MkAcl
140
143
  end
141
144
  end
142
145
  end
146
+
147
+ #def declare_record(name, array_arg = nil, &record_
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
143
169
 
@@ -1,5 +1,7 @@
1
1
 
2
2
  module MkAcl
3
+ DEFAULT_MUTATION = "app_portal.mutate"
4
+
3
5
  class Spec
4
6
  # Source SPEC file. Only for informational purposes
5
7
  attr_reader :file
@@ -204,9 +206,9 @@ module MkAcl
204
206
  def to_s() = watch
205
207
 
206
208
  def dump
207
- puts "watch: #{watch}"
208
- puts "watch: #{assign}"
209
- puts "stamp: #{stamp}"
209
+ puts "watch: #{watch}" if watch
210
+ puts "assign: #{assign}" if assign
211
+ puts "stamp: #{stamp}" if stamp
210
212
  end
211
213
  end
212
214
 
@@ -218,6 +220,7 @@ module MkAcl
218
220
  attr_accessor :roles # Roles that this rule applies to
219
221
  attr_accessor :filter # Goes into the postgres policy, may be nil
220
222
  attr_accessor :assert # Goes into the postgres trigger, may be nil
223
+ attr_accessor :mutation # Mutation function to use, may be nil. Default app_portal.mutate()
221
224
  attr_accessor :fields # Only used for insert and update, nil otherwise
222
225
  attr_accessor :tables # Only used for attach and detach, nil otherwise
223
226
  attr_reader :ordinal
@@ -234,6 +237,7 @@ module MkAcl
234
237
  @roles = []
235
238
  @filter = nil
236
239
  @assert = nil
240
+ @mutation = DEFAULT_MUTATION
237
241
  @fields = %w(insert update).include?(action.name) ? [] : nil
238
242
  @tables = %w(attach).include?(action.name) ? [] : nil
239
243
 
@@ -244,6 +248,8 @@ module MkAcl
244
248
  puts "roles: [#{roles.join(' ')}]"
245
249
  puts "filter: #{filter}" if filter
246
250
  puts "assert: #{assert}" if assert
251
+ puts "mutation: #{mutation || 'nil'}" \
252
+ if %w(insert update delete).include?(name) && mutation != DEFAULT_MUTATION
247
253
  puts "fields: [#{fields.join(' ')}]" if fields && !fields.empty?
248
254
  puts "tables: [#{tables.join(' ')}]" if tables && !tables.empty?
249
255
  puts "ordinal: #{ordinal}"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MikrasUtils
4
- VERSION = "0.11.0"
4
+ VERSION = "0.12.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mikras_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claus Rasmussen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-03-06 00:00:00.000000000 Z
11
+ date: 2025-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg_conn