Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion keepercommander/commands/pedm/pedm_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ def __init__(self):
parser.add_argument('--policy-type', dest='policy_type', action='store', default='elevation',
choices=['elevation', 'file_access', 'command', 'least_privilege'],
help='Policy type')
parser.add_argument('--policy-name', dest='policy_name', action='store',
parser.add_argument('--policy-name', dest='policy_name', action='store', required=True,
help='Policy name')
parser.add_argument('--control', dest='control', action='append',
choices=['allow', 'deny', 'audit', 'notify', 'mfa', 'justify', 'approval'],
Expand Down Expand Up @@ -1432,6 +1432,14 @@ def execute(self, context: KeeperParams, **kwargs) -> None:
if policy_filter:
policy_data.update(policy_filter)

if policy_type in ('PrivilegeElevation', 'FileAccess', 'CommandLine'):
missing = [name for name, key in (('user', 'UserCheck'), ('machine', 'MachineCheck'), ('application', 'ApplicationCheck'))
if not policy_filter.get(key)]
if missing:
raise base.CommandError(
f'At least one machine, application, and user collection required to save this policy type. '
f'Missing: {", ".join(missing)}. Use --user-filter, --machine-filter, --app-filter.')

for filter_name in ('UserCheck', 'MachineCheck', 'ApplicationCheck', 'DateCheck', 'TimeCheck', 'DayCheck'):
f = policy_data.get(filter_name)
if f is None:
Expand Down
Loading