YAML-Datei für den Sicherheitsstatus

Diese Seite bietet einen Überblick über die Schlüssel/Wert-Paare in der Datei posture.yaml, die Sie zum Definieren der Richtlinien für Ihren Sicherheitsstatus erstellen. Informationen zum Erstellen einer YAML-Datei für einen Sicherheitsstatus und zum Bereitstellen in Ihrer Umgebung finden Sie unter Sicherheitsstatus verwalten.

YAML-Dateistruktur für Sicherheitsstatus

Sicherheitsstatus sind YAML-Dateien mit der folgenden Struktur:

name: posture_name
state: posture_state
description: posture_description
policy_sets:
- policy_set_id: policy_set_ID
  - description: policy_set_description
  policies:
  - policy_id: policy_id
    compliance_standards:
      - standard: policy_standards
      - control: policy_control
          - description: policy_description
    # Definition for a organization policy
    constraint:
      org_policy_constraint:
        canned_constraint_id: constraint_ID
        policy_rules:
          - org_policy_kind: org_policy_kind_value
          - condition:
              expression: org_policy_expression
              title: org_policy_title
              description: org_policy_description
              location: org_policy_location
    # Definition for a custom organization policy constraint
    constraint:
      org_policy_constraint_custom:
        custom_constraint:
          name: custom_org_constraint_name
          resource_types: custom_org_resource_type
          method_types: custom_org_method_type
          condition: custom_org_condition
          action_type: custom_org_action_type
          display_name: custom_org_constraint_display_name
          description: custom_org_constraint_description
        policy_rules:
          - org_policy_kind: org_policy_kind_value
          - condition:
              expression: org_policy_expression
              title: org_policy_title
              description: org_policy_description
              location: org_policy_location
      # Definition for a Security Health Analytics detector
      constraint:
        security_health_analytics_module:
            module_name: sha_detector_name
            module_enablement_state: sha_detector_enabled
      # Definition for a custom Security Health Analytics detector
      constraint:
        security_health_analytics_custom_module:
            display_name: sha_custom_detector_name
            config:
                predicate:
                    expression: sha_custom_detector_expression
                    title: sha_custom_detector_predicate_title
                    description: sha_custom_detector_predicate_description
                    location: sha_custom_detector_predicate_location
                - custom_output:
                    - property:
                        name: sha_custom_detector_output_name
                        value_expression:
                            expression: sha_custom_detector_output_expression
                            title: sha_custom_detector_output_title
                            description: sha_custom_detector_output_description
                            location: sha_custom_detector_output_location
                resource_selector:
                    - resource_types: sha_custom_detector_resource
            severity: sha_custom_severity_level
              description: sha_custom_detector_description
              recommendation: sha_custom_detector_recommendation
            module_enablement_state: sha_detector_enabled

Beschreibung der Schlüssel/Wert-Paare

Die folgende Tabelle enthält eine Beschreibung der Schlüssel/Wert-Paare in der Datei posture.yaml.

