Skip to main content

Triage and Remediation

Remediation

Using Console

To remediate the PostgreSQL External Scripts Enabled Flag Should Be Off misconfiguration for GCP using GCP console, follow these steps:
  1. Open the GCP Console and navigate to the Cloud SQL instances page.
  2. Select the PostgreSQL instance you want to remediate.
  3. Click on the “Edit” button at the top of the page.
  4. Scroll down to the “Flags” section.
  5. Locate the “external-scripts-enabled” flag and set it to “off”.
  6. Click on the “Save” button at the bottom of the page to save the changes.
After completing these steps, the PostgreSQL External Scripts Enabled Flag will be turned off, and the misconfiguration will be remediated.

To remediate the PostgreSQL External Scripts Enabled Flag misconfiguration for GCP using GCP CLI, you can follow the below steps:
  1. Open the Cloud Shell in your GCP console.
  2. Run the following command to list all the Cloud SQL instances in your GCP project:
  3. Identify the instance for which you want to remediate the PostgreSQL External Scripts Enabled Flag misconfiguration.
  4. Run the following command to update the instance configuration:
    Replace [INSTANCE_NAME] with the name of your Cloud SQL instance.
  5. Confirm the update by running the following command:
    This will display the details of your Cloud SQL instance, including the updated configuration.
By following these steps, you can remediate the PostgreSQL External Scripts Enabled Flag misconfiguration for GCP using GCP CLI.
To remediate the PostgreSQL External Scripts Enabled Flag misconfiguration on GCP using Python, you can follow the below steps:
  1. Connect to the GCP project using the google-auth and google-cloud-secret-manager libraries.
  1. Retrieve the PostgreSQL instance name and configuration details from the GCP Secret Manager.
  1. Connect to the PostgreSQL instance using the psycopg2 library.
  1. Disable the External Scripts Enabled flag by updating the postgresql.conf file.
  1. Restart the PostgreSQL instance for the changes to take effect.
By following these steps, you can remediate the PostgreSQL External Scripts Enabled Flag misconfiguration on GCP using Python.
For gcp-database-sql-instance (Google Cloud SQL for PostgreSQL), this finding cannot be remediated in Terraform because the external scripts enabled flag is specific to Microsoft SQL Server and does not exist as a configurable setting on Cloud SQL for PostgreSQL.There is no equivalent database flag or instance setting in the google_sql_database_instance resource (or any related Cloud SQL Terraform resource) that maps to SQL Server’s external scripts enabled option, either in Terraform or in the GCP Console, so no HCL change is possible or required. This rule is effectively not applicable to Cloud SQL for PostgreSQL.