sassoftware / pyviyatools

Python command-line tools that call the SAS Viya REST APIs - for SAS administrators.
Apache License 2.0
38 stars 31 forks source link

Request for script to disable rules in bulk #162

Closed tomstarr closed 1 year ago

tomstarr commented 1 year ago

As part of the my Auth Model implementation automation project, I have a need to be able to disable OOTB Viya rules en masse, in order for the newly created rules to become effective.

Recently the Viya CLI was enhanced to support the disabling of rules using the command: 'sas-viya authorization disable-rules ...' (and it's antonym 'sas-viya authorization enable-rules ...') However, both of these commands only support the disabling of a single rule at a time, and they require the rule's ID in order to do this.

Please develop something that will:

  1. read in a CSV (sample csv lines at the bottom)
  2. run the getruleid.py script to retrieve all of the rules' IDs (e.g. ./getruleid.py -u '+objecturi+' -p '+principal+' -o csv')
  3. loop the resulting rule IDs through the Viya CLI's disable-rules command

Thanks heaps!

Sample CSV:

"objectUri","principal or principalType"
"/jobExecution/jobRequests/*","authenticatedUsers"
"/jobExecution/jobRequests/*/","authenticatedUsers"
"/jobExecution/jobs/**","authenticatedUsers"
"/jobExecution/jobs/**","authenticatedUsers"
tomstarr commented 1 year ago

Hi Gerry, I raised this as an issue after consulting with Ajmal. However, as it happens, I found some time today and was able to write something myself. #163 togglerules

Do take a look and see whether it'd tick the boxes for this project, or could do with some refinement.

Thanks.

tomstarr commented 1 year ago

Opened a new pull request without the pycache this time :) #164

gerrynelson63 commented 1 year ago

Thanks for adding this tool Tom, nice work, I have merged it in.