Schlüssel/Wert-Paar Beschreibung
name: posture_name Der Name des Sicherheitsstatus, beginnend mit einem Buchstaben. Dieser Wert ist optional, da Sie den Namen des Sicherheitsstatus beim Ausführen des Befehls gcloud scc postures create angeben.
state: posture_state Ein ENUM, das Sie auf ACTIVE, DRAFT oder DEPRECATED festlegen können. Weitere Informationen finden Sie unter Status eines Sicherheitsstatus ändern.
description: posture_description Eine Beschreibung der Richtlinie. Dieser Wert ist optional.
policy_set_id: policy_set_ID Eine eindeutige Kennung für die Richtlinie, die in der Statusdatei festgelegt ist. Eine Statusdatei kann mehrere Richtliniensätze enthalten.
description: policy_set_description Eine Beschreibung der Richtliniengruppe. Dieser Wert ist optional.
policy_id: policy_id Eine eindeutige Kennung für die Richtlinie innerhalb der Richtliniengruppe. Ein Richtliniensatz kann mehrere Richtlinien enthalten.
standard: policy_compliance_standard Der Name des Compliancestandards, der durch diese Richtlinie unterstützt wird.
control: policy_compliance_control Die jeweiligen Steuerelemente im Compliancestandard, die durch diese Richtlinie unterstützt werden.
description: policy_compliance_description Eine Beschreibung des Compliancestandards, der durch diese Richtlinie unterstützt wird.
canned_constraint_id: constraint_ID Der Name der Einschränkung der Organisationsrichtlinie. Beispiel: cloudbuild.allowedWorkerPools. Geben Sie in constraint_ID nicht das Präfix constraints/ an.
org_policy_kind Werte für die Liste der Organisationsrichtlinien sind allow_all, deny_all, allowed_values, denied_values. Wert für boolesche Organisationsrichtlinien ist enforce.
org_policy_kind_value Werte für die Art allow_all, deny_all und enforce sind true oder false. Der Wert für die Arten allowed_values und denied_values ist eine Liste mit zulässigen bzw. abgelehnten Werten.
condition: Eine Bedingung, die bestimmt, ob diese Regel bei der Auswertung der Richtlinie verwendet wird. Wenn das Feld festgelegt ist, muss das Feld expression in Expr 1 bis 10 Unterausdrücke enthalten, die mit den Operatoren || oder && verbunden sind. Jeder Unterausdruck muss das Format resource.matchTag('ORG_ID/tag_key_short_name, 'tag_value_short_name') oder resource.matchTagId('tagKeys/key_id', 'tagValues/value_id') haben, wobei „key_name“ und „value_name“ die Ressourcennamen für Labelschlüssel und -werte sind. Diese Namen sind im Tag Manager verfügbar. Ein Beispielausdruck ist resource.matchTag('123456789/environment, 'prod') oder resource.matchTagId('tagKeys/123', 'tagValues/456').
expression: org_policy_expression Die Textdarstellung eines Ausdrucks in der Common Expression Language-Syntax. Dieser Wert ist optional.
title: org_policy_title Die Beschreibung des Zwecks des Ausdrucks. Dieser Wert ist optional.
description: org_policy_description Die Beschreibung des Ausdrucks. Dieser Wert ist optional.
location: org_policy_location Ein String, der den Ort des Ausdrucks zum Melden von Fehlern angibt. Zum Beispiel ein Dateiname und eine Position in der Datei. Dieser Wert ist optional.
name: custom_org_constraint_name Der Name der benutzerdefinierten Einschränkung im Format organizations/ORGANIZATION_ID/customConstraints/CONSTRAINT_NAME. Beispiel: organizations/3589215982/customConstraints/custom.disableGkeAutoUpgrade. CONSTRAINT_NAME darf maximal 62 Zeichen lang sein. Das Präfix organizations/{organization_id}/customConstraints/custom wird nicht gezählt. Wenn Sie eine benutzerdefinierte Einschränkung in der Statusdatei definieren, wird eine neue benutzerdefinierte Einschränkung erstellt.
resource_types: custom_org_resource_type Der voll qualifizierte Name der Google Cloud REST-Ressource, die das Objekt und das Feld enthält, das Sie einschränken möchten. Pro Ressourcentyp sind maximal 20 benutzerdefinierte Einschränkungen zulässig.
method_types: custom_org_method_type Die Liste der RESTful-Methoden, für die die Einschränkung erzwungen werden soll.
condition: custom_org_condition Die CEL-Bedingung, die sich auf die unterstützte Dienstressource bezieht. Dieses Feld hat eine maximale Länge von 1000 Zeichen.
action_type: custom_org_action_type Die auszuführende Aktion, wenn die Bedingung erfüllt ist.
display_name: custom_org_constraint_display_name Ein nutzerfreundlicher Name für die Einschränkung. Dieses Feld hat eine maximale Länge von 200 Zeichen.
description: custom_org_constraint_description Die Beschreibung der Einschränkung, die als Fehlermeldung angezeigt werden soll, wenn gegen die Richtlinie verstoßen wird. Dieses Feld hat eine maximale Länge von 2000 Zeichen.
module_name: sha_detector_name Der Name eines Security Health Analytics-Detektors. Beispiel: BIGQUERY_TABLE_CMEK_DISABLED.
module_enablement_state: sha_detector_enabled Gibt an, ob der Security Health Analytics-Detektor aktiviert ist. ENABLED oder DISABLED.
display_name: sha_custom_detector_name Der Name des benutzerdefinierten Moduls für Security Health Analytics. Der Name muss zwischen 1 und 128 Zeichen lang sein und mit einem Kleinbuchstaben beginnen. Er darf nur alphanumerische Zeichen oder Unterstriche enthalten.
expression: sha_custom_detector_expression Die CEL-Ausdrücke, die die Attribute der zu scannenden Ressourcentypen prüfen.
title: sha_custom_detector_predicate_title Der Name der Prädikat-Property für das benutzerdefinierte Modul für Security Health Analytics.
description: sha_custom_detector_predicate_description Die Beschreibung der Prädikat-Property für das benutzerdefinierte Modul für Security Health Analytics.
location: sha_custom_detector_predicate_location Der Standort, für den die Prädikateigenschaft gilt.
name: sha_custom_detector_output_name Der Name der custom_output-Eigenschaft.
expression: sha_custom_detector_output_expression Welcher Ausdruck in der Ausgabe zurückgegeben werden soll.
title: sha_custom_detector_output_title Der Titel der Ausgabe.
description: sha_custom_detector_output_description Die Beschreibung der Ausgabe für das benutzerdefinierte Modul für Security Health Analytics.
location: sha_custom_detector_output_location Der Speicherort, auf den sich die Ausgabe bezieht.
resource_types: sha_custom_detector_resource Die Ressourcentypen, die vom benutzerdefinierten Modul gescannt werden.
severity: sha_custom_severity_level Der Schweregrad der Ergebnisse, die von diesem Modul erstellt werden.
description: sha_custom_detector_description Die Sicherheitslücke oder fehlerhafte Konfiguration, die vom benutzerdefinierten Modul erkannt wird.
recommendation: sha_custom_detector_recommendation Eine Beschreibung, wie das erkannte Problem behoben werden kann.

