@@ -187,8 +187,6 @@ def update_policy(self, sec, ptype, old_rule, new_rule):
187
187
188
188
return True
189
189
190
-
191
-
192
190
def update_policies (self , sec , ptype , old_rules , new_rules ):
193
191
"""update policy rules from the model using update_policy for each rule.
194
192
If any update fails, roll back all changes."""
@@ -212,8 +210,6 @@ def update_policies(self, sec, ptype, old_rules, new_rules):
212
210
213
211
return True
214
212
215
-
216
-
217
213
def remove_policy (self , sec , ptype , rule ):
218
214
"""removes a policy rule from the model."""
219
215
if not self .has_policy (sec , ptype , rule ):
@@ -229,15 +225,13 @@ def remove_policy(self, sec, ptype, rule):
229
225
230
226
return rule not in assertion .policy
231
227
232
-
233
228
def remove_policies (self , sec , ptype , rules ):
234
229
"""Remove multiple policy rules by sequentially calling remove_policy."""
235
230
for rule in rules :
236
231
if not self .remove_policy (sec , ptype , rule ):
237
232
return False
238
233
return True
239
234
240
-
241
235
def remove_policies_with_effected (self , sec , ptype , rules ):
242
236
effected = []
243
237
for rule in rules :
@@ -270,15 +264,14 @@ def remove_filtered_policy_returns_effects(self, sec, ptype, field_index, *field
270
264
271
265
assertion = self [sec ][ptype ]
272
266
assertion .policy = tmp
273
-
267
+
274
268
new_map = {}
275
269
for idx , r in enumerate (assertion .policy ):
276
270
new_map [DEFAULT_SEP .join (r )] = idx
277
271
assertion .policy_map = new_map
278
272
279
273
return effects
280
274
281
-
282
275
def remove_filtered_policy (self , sec , ptype , field_index , * field_values ):
283
276
"""removes policy rules based on field filters from the model."""
284
277
tmp = []
@@ -297,15 +290,14 @@ def remove_filtered_policy(self, sec, ptype, field_index, *field_values):
297
290
298
291
assertion = self [sec ][ptype ]
299
292
assertion .policy = tmp
300
-
293
+
301
294
new_map = {}
302
295
for idx , r in enumerate (assertion .policy ):
303
296
new_map [DEFAULT_SEP .join (r )] = idx
304
297
assertion .policy_map = new_map
305
298
306
299
return res
307
300
308
-
309
301
def get_values_for_field_in_policy (self , sec , ptype , field_index ):
310
302
"""gets all values for a field for all rules in a policy, duplicated values are removed."""
311
303
values = []
@@ -319,4 +311,4 @@ def get_values_for_field_in_policy(self, sec, ptype, field_index):
319
311
if value not in values :
320
312
values .append (value )
321
313
322
- return values
314
+ return values
0 commit comments