Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #169 safe permission set properly now #170

Merged
Show file tree
Hide file tree
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
107 changes: 11 additions & 96 deletions cmd/safes.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var (
// Role of safe member to determine pre-defined safe permissions
Role string
// RolePermissions contain the pre-defined safe permissions of defined role
RolePermissions []requests.PermissionKeyValue
RolePermissions map[string]string
// User is the user to search for as a safe member
User string
// Group is the group to search for as a safe member
Expand Down Expand Up @@ -242,95 +242,12 @@ var addMembersCmd = &cobra.Command{

// If no role is specified, default to user-provided safe permissions
if Role == "" {
RolePermissions = []requests.PermissionKeyValue{
{
Key: "UseAccounts",
Value: UseAccounts,
},
{
Key: "RetrieveAccounts",
Value: RetrieveAccounts,
},
{
Key: "ListAccounts",
Value: ListAccounts,
},
{
Key: "AddAccounts",
Value: AddAccounts,
},
{
Key: "UpdateAccountContent",
Value: UpdateAccountContent,
},
{
Key: "UpdateAccountProperties",
Value: UpdateAccountProperties,
},
{
Key: "InitiateCPMAccountManagementOperations",
Value: InitiateCPMAccountManagementOperations,
},
{
Key: "SpecifyNextAccountContent",
Value: SpecifyNextAccountContent,
},
{
Key: "RenameAccounts",
Value: RenameAccounts,
},
{
Key: "DeleteAccounts",
Value: DeleteAccounts,
},
{
Key: "UnlockAccounts",
Value: UnlockAccounts,
},
{
Key: "ManageSafe",
Value: ManageSafe,
},
{
Key: "ManageSafeMembers",
Value: ManageSafeMembers,
},
{
Key: "BackupSafe",
Value: BackupSafe,
},
{
Key: "ViewAuditLog",
Value: ViewAuditLog,
},
{
Key: "ViewSafeMembers",
Value: ViewSafeMembers,
},
{
Key: "AccessWithoutConfirmation",
Value: AccessWithoutConfirmation,
},
{
Key: "CreateFolders",
Value: CreateFolders,
},
{
Key: "DeleteFolders",
Value: DeleteFolders,
},
{
Key: "MoveAccountsAndFolders",
Value: MoveAccountsAndFolders,
},
{
Key: "RequestsAuthorizationLevel1",
Value: RequestsAuthorizationLevel1,
},
{
Key: "RequestsAuthorizationLevel2",
Value: RequestsAuthorizationLevel2,
},
var RolePermissionsString string
RolePermissionsString = fmt.Sprintf("UseAccounts=%v,RetrieveAccounts=%v,ListAccounts=%v,AddAccounts=%v,UpdateAccountContent=%v,UpdateAccountProperties=%v,InitiateCPMAccountManagementOperations=%v,SpecifyNextAccountContent=%v,RenameAccounts=%v,DeleteAccounts=%v,UnlockAccounts=%v,ManageSafe=%v,ManageSafeMembers=%v,BackupSafe=%v,ViewAuditLog=%v,ViewSafeMembers=%v,AccessWithoutConfirmation=%v,CreateFolders=%v,DeleteFolders=%v,MoveAccountsAndFolders=%v,RequestsAuthorizationLevel1=%v,RequestsAuthorizationLevel2=%v", UseAccounts, RetrieveAccounts, ListAccounts, AddAccounts, UpdateAccountContent, UpdateAccountProperties, InitiateCPMAccountManagementOperations, SpecifyNextAccountContent, RenameAccounts, DeleteAccounts, UnlockAccounts, ManageSafe, ManageSafeMembers, BackupSafe, ViewAuditLog, ViewSafeMembers, AccessWithoutConfirmation, CreateFolders, DeleteFolders, MoveAccountsAndFolders, RequestsAuthorizationLevel1, RequestsAuthorizationLevel2)
RolePermissions, err = keyValueStringToMap(RolePermissionsString)
if err != nil {
log.Fatalf("Failed to parse role permissions. %s", err)
return
}
}

Expand All @@ -344,12 +261,10 @@ var addMembersCmd = &cobra.Command{
}

newMember := requests.AddSafeMember{
Member: requests.AddSafeMemberInternal{
MemberName: MemberName,
SearchIn: SearchIn,
MembershipExpirationDate: MembershipExpirationDate,
Permissions: RolePermissions,
},
MemberName: MemberName,
SearchIn: SearchIn,
MembershipExpirationDate: MembershipExpirationDate,
Permissions: RolePermissions,
}

// Add a safe with the configuration options given via CLI subcommands
Expand Down
2 changes: 1 addition & 1 deletion docs/cybr.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ Security.
* [cybr users](cybr_users.md) - User actions for PAS REST API
* [cybr version](cybr_version.md) - Display current version

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ All account actions that can be taken via PAS REST API.
* [cybr accounts reconcile](cybr_accounts_reconcile.md) - Mark an account for reconciliation
* [cybr accounts verify](cybr_accounts_verify.md) - Mark an account for verification

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_accounts_add.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ cybr accounts add [flags]

* [cybr accounts](cybr_accounts.md) - Account actions for PAS REST API

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_accounts_change.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ cybr accounts change [flags]

* [cybr accounts](cybr_accounts.md) - Account actions for PAS REST API

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_accounts_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ cybr accounts delete [flags]

* [cybr accounts](cybr_accounts.md) - Account actions for PAS REST API

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_accounts_get-password.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ cybr accounts get-password [flags]

* [cybr accounts](cybr_accounts.md) - Account actions for PAS REST API

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_accounts_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ cybr accounts get [flags]

* [cybr accounts](cybr_accounts.md) - Account actions for PAS REST API

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_accounts_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ cybr accounts list [flags]

* [cybr accounts](cybr_accounts.md) - Account actions for PAS REST API

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_accounts_move.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ cybr accounts move [flags]

* [cybr accounts](cybr_accounts.md) - Account actions for PAS REST API

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_accounts_reconcile.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ cybr accounts reconcile [flags]

* [cybr accounts](cybr_accounts.md) - Account actions for PAS REST API

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_accounts_verify.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ cybr accounts verify [flags]

* [cybr accounts](cybr_accounts.md) - Account actions for PAS REST API

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_applications.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ All applications actions that can be taken via PAS REST API.
* [cybr applications list](cybr_applications_list.md) - List all applications
* [cybr applications list-authn](cybr_applications_list-authn.md) - List all authn methods on a specific application

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_applications_add-authn.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ cybr applications add-authn [flags]

* [cybr applications](cybr_applications.md) - Applications actions for PAS REST API

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_applications_add.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ cybr applications add [flags]

* [cybr applications](cybr_applications.md) - Applications actions for PAS REST API

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_applications_delete-authn.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ cybr applications delete-authn [flags]

* [cybr applications](cybr_applications.md) - Applications actions for PAS REST API

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_applications_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ cybr applications delete [flags]

* [cybr applications](cybr_applications.md) - Applications actions for PAS REST API

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_applications_list-authn.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ cybr applications list-authn [flags]

* [cybr applications](cybr_applications.md) - Applications actions for PAS REST API

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_applications_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ cybr applications list [flags]

* [cybr applications](cybr_applications.md) - Applications actions for PAS REST API

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_ccp.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ All actions that can be performed with the Central Credential Provider.
* [cybr](cybr.md) - cybr is CyberArk's PAS command-line interface utility
* [cybr ccp get-account](cybr_ccp_get-account.md) - Get account from CCP

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_ccp_get-account.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ cybr ccp get-account [flags]

* [cybr ccp](cybr_ccp.md) - CCP actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_cem.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ All actions that can be performed with the Cloud Entitlements Manager.
* [cybr cem recommendations](cybr_cem_recommendations.md) - Get Entity Recommendations
* [cybr cem remediations](cybr_cem_remediations.md) - Get Entity Remediations

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_cem_accounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ cybr cem accounts [flags]

* [cybr cem](cybr_cem.md) - CEM actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_cem_entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ cybr cem entities [flags]

* [cybr cem](cybr_cem.md) - CEM actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_cem_entity-details.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ cybr cem entity-details [flags]

* [cybr cem](cybr_cem.md) - CEM actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_cem_logon.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ cybr cem logon [flags]

* [cybr cem](cybr_cem.md) - CEM actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_cem_recommendations.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ cybr cem recommendations [flags]

* [cybr cem](cybr_cem.md) - CEM actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_cem_remediations.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ cybr cem remediations [flags]

* [cybr cem](cybr_cem.md) - CEM actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ cybr completion [bash|zsh|fish|powershell]

* [cybr](cybr.md) - cybr is CyberArk's PAS command-line interface utility

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_conjur.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ Perform actions on conjur
* [cybr conjur update-policy](cybr_conjur_update-policy.md) - Update policy to conjur
* [cybr conjur whoami](cybr_conjur_whoami.md) - Get current user info logged into Conjur

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_conjur_append-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ cybr conjur append-policy [flags]

* [cybr conjur](cybr_conjur.md) - Conjur actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_conjur_enable-authn.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ cybr conjur enable-authn [flags]

* [cybr conjur](cybr_conjur.md) - Conjur actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_conjur_get-secret.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ cybr conjur get-secret [flags]

* [cybr conjur](cybr_conjur.md) - Conjur actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_conjur_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ cybr conjur info [flags]

* [cybr conjur](cybr_conjur.md) - Conjur actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_conjur_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ cybr conjur list [flags]

* [cybr conjur](cybr_conjur.md) - Conjur actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_conjur_logoff.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ cybr conjur logoff [flags]

* [cybr conjur](cybr_conjur.md) - Conjur actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_conjur_logon-non-interactive.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ cybr conjur logon-non-interactive [flags]

* [cybr conjur](cybr_conjur.md) - Conjur actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_conjur_logon.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ cybr conjur logon [flags]

* [cybr conjur](cybr_conjur.md) - Conjur actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_conjur_replace-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ cybr conjur replace-policy [flags]

* [cybr conjur](cybr_conjur.md) - Conjur actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_conjur_rotate-api-key.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ cybr conjur rotate-api-key [flags]

* [cybr conjur](cybr_conjur.md) - Conjur actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_conjur_set-secret.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ cybr conjur set-secret [flags]

* [cybr conjur](cybr_conjur.md) - Conjur actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_conjur_update-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ cybr conjur update-policy [flags]

* [cybr conjur](cybr_conjur.md) - Conjur actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_conjur_whoami.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ cybr conjur whoami [flags]

* [cybr conjur](cybr_conjur.md) - Conjur actions

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_logoff.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ cybr logoff [flags]

* [cybr](cybr.md) - cybr is CyberArk's PAS command-line interface utility

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_logon.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ cybr logon [flags]

* [cybr](cybr.md) - cybr is CyberArk's PAS command-line interface utility

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
2 changes: 1 addition & 1 deletion docs/cybr_platforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ All platform actions that can be taken via PAS REST API.
* [cybr platforms get](cybr_platforms_get.md) - Get a specific platform
* [cybr platforms list](cybr_platforms_list.md) - List all platforms

###### Auto generated by spf13/cobra on 17-Aug-2022
###### Auto generated by spf13/cobra on 13-Oct-2022
Loading