Beispiel für posture.yaml

createTime: '2024-04-01T15:27:27.188366349Z'
etag: h5ulCqzUqOcaIjKjxHFrOrrZpmneG8A0K1mdO-uHsLM
name: organizations/123/locations/global/postures/mixedcasposture
policySets:
- policies:
  - constraint:
      securityHealthAnalyticsModule:
        moduleEnablementState: ENABLED
        moduleName: BIGQUERY_TABLE_CMEK_DISABLED
    description: enable BIGQUERY_TABLE_CMEK_DISABLED
    policyId: SHA module BIGQUERY_TABLE_CMEK_DISABLED
  - constraint:
      orgPolicyConstraint:
        cannedConstraintId: iam.allowServiceAccountCredentialLifetimeExtension
        policyRules:
        - allowAll: true
        - condition:
            expression: resource.matchTag("123/location", "us-east3")
            title: policy for us-east3
            description: apply policy to us-east3
    policyId: test/123/policies/iam.allowServiceAccountCredentialLifetimeExtension
  - constraint:
      orgPolicyConstraintCustom:
        customConstraint:
          actionType: ALLOW
          condition: resource.management.autoUpgrade == false
          description: Only allow GKE NodePool resource to be created or updated if
            AutoUpgrade is not enabled where this custom constraint is enforced.
          displayName: Disable GKE auto upgrade
          methodTypes:
          - CREATE
          name: organizations/123/customConstraints/custom.gke123
          resourceTypes:
          - container.googleapis.com/NodePool
        policyRules:
        - enforce: true
    policyId: orgPolicycustomconstraint
  - constraint:
      securityHealthAnalyticsModule:
        moduleEnablementState: DISABLED
        moduleName: PUBLIC_BUCKET_ACL
    description: PUBLIC_BUCKET_ACL disabled
    policyId: sha module PUBLIC_BUCKET_ACL
  - constraint:
      securityHealthAnalyticsCustomModule:
        config:
          customOutput: {}
          description: Test Custom Module
          predicate:
            expression: resource.rotationPeriod > duration('2592000s')
          recommendation: Testing custom modules
          resourceSelector:
            resourceTypes:
            - cloudkms.googleapis.com/CryptoKey
          severity: CRITICAL
        displayName: customSHA
        moduleEnablementState: ENABLED
    policyId: sha_custom_module
  - constraint:
      securityHealthAnalyticsCustomModule:
        config:
          customOutput: {}
          description: Test Custom Module
          predicate:
            expression: resource.rotationPeriod > duration('2592000s')
          recommendation: Testing custom modules
          resourceSelector:
            resourceTypes:
            - cloudkms.googleapis.com/CryptoKey
          severity: CRITICAL
        displayName: customSHA2
        moduleEnablementState: ENABLED
    policyId: sha_custom_module_2
  policySetId: PolicySetmix
