Logging metric filter and alert for SQL instance configuration are not configured Affecting Cloud SQL service in Google


Severity

0.0
medium
0
10
Severity Framework
Snyk CCSS
Rule category
Logging/ Logging

Is your environment affected by this misconfiguration?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
Frameworks
CIS-ControlsCIS-GoogleHIPAAISO-27001NIST-800-53PCI-DSSSOC-2
  • Snyk IDSNYK-CC-00442
  • creditSnyk Research Team

Description

Misconfiguration of SQL instances can adversely impact business continuity, disaster recovery, and high availability or increase exposure to untrusted networks. Monitoring configuration changes can reduce the time needed to correct them.

How to fix?

Ensure google_logging_metric and google_monitoring_alert_policy resources are configured to alert for SQL instance configuration changes.

Example Configuration

resource "google_logging_metric" "logging_metric_442" {
  name   = "logging_metric_442"
  filter = "protoPayload.methodName=\"cloudsql.instances.update\""

  metric_descriptor {
    value_type  = "INT64"
    metric_kind = "DELTA"
  }
}

resource "google_monitoring_alert_policy" "alert_policy" {
  depends_on   = [google_logging_metric.logging_metric_442]
  display_name = "Alert Policy"
  combiner     = "OR"
  conditions {
    display_name = "condition"
    condition_threshold {
      filter     = "resource.type=\"global\" metric.type=\"logging.googleapis.com/user/logging_metric_442\""
      duration   = "60s"
      comparison = "COMPARISON_GT"
    }
  }
}