Browse Source

RLS for listcastablesandeffectiveaccess.py (#61)

master
David Stern 6 years ago
committed by GitHub
parent
commit
48763e1c31
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      listcastablesandeffectiveaccess.py

16
listcastablesandeffectiveaccess.py

@ -5,7 +5,7 @@
# January 2019
#
# Usage:
# listcastablesandeffectiveaccess.py [--noheader] [-d]
# listcastablesandeffectiveaccess.py [--noheader] [--rowlevelsecurity] [--sourcetables] [-d]
#
# Examples:
#
@ -49,15 +49,23 @@ permissions=['readInfo','select','limitedPromote','promote','createTable','dropT
parser = argparse.ArgumentParser()
parser.add_argument("--noheader", action='store_true', help="Do not print the header row")
parser.add_argument("--rowlevelsecurity", action='store_true', help="Get row level security (i.e. table filters on the select permission)")
parser.add_argument("--sourcetables", action='store_true', help="Get effective permissions for source tables, rather than in-memory tables which is the default")
parser.add_argument("-d","--debug", action='store_true', help="Debug")
args = parser.parse_args()
noheader=args.noheader
rowlevelsecurity=args.rowlevelsecurity
sourcetables=args.sourcetables
debug=args.debug
if rowlevelsecurity:
permissions.append("tableFilter")
# Print header row unless noheader argument was specified
if not noheader:
print('server,caslib,table,'+','.join(map(str, identity_cols))+','+','.join(map(str, permissions)))
endpoint='/casManagement/servers'
method='get'
@ -105,6 +113,11 @@ for server in servers:
tables=tables_result_json['items']
for table in tables:
tablename=table['name']
# We have the in-memory table name, but if the user requested it, try to use the source table name instead
if sourcetables and 'tableReference' in table:
if 'sourceTableName' in table['tableReference']:
tablename=table['tableReference']['sourceTableName']
# Get effective Access Controls on this table
endpoint='/casAccessManagement/servers/'+servername+'/caslibs/'+caslibname+'/tableControls/'+tablename+'?accessControlType=effective'
method='get'
@ -127,4 +140,3 @@ for server in servers:
else:
#tables_result_json is None
print(servername+','+caslibname+',[error getting tables]')

Loading…
Cancel
Save