Google Cloud Storage
storage.gcs
Protects against destructive GCS operations like bucket removal, object deletion, and recursive deletes.
- 6blocking rules
- 15safe patterns
- 2Critical
- 4High
[packs]
enabled = ["storage.gcs"]Evaluated when a command contains gsutil, gcloud.
Blocking rules
Each rule ID is storage.gcs:<name>. Use it in allowlists and [policy.rules].
Criticalgcloud-storage-buckets-deletegcloud storage buckets delete removes a GCS bucket.
Explanation
Deleting a GCS bucket removes the bucket configuration and all objects within it (if --recursive is used). The globally unique bucket name may not be immediately reclaimable. All dependent applications will fail. Safer alternatives: - gcloud storage buckets describe: Review bucket configuration - gcloud storage cp -r: Backup contents before deletion - Remove objects first to understand data being deleted
Criticalgsutil-rbgsutil rb removes a GCS bucket.
Explanation
Removing a GCS bucket deletes the bucket and potentially all objects within it. Bucket names are globally unique and may not be immediately available for reuse. Applications and services referencing this bucket will fail. Safer alternatives: - gsutil ls gs://bucket: List bucket contents first - gsutil -m cp -r gs://bucket ./backup: Backup contents locally - Enable object versioning before testing deletions
Highgcloud-storage-objects-deletegcloud storage objects delete removes objects from GCS.
Explanation
Deleting GCS objects permanently removes data. Without object versioning, deleted files cannot be recovered. Production data should be backed up before deletion. Safer alternatives: - gcloud storage objects describe: Verify object before deletion - Enable bucket versioning for soft deletes - Move to archive storage class instead of deleting
Highgcloud-storage-rmgcloud storage rm removes objects from GCS.
Explanation
The rm command deletes objects and can recursively remove entire bucket contents. Deleted objects are permanently lost unless versioning is enabled. Wildcards can unexpectedly match more files than intended. Safer alternatives: - gcloud storage ls: Preview files matching pattern - Enable bucket versioning before testing - gcloud storage mv: Move to archive bucket instead
Highgsutil-rmgsutil rm deletes objects from GCS.
Explanation
Deleting GCS objects permanently removes data unless versioning is enabled. With -r flag, entire directory trees are deleted recursively. Without versioning, deleted objects cannot be recovered. Safer alternatives: - gsutil ls: Preview what will be deleted - Enable bucket versioning for recovery options - gsutil mv: Move to archive bucket instead of deleting
Highgsutil-rsync-deletegsutil rsync -d deletes destination objects not in source.
Explanation
The -d flag with gsutil rsync deletes destination objects that don't exist in the source. If source and destination are swapped, or source is empty, this can result in total data loss at the destination. Safer alternatives: - gsutil rsync -n -d: Dry run to preview deletions - gsutil rsync without -d: Only adds/updates, never deletes - Backup destination before syncing
Safe patterns
Checked first. A command that matches one is never blocked by this pack.
gsutil-lsgsutil-catgsutil-statgsutil-dugsutil-hashgsutil-versiongsutil-helpgsutil-cpgcloud-storage-buckets-listgcloud-storage-buckets-describegcloud-storage-objects-listgcloud-storage-objects-describegcloud-storage-lsgcloud-storage-catgcloud-storage-cp