Mindesteinstellungen für Model Armor konfigurieren

In diesem Dokument wird beschrieben, wie Sie die Model Armor-Mindesteinstellungen aufrufen und aktualisieren. Außerdem finden Sie ein Beispiel für einen Verstoß gegen eine Mindesteinstellung.

Mit den Mindesteinstellungen für Model Armor werden Regeln definiert, die Mindestanforderungen für alle Model Armor-Vorlagen festlegen, die an einem bestimmten Punkt in der Google Cloud Ressourcenhierarchie erstellt werden (d. h. auf Organisations-, Ordner- oder Projektebene). Wenn mehrere Etagenkonfigurationen in Konflikt stehen, haben die Einstellungen in der Ressourcenhierarchie Vorrang, die weiter unten liegen. Wenn beispielsweise eine Richtlinie für die Mindesteinstellung auf Ordner- und Projektebene erstellt wird, wird die Richtlinie auf Projektebene angewendet. Dieses Verhalten gilt nur für Projekte in diesem Ordner.

Angenommen, Sie haben eine Richtlinie auf Ordnerebene für einen bestimmten Ordner festgelegt und damit einen Filter für schädliche URIs für alle Inhalte darin aktiviert. In diesem Ordner befindet sich dann ein bestimmtes Projekt. Für dieses Projekt haben Sie eine spezifischere Richtlinie auf Projektebene konfiguriert. Für diese Richtlinie auf Projektebene ist die Erkennung von Prompt Injection und Jailbreaking mit einem mittleren Konfidenzschwellenwert erforderlich.

Das Ergebnis lautet:

  • Jede Model Armor-Vorlage, die in diesem Projekt erstellt wird, muss den Filter für die Erkennung von Prompt Injection und Jailbreaking enthalten, der mit einem Konfidenzwert von mindestens „Mittel“ festgelegt ist. Das liegt daran, dass mit der Richtlinie auf Projektebene eine Mindestanforderung für alle Vorlagen in diesem Projekt festgelegt wird.

  • Vorlagen, die außerhalb des übergeordneten Ordners dieses Projekts erstellt wurden, sind nicht von den Richtlinien dieses Ordners betroffen. Wenn Sie also eine Vorlage in einem anderen Ordner oder auf Stammebene erstellen, ist der Filter für schädliche URLs, der für diesen bestimmten Ordner festgelegt wurde, nicht automatisch erforderlich. Das zeigt, dass diese Richtlinien auf ihre jeweilige Hierarchieebene beschränkt sind und nicht global gelten, sofern sie nicht auf einer höheren, breiteren Organisationsebene festgelegt werden.

Mindesteinstellungen helfen CISOs und Sicherheitsarchitekten, Mindestsicherheitsanforderungen für alle Model Armor-Vorlagen in ihrer Organisation durchzusetzen. Diese Einstellungen sollen verhindern, dass Entwickler Sicherheitsstandards gefährden. Wenn Sie die Premium- oder Enterprise-Stufe von Security Command Center verwenden, werden Ergebnisse durch Verstöße gegen die Mindesteinstellung ausgelöst. Wenn eine Vorlage mit weniger restriktiven Einstellungen vor einer Mindesteinstellung erstellt wird, wird in Security Command Center ein Ergebnis angezeigt. Mithilfe dieser Einstellungen können Sie weniger sichere Model Armor-Vorlagen erkennen und beheben. Mit Einstellungen auf Etagebene kann Sensitive Data Protection nicht erzwungen werden.

Hinweise

Führen Sie zuerst die folgenden Schritte aus.

Erforderliche Berechtigungen erhalten

Bitten Sie Ihren Administrator, Ihnen die IAM-Rolle Model Armor Floor Setting Admin (roles/modelarmor.floorSettingsAdmin) für die Einstellungen für die Untergrenze von Model Armor zu gewähren, um die Berechtigungen zu erhalten, die Sie zum Verwalten von Einstellungen für die Untergrenze benötigen. Weitere Informationen zum Zuweisen von Rollen finden Sie unter Zugriff auf Projekte, Ordner und Organisationen verwalten.

Sie können die erforderlichen Berechtigungen auch über benutzerdefinierte Rollen oder andere vordefinierte Rollen erhalten.

APIs aktivieren

Sie müssen die Model Armor APIs aktivieren, bevor Sie Model Armor verwenden können.

Console

  1. Enable the Model Armor API.

    Enable the API

  2. Wählen Sie das Projekt aus, für das Sie Model Armor aktivieren möchten.

gcloud

