Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate “OCI Storage Buckets Should Have Versioning Enabled” using the OCI Console:
  1. Sign in to OCI Console
    Log in to the OCI Console with an account that has permissions to manage Object Storage buckets.
  2. Go to Object Storage
    • Open the hamburger menu (☰) in the top-left.
    • Navigate to: Storage → Buckets (under “Object Storage & Archive Storage”).
  3. Select the Correct Compartment
    • In the left-side Compartment selector, choose the compartment that contains the non‑compliant bucket(s).
  4. Open the Target Bucket
    • Locate the bucket that needs versioning.
    • Click the bucket Name to open its details page.
  5. Edit Bucket Properties
    • On the bucket details page, click Edit (or Edit bucket).
  6. Enable Versioning
    • Find the Versioning section.
    • Set Versioning to Enabled (or select Enable object versioning).
    • Review any warning about impact (e.g., additional storage costs for multiple versions).
  7. Save Changes
    • Click Save changes (or Update).
  8. Validate
    • After saving, confirm on the bucket details page that Versioning: Enabled is shown.
    • If your security/monitoring control is via Cloud Guard or Security Zones, wait for the next evaluation cycle and verify the problem is cleared in:
      • Cloud Guard → Targets / Problems, or
      • Security Zones → Violations, depending on your setup.
  9. Repeat for Other Buckets
    • Repeat steps 3–8 for all buckets that must comply with the “Versioning Enabled” requirement in the monitored compartments/tenancies.
If you tell me whether you’re using Cloud Guard, Security Zones, or another policy pack, I can tailor the verification step to that specific OCI monitoring service.
Below are step‑by‑step OCI CLI instructions to enable versioning on Object Storage buckets.Assumptions:
  • You already have oci CLI installed and configured (oci setup config).
  • You know your compartment OCID and namespace (or can retrieve them).

1. Get the Object Storage namespace

Output will look like:
Note the value (e.g., my_namespace).

2. List buckets in a compartment (optional, to find targets)

From the output, note the name of each bucket you need to fix.

3. Check current versioning status for a bucket

If it returns Disabled or empty, versioning is not enabled.

4. Enable versioning for a single bucket


5. Verify versioning is enabled

It should now output:

6. (Optional) Bulk‑enable versioning on all buckets in a compartment

This will remediate the “OCI Storage Buckets Should Have Versioning Enabled” finding via OCI CLI.
Below are step‑by‑step instructions and a Python example to detect and remediate OCI Object Storage buckets that do not have versioning enabled.

1. Prerequisites

  1. Install OCI Python SDK
  2. Configure OCI credentials (one of):
    • ~/.oci/config file with a profile (e.g., DEFAULT), or
    • Instance principal / resource principal in OCI (for running on OCI compute / functions).
    Example ~/.oci/config:

2. Concept

  • Versioning status is set at the bucket level.
  • API: ObjectStorageClient.update_bucket with UpdateBucketDetails.versioning = "Enabled".
We’ll:
  1. List all buckets in a compartment.
  2. Check each bucket’s versioning status.
  3. For those not "Enabled", call update_bucket to enable it.
  4. Wrap this in a script that can be used for periodic monitoring/remediation.

3. Python Script: Detect & Remediate Bucket Versioning


4. How to Use for Monitoring

  • Run this script on a schedule (e.g., cron, OCI Functions + OCI Events) to:
    • Log buckets and their versioning status (monitoring).
    • Automatically remediate any non‑compliant bucket (enable versioning).
Example cron (every hour):
This setup continuously monitors and remediates the “versioning disabled” misconfiguration on OCI Object Storage buckets using Python.
Enabling versioning on an existing oci_objectstorage_bucket is an in‑place update in OCI and does not force bucket replacement.After updating your configuration, terraform plan should show a single in‑place update (~ on oci_objectstorage_bucket.MONITORED_BUCKET) changing versioning from "Disabled" (or null) to "Enabled".