Ensure that the 'log_temp_files' database flag for Cloud SQL PostgreSQL instance is set to '0' (on)
Enabling log_temp_files flag will enable logging of any temporary file that was created because work_mem got full. This feature is recommended in order to increase logging details for your PostgreSQL database instances, and it might help to identify poor performance.
Risk Level: Low
Cloud Entity: GCP CloudSql
CloudGuard Rule ID: D9.GCP.LOG.05
Covered by Spectral: Yes
Category: Database
GSL LOGIC
CloudSql where databaseVersion like 'POSTGRES%' should have settings.databaseFlags contain [ name like 'log_temp_files' and value = 0 ]
REMEDIATION
From Portal
- Go to https://console.cloud.google.com/sql/instances and navigate to the instance where the flag needs to be set
- Click Edit Configurations
- Under flags section, choose add flag, look for log_temp_files and choose value - 0.
- Save and review your changes
From TF
Set the flag 'log_temp_files' to '0':
resource 'google_sql_database_instance' 'default' {
...
settings {
database_flags {
name = 'log_temp_files'
value = '0'
}
}
}
From Command Line
- First retrieve all existing flags values:
gcloud sql instances describe INSTANCE_NAME
- Add all existing flags and their value to the patch request - otherwise they will get set to their default value.
gcloud sql instances patch INSTANCE_NAME --database-flags (ExistingFlag1=Value1,ExistingFlag2=Value2,...),log_temp_files=0
References
- https://cloud.google.com/sdk/gcloud/reference/sql/instances/describe
- https://cloud.google.com/sdk/gcloud/reference/sql/instances/patch#--database-flags
- https://cloud.google.com/sql/docs/postgres/flags
- https://www.postgresql.org/docs/9.6/runtime-config-logging.html#GUC-LOG-TEMP-FILES
GCP CloudSql
Cloud SQL is a fully managed database service that makes it easy to set up, maintain, manage, and administer your relational PostgreSQL, MySQL, and SQL Server databases in the cloud.
Compliance Frameworks
- CloudGuard GCP All Rules Ruleset
- GCP CIS Foundations v. 1.1.0
- GCP CIS Foundations v. 1.2.0
- GCP CloudGuard Best Practices
- GCP MITRE ATT&CK Framework v12.1
- GCP NIST 800-53 Rev 5
Updated about 1 year ago