- policy_set_id: BigQuery detective policy set
  description: SHA module that new customers can automatically enable.
  policies:
  - policy_id: Public dataset
    constraint:
      securityHealthAnalyticsModule:
        moduleEnablementState: ENABLED
        moduleName: PUBLIC_DATASET
state: ACTIVE

Beispiele

Beispiele finden Sie in den vordefinierten Vorlagen für den Sicherheitsstatus.

Die folgende Sicherheitsstatusdatei enthält Security Health Analytics-Detektoren für AWS und Google Cloud:

description: Posture to help make storage workloads more secure across Google Cloud and AWS.
state: ACTIVE
policy_sets:
- policy_set_id: Google Cloud policy set
  description: Policy set containing organization policies and Security Health Analytics modules for securing Cloud Storage.
  policies:
  - policy_id: Enforce Public Access Prevention
    compliance_standards:
    - standard: NIST SP 800-53
      control: AC-3
    - standard: NIST SP 800-53
      control: AC-17
    - standard: NIST SP 800-53
      control: AC-20
    constraint:
      org_policy_constraint:
        canned_constraint_id: storage.publicAccessPrevention
        policy_rules:
        - enforce: true
    description: This policy prevents access to existing and future resources via the public internet by disabling and blocking access control lists (ACLs) and IAM permissions that grant access to allUsers and allAuthenticatedUsers.
  - policy_id: Bucket IAM not monitored
    compliance_standards:
    - standard: NIST 800-53 R5
      control: AC-12
    - standard: NIST 800-53 R5
      control: AC-2
    - standard: NIST 800-53 R5
      control: AC-7
    constraint:
      securityHealthAnalyticsModule:
        moduleEnablementState: ENABLED
        moduleName: BUCKET_IAM_NOT_MONITORED
    description: This detector logs metric filter and creates alerts for Cloud Storage IAM permission changes. By monitoring changes to Cloud Storage bucket permissions, this detector can help you identify over-privileged users or suspicious activity at early stages.

- policy_set_id: AWS policy set
  description:  Policy set containing AWS built-in Security Health Analytics modules for securing S3 buckets.
  policies:
  - policy_id: S3 bucket replication enabled
    compliance_standards:
    - standard: NIST 800-53 R5
      control: SI-13(5)
    constraint:
      securityHealthAnalyticsModule:
        moduleEnablementState: ENABLED
        moduleName: S3_BUCKET_REPLICATION_ENABLED
    description: This control checks whether an Amazon S3 bucket has cross-region replication enabled. The control fails if the bucket doesn't have cross-region replication enabled or if same-region replication is also enabled.

  - policy_id: S3 bucket logging enabled
    compliance_standards:
    - standard: NIST 800-53 R5
      control: SI-13(5)
    - standard: PCI DSS 3.2.1
      control: 10.3.1
    constraint:
      securityHealthAnalyticsModule:
        moduleEnablementState: ENABLED
        moduleName: S3_BUCKET_LOGGING_ENABLED
    description: AWS S3 Server Access Logging feature records access requests to storage buckets which is useful for security audits. By default, server access logging is not enabled for S3 buckets.

Nächste Schritte