Führen Sie die folgenden Schritte mit der Google Cloud CLI und der Model Armor API aus, bevor Sie beginnen:

  1. In the Google Cloud console, activate Cloud Shell.

    Activate Cloud Shell

    At the bottom of the Google Cloud console, a Cloud Shell session starts and displays a command-line prompt. Cloud Shell is a shell environment with the Google Cloud CLI already installed and with values already set for your current project. It can take a few seconds for the session to initialize.

  2. Führen Sie den folgenden Befehl aus, um den API-Endpunkt für den Model Armor-Dienst festzulegen.

    gcloud config set api_endpoint_overrides/modelarmor "https://modelarmor.LOCATION.rep.googleapis.com/"

    Ersetzen Sie LOCATION durch die Region, in der Sie Model Armor verwenden möchten.

  3. Führen Sie den folgenden Befehl aus, um Model Armor zu aktivieren.

      gcloud services enable modelarmor.googleapis.com --project=PROJECT_ID
       

    Ersetzen Sie PROJECT_ID durch die ID des Projekts.

    Einbindung in Vertex AI

    Model Armor ist in Vertex AI integriert, um Anfragen und Antworten von Gemini-Modellen anhand Ihrer festgelegten Mindesteinstellungen zu prüfen. Sie müssen Cloud Logging aktivieren, um Prompts und Antworten zu sehen. Weitere Informationen finden Sie unter Model Armor-Integration mit Vertex AI.

    Mindesteinstellungen konfigurieren

    Mit Mindesteinstellungen konfigurieren Sie die Mindestschwellenwerte für die Erkennung für Model Armor-Vorlagen. Mit diesen Einstellungen wird geprüft, ob alle neuen und geänderten Vorlagen bestimmte Anforderungen erfüllen. So konfigurieren Sie die Etagen:

    Console

    1. Rufen Sie in der Google Cloud Console die Seite Model Armor auf.

      Zu Model Armor

    2. Wählen Sie ein Projekt aus.
    3. Rufen Sie auf der Seite Model Armor den Tab Floor settings (Mindestschutz) auf und klicken Sie auf Configure floor settings (Mindestschutz konfigurieren).
    4. Wählen Sie auf der Seite Etagenkonfiguration die Konfigurationsoption aus.
    5. Konfigurieren Sie im Abschnitt Erkennungen die Erkennungseinstellungen.
    6. Optional: Wenn Sie die Sensitive Data Protection-Erkennung auswählen, müssen Sie die Sensitive Data Protection-Einstellungen konfigurieren.
    7. Legen Sie im Bereich Verantwortungsbewusste KI das Konfidenzniveau für jeden Inhaltsfilter fest.

    8. Wählen Sie im Abschnitt Dienste die Dienste aus, auf die diese Mindesteinstellungen angewendet werden sollen.

    9. Wählen Sie im Bereich Logs die Option Cloud Logging aktivieren aus, um alle Nutzer-Prompts, Modellantworten und Ergebnisse des Mindesteinstellungs-Detectors zu protokollieren.

    10. Wählen Sie Unterstützung mehrerer Sprachen aktivieren aus, um die Einstellungen für die Erkennung mehrerer Sprachen zu verwenden.

    11. Klicken Sie auf Etagenkonfiguration speichern.

    REST

    curl -X PATCH \
        -H "Content-Type: application/json" \
        -H "Authorization: Bearer $(gcloud auth print-access-token)" \
        -d '{"filterConfig" : {}, "integratedServices": "AI_PLATFORM", "aiPlatformFloorSetting":{"inspect_only":true, "enableCloudLogging":true}}' \
        "https://modelarmor.googleapis.com/v1/projects/PROJECT_ID/locations/global/floorSetting"

    Ersetzen Sie PROJECT_ID durch die ID des Projekts für die Etagenkonfiguration.

    Festlegen, wie Mindesteinstellungen übernommen werden

    Wählen Sie beim Konfigurieren von Mindesteinstellungen die Konfigurationsoption aus.

    • Mindesteinstellungen des übergeordneten Elements übernehmen: Mindesteinstellungen, die in der Ressourcenhierarchie höher festgelegt sind, werden übernommen. Klicken Sie auf Etagenkonfiguration speichern und überspringen Sie die nächsten Schritte. Wenn Sie die übernommenen Einstellungen aufrufen möchten, gehen Sie zum Tab Etagenkonfiguration.

    • Benutzerdefiniert: Sie definieren Mindesteinstellungen für dieses Projekt. Die benutzerdefinierten Einstellungen, die Sie für ein Projekt definieren, überschreiben alle übernommenen Mindesteinstellungen.

    • Deaktivieren: Deaktiviert alle übernommenen Mindesteinstellungen. Das bedeutet, dass keine Erkennungsregeln auf die Model Armor-Vorlagen und Vertex AI für Ihre Gemini-Arbeitslasten angewendet werden. Klicken Sie auf Etagenkonfiguration speichern und überspringen Sie die nächsten Schritte. Den deaktivierten Status finden Sie auf dem Tab Etagenkonfiguration.

    Festlegen, wo Mindesteinstellungen angewendet werden

    Wählen Sie einen der folgenden Dienste aus, auf die die konfigurierten Mindesteinstellungen angewendet werden sollen.

    • Model Armor – Vorlage erstellen und aktualisieren: Jede neue und geänderte Model Armor-Vorlage in einem Projekt wird geprüft, um sicherzustellen, dass die Mindesteinstellungen gemäß den Mindesteinstellungen angegeben sind.
    • Vertex AI: An Gemini-Modelle gesendete Anfragen werden geprüft und Anfragen, die die Schwellenwerte für die Mindesteinstellungen erfüllen, werden protokolliert oder blockiert.

      Wenn Sie Vertex AI auswählen, wird der Abschnitt Vertex AI angezeigt, in dem Sie festlegen können, wie die Untergrenzeneinstellungen erzwungen werden.

      • Nur prüfen: Anfragen, die nicht den Mindesteinstellungen entsprechen, werden erkannt, aber nicht blockiert.
      • Verstöße prüfen und blockieren: Anfragen, die nicht den Mindesteinstellungen entsprechen, werden erkannt und blockiert.

    Mindesteinstellungen für Model Armor ansehen

    Sie können die Mindesteinstellungen von Model Armor aufrufen, um vorhandene Einstellungen zu prüfen, die Mindestanforderungen für Ihre KI-Anwendungen zu ermitteln oder Probleme zu beheben, wenn sich eine Vorlage nicht wie erwartet verhält.

    Führen Sie den folgenden Befehl aus, um die Einstellungen für die Untergrenze von Model Armor aufzurufen.

    Konsole

    1. Rufen Sie in der Google Cloud Console die Seite Model Armor auf.

      Zu Model Armor

    2. Prüfen Sie, ob Sie das Projekt aufrufen, für das Sie Model Armor aktiviert haben.

    3. Rufen Sie auf der Seite Model Armor den Tab Floor settings (Mindestbetragseinstellungen) auf. Wenn die Etagenkonfiguration auf Organisationsebene festgelegt ist, können Sie sie hier aufrufen. Wenn keine Einstellungen für den Boden definiert sind, müssen Sie sie konfigurieren. Weitere Informationen finden Sie unter Etagenkonfiguration.

    gcloud

    • Mindesteinstellung für Model Armor für ein bestimmtes Projekt ansehen.

        gcloud model-armor floorsettings describe \
            --full-uri='projects/PROJECT_ID/locations/global/floorSetting'
    • Die Mindesteinstellung für Model Armor für eine bestimmte Organisation ansehen.

        gcloud model-armor floorsettings describe \
            --full-uri='organizations/ORGANIZATION_ID/locations/global/floorSetting'
    • Mindesteinstellung für Model Armor für einen bestimmten Ordner ansehen

         gcloud model-armor floorsettings describe \
             --full-uri='folders/FOLDER_ID/locations/global/floorSetting'

      Ersetzen Sie Folgendes:

      • PROJECT_ID: Die ID des Projekts für die Etagenkonfiguration.
      • FOLDER_ID: die ID des Ordners für die Etagenkonfiguration.
      • ORGANIZATION_ID: die ID der Organisation für die Etagenkonfiguration.

    REST

    • Mindesteinstellung für Model Armor für ein bestimmtes Projekt ansehen.

      curl -X GET \
        -H "Authorization: Bearer $(gcloud auth print-access-token)" \
        -H "Content-Type: application/json" \
        "https://modelarmor.googleapis.com/v1/projects/PROJECT_ID/locations/global/floorSetting"
    • Mindesteinstellung für Model Armor für einen bestimmten Ordner ansehen

      curl -X GET \
        -H "Authorization: Bearer $(gcloud auth print-access-token)" \
        -H "Content-Type: application/json" \
        "https://modelarmor.googleapis.com/v1/folders/FOLDER_ID/locations/global/floorSetting"
    • Die Mindesteinstellung für Model Armor für eine bestimmte Organisation ansehen.

      curl -X GET \
        -H "Authorization: Bearer $(gcloud auth print-access-token)" \
        -H "Content-Type: application/json" \
        "https://modelarmor.googleapis.com/v1/organizations/ORGANIZATION_ID/locations/global/floorSetting"

    Ersetzen Sie Folgendes:

    • PROJECT_ID: Die ID des Projekts für die Etagenkonfiguration.
    • FOLDER_ID: die ID des Ordners für die Etagenkonfiguration.
    • ORGANIZATION_ID: die ID der Organisation für die Etagenkonfiguration.

    Go

    Um diesen Code auszuführen, müssen Sie zuerst eine Go-Entwicklungsumgebung einrichten und das Model Armor Go SDK installieren.

    • Mindesteinstellung für Model Armor für ein bestimmtes Projekt ansehen.

      
      import (
      	"context"
      	"fmt"
      	"io"
      
      	modelarmor "cloud.google.com/go/modelarmor/apiv1"
      	modelarmorpb "cloud.google.com/go/modelarmor/apiv1/modelarmorpb"
      )
      
      // getProjectFloorSettings gets details of a single floor setting of a project.
      //
      // This method retrieves the details of a single floor setting of a project.
      //
      // w io.Writer: The writer to use for logging.
      // projectID string: The ID of the project.
      func getProjectFloorSettings(w io.Writer, projectID string) error {
      	ctx := context.Background()
      
      	// Create the Model Armor client.
      	client, err := modelarmor.NewClient(ctx)
      	if err != nil {
      		return fmt.Errorf("failed to create client: %w", err)
      	}
      	defer client.Close()
      
      	floorSettingsName := fmt.Sprintf("projects/%s/locations/global/floorSetting", projectID)
      
      	// Get the project floor setting.
      	req := &modelarmorpb.GetFloorSettingRequest{
      		Name: floorSettingsName,
      	}
      
      	response, err := client.GetFloorSetting(ctx, req)
      	if err != nil {
      		return fmt.Errorf("failed to get floor setting: %w", err)
      	}
      
      	// Print the retrieved floor setting using fmt.Fprintf with the io.Writer.
      	fmt.Fprintf(w, "Retrieved floor setting: %v\n", response)
      
      	return nil
      }
      
    • Mindesteinstellung für Model Armor für einen bestimmten Ordner ansehen

      
      import (
      	"context"
      	"fmt"
      	"io"
      
      	modelarmor "cloud.google.com/go/modelarmor/apiv1"
      	modelarmorpb "cloud.google.com/go/modelarmor/apiv1/modelarmorpb"
      )
      
      // getFolderFloorSettings gets details of a single floor setting of a folder.
      //
      // This method retrieves the details of a single floor setting of a folder.
      //
      // w io.Writer: The writer to use for logging.
      // folderID string: The ID of the folder.
      func getFolderFloorSettings(w io.Writer, folderID string) error {
      	ctx := context.Background()
      
      	// Create the Model Armor client.
      	client, err := modelarmor.NewClient(ctx)
      	if err != nil {
      		return fmt.Errorf("failed to create client: %w", err)
      	}
      	defer client.Close()
      
      	// Prepare folder floor setting path/name
      	floorSettingsName := fmt.Sprintf("folders/%s/locations/global/floorSetting", folderID)
      
      	// Get the folder floor setting.
      	req := &modelarmorpb.GetFloorSettingRequest{
      		Name: floorSettingsName,
      	}
      
      	response, err := client.GetFloorSetting(ctx, req)
      	if err != nil {
      		return fmt.Errorf("failed to get floor setting: %w", err)
      	}
      
      	// Print the retrieved floor setting using fmt.Fprintf with the io.Writer.
      	fmt.Fprintf(w, "Retrieved folder floor setting: %v\n", response)
      
      	return nil
      }
      
    • Die Mindesteinstellung für Model Armor für eine bestimmte Organisation ansehen.

      
      import (
      	"context"
      	"fmt"
      	"io"
      
      	modelarmor "cloud.google.com/go/modelarmor/apiv1"
      	modelarmorpb "cloud.google.com/go/modelarmor/apiv1/modelarmorpb"
      )
      
      // getOrganizationFloorSettings gets details of a single floor setting of an organization.
      //
      // This method retrieves the details of a single floor setting of an organization.
      //
      // w io.Writer: The writer to use for logging.
      // organizationID string: The ID of the organization.
      func getOrganizationFloorSettings(w io.Writer, organizationID string) error {
      	ctx := context.Background()
      
      	// Create the Model Armor client.
      	client, err := modelarmor.NewClient(ctx)
      	if err != nil {
      		return fmt.Errorf("failed to create client: %w", err)
      	}
      	defer client.Close()
      
      	floorSettingsName := fmt.Sprintf("organizations/%s/locations/global/floorSetting", organizationID)
      
      	// Get the organization floor setting.
      	req := &modelarmorpb.GetFloorSettingRequest{
      		Name: floorSettingsName,
      	}
      
      	response, err := client.GetFloorSetting(ctx, req)
      	if err != nil {
      		return fmt.Errorf("failed to get floor setting: %w", err)
      	}
      
      	// Print the retrieved floor setting using fmt.Fprintf with the io.Writer.
      	fmt.Fprintf(w, "Retrieved org floor setting: %v\n", response)
      
      	return nil
      }
      

    Java

    Um diesen Code auszuführen, müssen Sie zuerst eine Java-Entwicklungsumgebung einrichten und das Model Armor Java SDK installieren.

    • Mindesteinstellung für Model Armor für ein bestimmtes Projekt ansehen.

      
      import com.google.cloud.modelarmor.v1.FloorSetting;
      import com.google.cloud.modelarmor.v1.FloorSettingName;
      import com.google.cloud.modelarmor.v1.GetFloorSettingRequest;
      import com.google.cloud.modelarmor.v1.ModelArmorClient;
      import java.io.IOException;
      
      public class GetProjectFloorSetting {
      
        public static void main(String[] args) throws IOException {
          // TODO(developer): Replace these variables before running the sample.
          String projectId = "your-project-id";
      
          getProjectFloorSetting(projectId);
        }
      
        public static FloorSetting getProjectFloorSetting(String projectId) throws IOException {
      
          // Initialize client that will be used to send requests. This client only
          // needs to be created once, and can be reused for multiple requests.
          try (ModelArmorClient client = ModelArmorClient.create()) {
            String name = FloorSettingName.of(projectId, "global").toString();
      
            GetFloorSettingRequest request = GetFloorSettingRequest.newBuilder().setName(name).build();
      
            FloorSetting floorSetting = client.getFloorSetting(request);
            System.out.println("Fetched floor setting for project: " + projectId);
      
            return floorSetting;
          }
        }
      }
    • Mindesteinstellung für Model Armor für einen bestimmten Ordner ansehen

      
      import com.google.cloud.modelarmor.v1.FloorSetting;
      import com.google.cloud.modelarmor.v1.FloorSettingName;
      import com.google.cloud.modelarmor.v1.GetFloorSettingRequest;
      import com.google.cloud.modelarmor.v1.ModelArmorClient;
      import java.io.IOException;
      
      public class GetFolderFloorSetting {
      
        public static void main(String[] args) throws IOException {
          // TODO(developer): Replace these variables before running the sample.
          String folderId = "your-folder-id";
      
          getFolderFloorSetting(folderId);
        }
      
        public static FloorSetting getFolderFloorSetting(String folderId) throws IOException {
      
          // Initialize client that will be used to send requests. This client only
          // needs to be created once, and can be reused for multiple requests.
          try (ModelArmorClient client = ModelArmorClient.create()) {
            String name = FloorSettingName.ofFolderLocationName(folderId, "global").toString();
      
            GetFloorSettingRequest request = GetFloorSettingRequest.newBuilder().setName(name).build();
      
            FloorSetting floorSetting = client.getFloorSetting(request);
            System.out.println("Fetched floor setting for folder: " + folderId);
      
            return floorSetting;
          }
        }
      }
    • Die Mindesteinstellung für Model Armor für eine bestimmte Organisation ansehen.

      
      import com.google.cloud.modelarmor.v1.FloorSetting;
      import com.google.cloud.modelarmor.v1.FloorSettingName;
      import com.google.cloud.modelarmor.v1.GetFloorSettingRequest;
      import com.google.cloud.modelarmor.v1.ModelArmorClient;
      import java.io.IOException;
      
      public class GetOrganizationFloorSetting {
      
        public static void main(String[] args) throws IOException {
          // TODO(developer): Replace these variables before running the sample.
          String organizationId = "your-organization-id";
      
          getOrganizationFloorSetting(organizationId);
        }
      
        public static FloorSetting getOrganizationFloorSetting(String organizationId) throws IOException {
      
          // Initialize client that will be used to send requests. This client only
          // needs to be created once, and can be reused for multiple requests.
          try (ModelArmorClient client = ModelArmorClient.create()) {
            String name = FloorSettingName.ofOrganizationLocationName(organizationId, "global")
                .toString();
      
            GetFloorSettingRequest request = GetFloorSettingRequest.newBuilder().setName(name).build();
      
            FloorSetting floorSetting = client.getFloorSetting(request);
            System.out.println("Fetched floor setting for organization: " + organizationId);
      
            return floorSetting;
          }
        }
      }

    Node.js

    Um diesen Code auszuführen, müssen Sie zuerst eine Node.js-Entwicklungsumgebung einrichten und das Model Armor Node.js SDK installieren.

    • Mindesteinstellung für Model Armor für ein bestimmtes Projekt ansehen.

      /**
       * TODO(developer): Uncomment these variables before running the sample.
       */
      // const projectId = 'your-project-id';
      
      const name = `projects/${projectId}/locations/global/floorSetting`;
      
      // Imports the Modelarmor library
      const {ModelArmorClient} = require('@google-cloud/modelarmor').v1;
      
      // Instantiates a client
      const modelarmorClient = new ModelArmorClient();
      
      async function getProjectFloorSettings() {
        // Construct request
        const request = {
          name,
        };
      
        // Run request
        const [response] = await modelarmorClient.getFloorSetting(request);
        return response;
      }
      
      return await getProjectFloorSettings();
    • Mindesteinstellung für Model Armor für einen bestimmten Ordner ansehen

      /**
       * TODO(developer): Uncomment these variables before running the sample.
       */
      // const folderId = 'your-folder-id';
      
      const name = `folders/${folderId}/locations/global/floorSetting`;
      
      // Imports the Modelarmor library
      const {ModelArmorClient} = require('@google-cloud/modelarmor').v1;
      
      // Instantiates a client
      const modelarmorClient = new ModelArmorClient();
      
      async function getFolderFloorSettings() {
        // Construct request
        const request = {
          name,
        };
      
        const [response] = await modelarmorClient.getFloorSetting(request);
        return response;
      }
      
      return await getFolderFloorSettings();
    • Die Mindesteinstellung für Model Armor für eine bestimmte Organisation ansehen.

      /**
       * TODO(developer): Uncomment these variables before running the sample.
       */
      // const organizationId = 'your-organization-id';
      const name = `organizations/${organizationId}/locations/global/floorSetting`;
      
      // Imports the Modelarmor library
      const {ModelArmorClient} = require('@google-cloud/modelarmor').v1;
      
      // Instantiates a client
      const modelarmorClient = new ModelArmorClient();
      
      async function getOrganizationFloorSettings() {
        // Construct request
        const request = {
          name,
        };
      
        // Run request
        const [response] = await modelarmorClient.getFloorSetting(request);
        return response;
      }
      
      return await getOrganizationFloorSettings();

    PHP

    Um diesen Code auszuführen, müssen Sie zuerst eine PHP-Entwicklungsumgebung einrichten und das Model Armor PHP SDK installieren.

    • Mindesteinstellung für Model Armor für ein bestimmtes Projekt ansehen.

      use Google\Cloud\ModelArmor\V1\Client\ModelArmorClient;
      use Google\Cloud\ModelArmor\V1\GetFloorSettingRequest;
      
      /**
       * Gets the floor settings for a given project.
       *
       * @param string $projectId The project Id for which the floor settings is to be retrieved.
       *
       */
      function get_project_floor_settings(string $projectId): void
      {
          $client = new ModelArmorClient();
      
          $floorSettingsName = sprintf('projects/%s/locations/global/floorSetting', $projectId);
      
          $response = $client->getFloorSetting((new GetFloorSettingRequest())->setName($floorSettingsName));
      
          printf("Floor settings retrieved successfully: %s\n", $response->serializeToJsonString());
      }
    • Mindesteinstellung für Model Armor für einen bestimmten Ordner ansehen

      use Google\Cloud\ModelArmor\V1\Client\ModelArmorClient;
      use Google\Cloud\ModelArmor\V1\GetFloorSettingRequest;
      
      /**
       * Gets the floor settings for a given folder.
       *
       * @param string $folderId The folder Id for which the floor settings is to be retrieved.
       *
       */
      function get_folder_floor_settings(string $folderId): void
      {
          $client = new ModelArmorClient();
      
          $floorSettingsName = sprintf('folders/%s/locations/global/floorSetting', $folderId);
      
          $response = $client->getFloorSetting((new GetFloorSettingRequest())->setName($floorSettingsName));
      
          printf("Floor settings retrieved successfully: %s\n", $response->serializeToJsonString());
      }
    • Die Mindesteinstellung für Model Armor für eine bestimmte Organisation ansehen.

      use Google\Cloud\ModelArmor\V1\Client\ModelArmorClient;
      use Google\Cloud\ModelArmor\V1\GetFloorSettingRequest;
      
      /**
       * Gets the floor settings for a given organization.
       *
       * @param string $organizationId The organization Id for which the floor settings is to be retrieved.
       *
       */
      function get_organization_floor_settings(string $organizationId): void
      {
          $client = new ModelArmorClient();
      
          $floorSettingsName = sprintf('organizations/%s/locations/global/floorSetting', $organizationId);
      
          $response = $client->getFloorSetting((new GetFloorSettingRequest())->setName($floorSettingsName));
      
          printf("Floor settings retrieved successfully: %s\n", $response->serializeToJsonString());
      }

    Python

    Um diesen Code auszuführen, müssen Sie zuerst eine Python-Entwicklungsumgebung einrichten und das Model Armor Python SDK installieren.

    • Mindesteinstellung für Model Armor für ein bestimmtes Projekt ansehen.

      
      from google.cloud import modelarmor_v1
      
      # Create the Model Armor client.
      client = modelarmor_v1.ModelArmorClient(transport="rest")
      
      # TODO(Developer): Uncomment below variable.
      # project_id = "YOUR_PROJECT_ID"
      
      floor_settings_name = f"projects/{project_id}/locations/global/floorSetting"
      
      # Get the project floor setting.
      response = client.get_floor_setting(
          request=modelarmor_v1.GetFloorSettingRequest(name=floor_settings_name)
      )
      
      # Print the retrieved floor setting.
      print(response)
      
    • Mindesteinstellung für Model Armor für einen bestimmten Ordner ansehen

      
      from google.cloud import modelarmor_v1
      
      # Create the Model Armor client.
      client = modelarmor_v1.ModelArmorClient(transport="rest")
      
      # TODO(Developer): Uncomment below variable.
      # folder_id = "YOUR_FOLDER_ID"
      
      # Prepare folder floor setting path/name
      floor_settings_name = f"folders/{folder_id}/locations/global/floorSetting"
      
      # Get the folder floor setting.
      response = client.get_floor_setting(
          request=modelarmor_v1.GetFloorSettingRequest(name=floor_settings_name)
      )
      
      # Print the retrieved floor setting.
      print(response)
      
    • Die Mindesteinstellung für Model Armor für eine bestimmte Organisation ansehen.

      
      from google.cloud import modelarmor_v1
      
      # Create the Model Armor client.
      client = modelarmor_v1.ModelArmorClient(transport="rest")
      
      # TODO(Developer): Uncomment below variable.
      # organization_id = "YOUR_ORGANIZATION_ID"
      
      floor_settings_name = (
          f"organizations/{organization_id}/locations/global/floorSetting"
      )
      
      # Get the organization floor setting.
      response = client.get_floor_setting(
          request=modelarmor_v1.GetFloorSettingRequest(name=floor_settings_name)
      )
      
      # Print the retrieved floor setting.
      print(response)
      

    Mindesteinstellungen für Model Armor aktualisieren

    Aktualisieren Sie die Mindesteinstellungen für Model Armor, um die Mindestanforderungen für Vorlagen zu ändern, damit sie Änderungen an Sicherheitsrichtlinien widerspiegeln, Fehlkonfigurationen zu korrigieren oder Konflikte zwischen Mindesteinstellungen zu beheben.

    Führen Sie den folgenden Befehl aus, um die Einstellungen für Model Armor zu aktualisieren.

    Konsole

    1. Rufen Sie in der Google Cloud Console die Seite Model Armor auf.

      Zu Model Armor

    2. Prüfen Sie, ob Sie das Projekt aufrufen, für das Sie Model Armor aktiviert haben.

    3. Rufen Sie auf der Seite Model Armor den Tab Floor settings (Mindestschutz) auf und klicken Sie auf Configure floor settings (Mindestschutz konfigurieren).

    4. Aktualisieren Sie die Pflichtfelder und klicken Sie auf Etagenkonfiguration speichern.

    gcloud

       gcloud model-armor floorsettings update --full-uri=<full-uri-of-the-floorsetting>
    

    Beispielbefehl:

           gcloud model-armor floorsettings update \
               --malicious-uri-filter-settings-enforcement=ENABLED \
               --pi-and-jailbreak-filter-settings-enforcement=DISABLED \
               --pi-and-jailbreak-filter-settings-confidence-level=LOW_AND_ABOVE \
               --basic-config-filter-enforcement=ENABLED \
               --add-rai-settings-filters='[{"confidenceLevel": "low_and_above", "filterType": "HARASSMENT"}, {"confidenceLevel": "high", "filterType": "SEXUALLY_EXPLICIT"}]'
               --full-uri='folders/FOLDER_ID/locations/global/floorSetting' \
               --enable-floor-setting-enforcement=true
    

    Ersetzen Sie FOLDER_ID durch die ID des Ordners für die Etagenkonfiguration.

    REST

    • Aktualisieren Sie die Mindesteinstellung für Model Armor für ein bestimmtes Projekt.

      curl -X PATCH -d '{"filterConfig" :{"piAndJailbreakFilterSettings": { "filterEnforcement": "ENABLED"}, "maliciousUriFilterSettings": { "filterEnforcement": "ENABLED" }, "rai_settings":{"rai_filters":{"filter_type":"DANGEROUS", "confidence_level":"LOW_AND_ABOVE" }, \
      "rai_filters":{"filter_type":"HATE_SPEECH", "confidence_level":"LOW_AND_ABOVE" }, "rai_filters":{"filter_type":"HARASSMENT", "confidence_level":"LOW_AND_ABOVE" }, "rai_filters":{"filter_type":"SEXUALLY_EXPLICIT", "confidence_level":"LOW_AND_ABOVE" }}},"enableFloorSettingEnforcement":"true"}' -H "Content-Type: application/json" -H "Authorization: Bearer $(gcloud auth print-access-token) "https://modelarmor.googleapis.com/v1/projects/PROJECT_ID/locations/global/floorSetting"
    • Die Mindesteinstellung für Model Armor für einen bestimmten Ordner aktualisieren.

      curl -X PATCH \
        -d '{"filterConfig" :{"piAndJailbreakFilterSettings": { "filterEnforcement": "ENABLED"}, "maliciousUriFilterSettings": { "filterEnforcement": "ENABLED" }},"enableFloorSettingEnforcement":"true"}' \
        -H "Content-Type: application/json" \
        -H "Authorization: Bearer $(gcloud auth print-access-token)" \
        "https://modelarmor.googleapis.com/v1/folders/FOLDER_ID/locations/global/floorSetting"
    • Aktualisieren Sie die Mindesteinstellung für Model Armor für eine bestimmte Organisation.

      curl -X PATCH \
        -d '{"filterConfig" :{"piAndJailbreakFilterSettings": { "filterEnforcement": "ENABLED"}, "maliciousUriFilterSettings": {
            "filterEnforcement": "ENABLED" }},"enableFloorSettingEnforcement":"true"}' \
        -H "Content-Type: application/json" \
        -H "Authorization: Bearer $(gcloud auth print-access-token)" \
            "https://modelarmor.googleapis.com/v1/organizations/ORGANIZATION_ID/locations/global/floorSetting"

      Ersetzen Sie Folgendes:

      • PROJECT_ID: Die ID des Projekts für die Etagenkonfiguration.
      • FOLDER_ID: die ID des Ordners für die Etagenkonfiguration.
      • ORGANIZATION_ID: die ID der Organisation für die Etagenkonfiguration.

      Der Aktualisierungsbefehl gibt die folgende Antwort zurück:

      {
      "name": "projects/PROJECT_ID/locations/global/floorSetting",
      "updateTime": "2024-12-19T15:36:21.318191Z",
      "filterConfig": {
      "piAndJailbreakFilterSettings": {
        "filterEnforcement": "ENABLED"
      },
      "maliciousUriFilterSettings": {
      "filterEnforcement": "ENABLED"
      }
      }
      }

    Go

    Um diesen Code auszuführen, müssen Sie zuerst eine Go-Entwicklungsumgebung einrichten und das Model Armor Go SDK installieren.

    • Aktualisieren Sie die Mindesteinstellung für Model Armor für ein bestimmtes Projekt.

      
      import (
      	"context"
      	"fmt"
      	"io"
      
      	modelarmor "cloud.google.com/go/modelarmor/apiv1"
      	modelarmorpb "cloud.google.com/go/modelarmor/apiv1/modelarmorpb"
      	"google.golang.org/api/option"
      )
      
      // updateProjectFloorSettings updates the floor settings of a project.
      //
      // This method updates the floor settings of a project.
      //
      // w io.Writer: The writer to use for logging.
      // projectID string: The ID of the project.
      // locationID string: The ID of the location.
      func updateProjectFloorSettings(w io.Writer, projectID, locationID string) error {
      	ctx := context.Background()
      
      	// Create options for Model Armor client.
      	opts := option.WithEndpoint(fmt.Sprintf("modelarmor.%s.rep.googleapis.com:443", locationID))
      	// Create the Model Armor client.
      	client, err := modelarmor.NewClient(ctx, opts)
      	if err != nil {
      		return fmt.Errorf("failed to create client: %w", err)
      	}
      	defer client.Close()
      
      	// Prepare project floor setting path/name
      	floorSettingsName := fmt.Sprintf("projects/%s/locations/global/floorSetting", projectID)
      
      	// Update the project floor setting
      	// For more details on filters, please refer to the following doc:
      	// [https://cloud.google.com/security-command-center/docs/key-concepts-model-armor#ma-filters](https://cloud.google.com/security-command-center/docs/key-concepts-model-armor#ma-filters)
      	enableEnforcement := true
      	req := &modelarmorpb.UpdateFloorSettingRequest{
      		FloorSetting: &modelarmorpb.FloorSetting{
      			Name: floorSettingsName,
      			FilterConfig: &modelarmorpb.FilterConfig{
      				RaiSettings: &modelarmorpb.RaiFilterSettings{
      					RaiFilters: []*modelarmorpb.RaiFilterSettings_RaiFilter{
      						{
      							FilterType:      modelarmorpb.RaiFilterType_HATE_SPEECH,
      							ConfidenceLevel: modelarmorpb.DetectionConfidenceLevel_HIGH,
      						},
      					},
      				},
      			},
      			EnableFloorSettingEnforcement: &enableEnforcement,
      		},
      	}
      
      	response, err := client.UpdateFloorSetting(ctx, req)
      	if err != nil {
      		return fmt.Errorf("failed to update floor setting: %w", err)
      	}
      
      	// Print the updated config
      	fmt.Fprintf(w, "Updated project floor setting: %+v\n", response)
      
      	return nil
      }
      
    • Die Mindesteinstellung für Model Armor für einen bestimmten Ordner aktualisieren.

      
      import (
      	"context"
      	"fmt"
      	"io"
      
      	modelarmor "cloud.google.com/go/modelarmor/apiv1"
      	modelarmorpb "cloud.google.com/go/modelarmor/apiv1/modelarmorpb"
      	"google.golang.org/api/option"
      )
      
      // updateFolderFloorSettings updates floor settings of a folder.
      //
      // This method updates the floor settings of a folder.
      //
      // w io.Writer: The writer to use for logging.
      // folderID string: The ID of the folder.
      // locationID string: The ID of the location.
      func updateFolderFloorSettings(w io.Writer, folderID, locationID string) error {
      	ctx := context.Background()
      
      	// Create the Model Armor client.
      	client, err := modelarmor.NewClient(ctx,
      		option.WithEndpoint(fmt.Sprintf("modelarmor.%s.rep.googleapis.com:443", locationID)),
      	)
      	if err != nil {
      		return fmt.Errorf("failed to create client: %w", err)
      	}
      	defer client.Close()
      
      	// Prepare folder floor settings path/name
      	floorSettingsName := fmt.Sprintf("folders/%s/locations/global/floorSetting", folderID)
      
      	// Prepare the floor setting update
      	enableEnforcement := true
      	floorSetting := &modelarmorpb.FloorSetting{
      		Name: floorSettingsName,
      		FilterConfig: &modelarmorpb.FilterConfig{
      			RaiSettings: &modelarmorpb.RaiFilterSettings{
      				RaiFilters: []*modelarmorpb.RaiFilterSettings_RaiFilter{
      					{
      						FilterType:      modelarmorpb.RaiFilterType_HATE_SPEECH,
      						ConfidenceLevel: modelarmorpb.DetectionConfidenceLevel_HIGH,
      					},
      				},
      			},
      		},
      		EnableFloorSettingEnforcement: &enableEnforcement,
      	}
      
      	// Prepare request for updating the floor setting.
      	req := &modelarmorpb.UpdateFloorSettingRequest{
      		FloorSetting: floorSetting,
      	}
      
      	// Update the floor setting.
      	response, err := client.UpdateFloorSetting(ctx, req)
      	if err != nil {
      		return fmt.Errorf("failed to update floor setting: %w", err)
      	}
      
      	// Print the updated config
      	fmt.Fprintf(w, "Updated folder floor setting: %v\n", response)
      
      	return nil
      
      }
      
    • Aktualisieren Sie die Mindesteinstellung für Model Armor für eine bestimmte Organisation.

      
      import (
      	"context"
      	"fmt"
      	"io"
      
      	modelarmor "cloud.google.com/go/modelarmor/apiv1"
      	modelarmorpb "cloud.google.com/go/modelarmor/apiv1/modelarmorpb"
      	"google.golang.org/api/option"
      )
      
      // updateOrganizationFloorSettings updates floor settings of an organization.
      //
      // This method updates the floor settings of an organization.
      //
      // w io.Writer: The writer to use for logging.
      // organizationID string: The ID of the organization.
      // locationID string: The ID of the location.
      func updateOrganizationFloorSettings(w io.Writer, organizationID, locationID string) error {
      	ctx := context.Background()
      
      	// Create options for Model Armor client.
      	opts := option.WithEndpoint(fmt.Sprintf("modelarmor.%s.rep.googleapis.com:443", locationID))
      	// Create the Model Armor client.
      	client, err := modelarmor.NewClient(ctx, opts)
      	if err != nil {
      		return fmt.Errorf("failed to create client: %w", err)
      	}
      	defer client.Close()
      
      	// Prepare organization floor setting path/name
      	floorSettingsName := fmt.Sprintf("organizations/%s/locations/global/floorSetting", organizationID)
      
      	// Update the organization floor setting
      	// For more details on filters, please refer to the following doc:
      	// [https://cloud.google.com/security-command-center/docs/key-concepts-model-armor#ma-filters](https://cloud.google.com/security-command-center/docs/key-concepts-model-armor#ma-filters)
      	enableEnforcement := true
      	req := &modelarmorpb.UpdateFloorSettingRequest{
      		FloorSetting: &modelarmorpb.FloorSetting{
      			Name: floorSettingsName,
      			FilterConfig: &modelarmorpb.FilterConfig{
      				RaiSettings: &modelarmorpb.RaiFilterSettings{
      					RaiFilters: []*modelarmorpb.RaiFilterSettings_RaiFilter{
      						{
      							FilterType:      modelarmorpb.RaiFilterType_HATE_SPEECH,
      							ConfidenceLevel: modelarmorpb.DetectionConfidenceLevel_HIGH,
      						},
      					},
      				},
      			},
      			EnableFloorSettingEnforcement: &enableEnforcement,
      		},
      	}
      
      	response, err := client.UpdateFloorSetting(ctx, req)
      	if err != nil {
      		return fmt.Errorf("failed to update floor setting: %w", err)
      	}
      
      	// Print the updated config
      	fmt.Fprintf(w, "Updated org floor setting: %+v\n", response)
      

    Java

    Um diesen Code auszuführen, müssen Sie zuerst eine Java-Entwicklungsumgebung einrichten und das Model Armor Java SDK installieren.

    Node.js

    Um diesen Code auszuführen, müssen Sie zuerst eine Node.js-Entwicklungsumgebung einrichten und das Model Armor Node.js SDK installieren.

    • Aktualisieren Sie die Mindesteinstellung für Model Armor für ein bestimmtes Projekt.

      /**
       * TODO(developer): Uncomment these variables before running the sample.
       */
      // const projectId = 'your-project-id';
      
      const modelarmor = require('@google-cloud/modelarmor');
      const {ModelArmorClient} = modelarmor.v1;
      const {protos} = modelarmor;
      
      // Initiate client
      const client = new ModelArmorClient();
      
      async function updateProjectFloorSettings() {
        const floorSettingsName = `projects/${projectId}/locations/global/floorSetting`;
      
        // Build the floor settings with your preferred filters
        // For more details on filters, please refer to the following doc:
        // https://cloud.google.com/security-command-center/docs/key-concepts-model-armor#ma-filters
        const floorSetting = {
          name: floorSettingsName,
          filterConfig: {
            raiSettings: {
              raiFilters: [
                {
                  filterType:
                    protos.google.cloud.modelarmor.v1.RaiFilterType.HARASSMENT,
                  confidenceLevel:
                    protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel
                      .LOW_AND_ABOVE,
                },
                {
                  filterType:
                    protos.google.cloud.modelarmor.v1.RaiFilterType
                      .SEXUALLY_EXPLICIT,
                  confidenceLevel:
                    protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel
                      .LOW_AND_ABOVE,
                },
              ],
            },
          },
          enableFloorSettingEnforcement: true,
        };
      
        const request = {
          floorSetting: floorSetting,
        };
      
        const [response] = await client.updateFloorSetting(request);
        return response;
      }
      
      return await updateProjectFloorSettings();
    • Die Mindesteinstellung für Model Armor für einen bestimmten Ordner aktualisieren.

      /**
       * TODO(developer): Uncomment these variables before running the sample.
       */
      // const folderId = 'your-folder-id';
      
      // Imports the Model Armor library
      const modelarmor = require('@google-cloud/modelarmor');
      const {ModelArmorClient} = modelarmor.v1;
      const {protos} = modelarmor;
      
      // Instantiates a client
      const client = new ModelArmorClient();
      
      async function updateFolderFloorSettings() {
        const floorSettingsName = `folders/${folderId}/locations/global/floorSetting`;
      
        // Build the floor settings with your preferred filters
        // For more details on filters, please refer to the following doc:
        // https://cloud.google.com/security-command-center/docs/key-concepts-model-armor#ma-filters
        const floorSetting = {
          name: floorSettingsName,
          filterConfig: {
            raiSettings: {
              raiFilters: [
                {
                  filterType:
                    protos.google.cloud.modelarmor.v1.RaiFilterType.HARASSMENT,
                  confidenceLevel:
                    protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel
                      .LOW_AND_ABOVE,
                },
                {
                  filterType:
                    protos.google.cloud.modelarmor.v1.RaiFilterType
                      .SEXUALLY_EXPLICIT,
                  confidenceLevel:
                    protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel
                      .LOW_AND_ABOVE,
                },
              ],
            },
          },
          enableFloorSettingEnforcement: true,
        };
      
        const request = {
          floorSetting: floorSetting,
        };
      
        const [response] = await client.updateFloorSetting(request);
        return response;
      }
      
      return await updateFolderFloorSettings();
    • Aktualisieren Sie die Mindesteinstellung für Model Armor für eine bestimmte Organisation.

      /**
       * TODO(developer): Uncomment these variables before running the sample.
       */
      // const organizationId = 'your-organization-id';
      
      const modelarmor = require('@google-cloud/modelarmor');
      const {ModelArmorClient} = modelarmor.v1;
      const {protos} = modelarmor;
      
      const client = new ModelArmorClient();
      
      async function updateOrganizationFloorSettings() {
        const floorSettingsName = `organizations/${organizationId}/locations/global/floorSetting`;
      
        // Build the floor settings with your preferred filters
        // For more details on filters, please refer to the following doc:
        // https://cloud.google.com/security-command-center/docs/key-concepts-model-armor#ma-filters
        const floorSetting = {
          name: floorSettingsName,
          filterConfig: {
            raiSettings: {
              raiFilters: [
                {
                  filterType:
                    protos.google.cloud.modelarmor.v1.RaiFilterType.HARASSMENT,
                  confidenceLevel:
                    protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel
                      .LOW_AND_ABOVE,
                },
                {
                  filterType:
                    protos.google.cloud.modelarmor.v1.RaiFilterType
                      .SEXUALLY_EXPLICIT,
                  confidenceLevel:
                    protos.google.cloud.modelarmor.v1.DetectionConfidenceLevel
                      .LOW_AND_ABOVE,
                },
              ],
            },
          },
          enableFloorSettingEnforcement: true,
        };
      
        const request = {
          floorSetting: floorSetting,
        };
      
        const [response] = await client.updateFloorSetting(request);
        return response;
      }
      
      return await updateOrganizationFloorSettings();

    PHP

    Um diesen Code auszuführen, müssen Sie zuerst eine PHP-Entwicklungsumgebung einrichten und das Model Armor PHP SDK installieren.

    • Aktualisieren Sie die Mindesteinstellung für Model Armor für ein bestimmtes Projekt.

      use Google\Cloud\ModelArmor\V1\Client\ModelArmorClient;
      use Google\Cloud\ModelArmor\V1\RaiFilterType;
      use Google\Cloud\ModelArmor\V1\DetectionConfidenceLevel;
      use Google\Cloud\ModelArmor\V1\UpdateFloorSettingRequest;
      use Google\Cloud\ModelArmor\V1\FilterConfig;
      use Google\Cloud\ModelArmor\V1\FloorSetting;
      use Google\Cloud\ModelArmor\V1\RaiFilterSettings;
      use Google\Cloud\ModelArmor\V1\RaiFilterSettings\RaiFilter;
      
      /**
       * Updates the floor settings for a given project.
       *
       * @param string $projectId The project Id for which the floor settings is to be updated.
       *
       */
      function update_project_floor_settings(string $projectId): void
      {
          $client = new ModelArmorClient();
      
          $floorSettingsName = sprintf('projects/%s/locations/global/floorSetting', $projectId);
      
          // Build the floor settings with your preferred filters
          // For more details on filters, please refer to the following doc:
          // https://cloud.google.com/security-command-center/docs/key-concepts-model-armor#ma-filters
      
          $raiFilterSetting = (new RaiFilterSettings())
              ->setRaiFilters([
                  (new RaiFilter())
                      ->setFilterType(RaiFilterType::HATE_SPEECH)
                      ->setConfidenceLevel(DetectionConfidenceLevel::HIGH)
              ]);
      
          $filterConfig = (new FilterConfig())->setRaiSettings($raiFilterSetting);
          $floorSetting = (new FloorSetting())
              ->setName($floorSettingsName)
              ->setFilterConfig($filterConfig)
              ->setEnableFloorSettingEnforcement(true);
      
          $updateRequest = (new UpdateFloorSettingRequest())->setFloorSetting($floorSetting);
      
          $response = $client->updateFloorSetting($updateRequest);
      
          printf("Floor setting updated: %s\n", $response->getName());
      }
    • Die Mindesteinstellung für Model Armor für einen bestimmten Ordner aktualisieren.

      use Google\Cloud\ModelArmor\V1\Client\ModelArmorClient;
      use Google\Cloud\ModelArmor\V1\RaiFilterType;
      use Google\Cloud\ModelArmor\V1\DetectionConfidenceLevel;
      use Google\Cloud\ModelArmor\V1\UpdateFloorSettingRequest;
      use Google\Cloud\ModelArmor\V1\FilterConfig;
      use Google\Cloud\ModelArmor\V1\FloorSetting;
      use Google\Cloud\ModelArmor\V1\RaiFilterSettings;
      use Google\Cloud\ModelArmor\V1\RaiFilterSettings\RaiFilter;
      
      /**
       * Updates the floor settings for a given folder.
       *
       * @param string $folderId The folder Id for which the floor settings is to be updated.
       *
       */
      function update_folder_floor_settings(string $folderId): void
      {
          $client = new ModelArmorClient();
      
          $floorSettingsName = sprintf('folders/%s/locations/global/floorSetting', $folderId);
      
          // Build the floor settings with your preferred filters
          // For more details on filters, please refer to the following doc:
          // https://cloud.google.com/security-command-center/docs/key-concepts-model-armor#ma-filters
      
          $raiFilterSetting = (new RaiFilterSettings())
              ->setRaiFilters([
                  (new RaiFilter())
                      ->setFilterType(RaiFilterType::HATE_SPEECH)
                      ->setConfidenceLevel(DetectionConfidenceLevel::HIGH)
              ]);
      
          $filterConfig = (new FilterConfig())->setRaiSettings($raiFilterSetting);
          $floorSetting = (new FloorSetting())
              ->setName($floorSettingsName)
              ->setFilterConfig($filterConfig)
              ->setEnableFloorSettingEnforcement(true);
      
          $updateRequest = (new UpdateFloorSettingRequest())->setFloorSetting($floorSetting);
      
          $response = $client->updateFloorSetting($updateRequest);
      
          printf("Floor setting updated: %s\n", $response->getName());
      }
    • Aktualisieren Sie die Mindesteinstellung für Model Armor für eine bestimmte Organisation.

      use Google\Cloud\ModelArmor\V1\Client\ModelArmorClient;
      use Google\Cloud\ModelArmor\V1\RaiFilterType;
      use Google\Cloud\ModelArmor\V1\DetectionConfidenceLevel;
      use Google\Cloud\ModelArmor\V1\UpdateFloorSettingRequest;
      use Google\Cloud\ModelArmor\V1\FilterConfig;
      use Google\Cloud\ModelArmor\V1\FloorSetting;
      use Google\Cloud\ModelArmor\V1\RaiFilterSettings;
      use Google\Cloud\ModelArmor\V1\RaiFilterSettings\RaiFilter;
      
      /**
       * Updates the floor settings for a given organization.
       *
       * @param string $organizationId The organization Id for which the floor settings is to be updated.
       *
       */
      function update_organization_floor_settings(string $organizationId)
      {
          $client = new ModelArmorClient();
      
          $floorSettingsName = sprintf('organizations/%s/locations/global/floorSetting', $organizationId);
      
          // Build the floor settings with your preferred filters
          // For more details on filters, please refer to the following doc:
          // https://cloud.google.com/security-command-center/docs/key-concepts-model-armor#ma-filters
      
          $raiFilterSetting = (new RaiFilterSettings())
              ->setRaiFilters([
                  (new RaiFilter())
                      ->setFilterType(RaiFilterType::HATE_SPEECH)
                      ->setConfidenceLevel(DetectionConfidenceLevel::HIGH)
              ]);
      
          $filterConfig = (new FilterConfig())->setRaiSettings($raiFilterSetting);
          $floorSetting = (new FloorSetting())
              ->setName($floorSettingsName)
              ->setFilterConfig($filterConfig)
              ->setEnableFloorSettingEnforcement(true);
      
          $updateRequest = (new UpdateFloorSettingRequest())->setFloorSetting($floorSetting);
      
          $response = $client->updateFloorSetting($updateRequest);
      
          printf("Floor setting updated: %s\n", $response->getName());
      }

    Python

    Um diesen Code auszuführen, müssen Sie zuerst eine Python-Entwicklungsumgebung einrichten und das Model Armor Python SDK installieren.

    Ergebnisse zu Verstößen gegen Mindestbeträge prüfen

    Jedes Model Armor-Ergebnis identifiziert einen Verstoß gegen die Mindesteinstellungen. Ein Verstoß tritt auf, wenn eine Model Armor-Vorlage die Mindestsicherheitsstandards nicht erfüllt, die durch die Mindesteinstellungen der Ressourcenhierarchie definiert sind. Mindesteinstellungen definieren die Mindestanforderungen für Vorlagen. Bei einem Verstoß gegen die Mindestumsatz-Einstellung kann es sich um eine Vorlage handeln, in der erforderliche Filter fehlen oder die nicht das Mindestkonfidenzniveau für diese Filter erreicht. Wenn ein Verstoß erkannt wird, wird in Security Command Center ein Ergebnis mit hoher Schwere generiert. Im Ergebnis werden die verletzte Mindesteinstellung, die nicht konforme Vorlage und Details zum Verstoß angegeben.

    Das folgende Beispiel zeigt das Feld sourceProperties des Ergebnisses. Dieser Verstoß im Zusammenhang mit dem Filter für schädliche URIs ist aufgetreten, weil die Vorlageneinstellung für maliciousUriFilterSettings DISABLED ist, die Mindesteinstellungen jedoch ENABLED erfordern.

    {
      "filterConfig": {
        "raiSettings": {
          "raiFilters": [
            {
              "filterType": "HATE_SPEECH",
              "confidenceLevel": {
                "floorSettings": "LOW_AND_ABOVE",
                "template": "MEDIUM_AND_ABOVE"
              }
            },
            {
              "filterType": "HARASSMENT",
              "confidenceLevel": {
                "floorSettings": "MEDIUM_AND_ABOVE",
                "template": "HIGH"
              }
            }
          ]
        },
        "piAndJailbreakFilterSettings": {
          "confidenceLevel": {
            "floorSettings": "LOW_AND_ABOVE",
            "template": "HIGH"
          }
        },
        "maliciousUriFilterSettings": {
          "floorSettings": "ENABLED",
          "template": "DISABLED"
        }
      }
    }

    Nächste Schritte