Skip to content

Conversation

@laissaouibrahim
Copy link

@laissaouibrahim laissaouibrahim commented Dec 14, 2025

Summary
As requested in IdeaExchange: Add system permission requirement for sf org delete sandbox command, we need to add a security layer to prevent accidental or unauthorized sandbox deletions via the CLI.

Problem
Currently, any user who has authenticated to a sandbox via the CLI can run sf org delete sandbox and delete it. There is no granular permission check within the Salesforce org to restrict this destructive action.

Proposed Solution
Modify the org delete sandbox command to enforce a permission check against the target sandbox before proceeding with deletion.

Acceptance Criteria

  1. Permission Check : The command must verify if the authenticated user has the 'DeleteSandbox' Permission Set assigned in the target org.
  2. Blocking: If the user does not have this Permission Set, the command must fail with an insufficientPermissions error and NOT delete the sandbox.

Implementation Details

  • Implement a hasPermission() method in the command class.
  • create a new permissionset :
  • image
  • Query the PermissionSetAssignment object to check for the assignment of a Permission Set named 'DeleteSandbox' for the current user.

Testing

  • Missing assigned PermissionSet to current user :
image
  • User with assigned PermissionSet :
image
  • Another error :
image

@laissaouibrahim laissaouibrahim requested a review from a team as a code owner December 14, 2025 11:26
@salesforce-cla
Copy link

Thanks for the contribution! Before we can merge this, we need @laissaouibrahim to sign the Salesforce Inc. Contributor License Agreement.

@laissaouibrahim
Copy link
Author

Thanks for the contribution! Before we can merge this, we need @laissaouibrahim to sign the Salesforce Inc. Contributor License Agreement.

done !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant