Model Armor の階数設定

Model Armor の下限設定では、 Google Cloudリソース階層の特定の場所(組織、フォルダ、プロジェクト レベル)で作成されるすべての Model Armor テンプレートの最小要件を指定するルールを定義します。互いに競合する複数の床設定がある場合は、リソース階層の下位の設定が優先されます。たとえば、フォルダレベルとプロジェクト レベルで下限設定ポリシーが作成されている場合、プロジェクト レベルのポリシーが適用されます。

以下に、Model Armor の床設定ポリシーの仕組みを示す例を示します。フロア ポリシー X は、悪意のある URL フィルタが有効になっているフォルダに設定されています。フロア ポリシー Y は、そのフォルダ内のプロジェクトに設定され、プロンプト挿入と不正使用の検出フィルタに対して中程度の信頼度しきい値が設定されています。最終的には、プロジェクトで作成されたすべての Model Armor テンプレートに、少なくともプロンプト挿入とジェイルブレイク検出フィルタを設定し、信頼度のしきい値を中程度にする必要がありますが、悪意のある URL フィルタは必要ありません。

フロア設定を使用すると、CISO とセキュリティ アーキテクトは組織内のすべての Model Armor テンプレートに最小限のセキュリティ対策を適用し、個々のデベロッパーが誤ってまたは意図的にセキュリティ基準を許容レベル以下に下げないようにすることができます。Security Command Center の Premium ティアまたは Enterprise ティアをご利用のお客様の場合、下限設定違反により検出結果がトリガーされます。つまり、フロア設定の前にテンプレートが作成され、テンプレートに制限の緩い設定が含まれている場合、Security Command Center に検出結果が表示され、安全性の低い Model Armor テンプレートの特定と修正に役立ちます。

Model Armor の階数設定を有効または無効にする

Model Armor の階数設定を有効にするには、enable_floor_setting_enforcement フラグを true に設定します。次の例に、その方法を示します。

gcloud

  • 特定のプロジェクトで Model Armor の階数設定を有効にする。

      gcloud model-armor floorsettings update \
       --full-uri='projects/PROJECT_ID/locations/global/floorSetting' \
       --enable-floor-setting-enforcement=true
    
  • 特定の組織で Model Armor の階数設定を有効にします。

      gcloud model-armor floorsettings update \
      --full-uri='organizations/ORGANIZATION_ID/locations/global/floorSetting' \
      --enable-floor-setting-enforcement=true
    
  • 特定のフォルダに対して Model Armor の階数設定を有効にします。

      gcloud model-armor floorsettings update \
      --full-uri='folders/FOLDER_ID/locations/global/floorSetting' \
      --enable-floor-setting-enforcement=true
    

    次のように置き換えます。

  • PROJECT_ID は、テンプレートのプロジェクトの ID です。

  • FOLDER_ID は、テンプレートのフォルダの ID です。

  • ORGANIZATION_ID は、テンプレートの組織の ID です。

REST

  curl -X PATCH
  -d '{"enable_floor_setting_enforcement" : "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?update_mask=enable_floor_setting_enforcement"
  

PROJECT_ID は、テンプレートのプロジェクトの ID に置き換えます。

Model Armor の床の設定を使用しない場合は、filter_config フラグを empty に設定するか、enable_floor_setting_enforcement フラグを false に設定します。

gcloud

    gcloud model-armor floorsettings get 
--full-uri='projects/PROJECT_ID/locations/global/floorSetting'
Flags --full-uri = name of the floor setting resource
--enable-floor-setting-enforcement=false
--filterConfig = {}

PROJECT_ID は、テンプレートのプロジェクトの ID に置き換えます。

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

PROJECT_ID は、テンプレートのプロジェクトの ID に置き換えます。

Model Armor の階数設定を表示する

次のコマンドを実行して、Model Armor の床の設定を表示します。

gcloud

  • 特定のプロジェクトの Model Armor の階数設定を表示する。

      gcloud model-armor floorsettings describe \
      --full-uri='projects/PROJECT_ID/locations/global/floorSetting'
  • 特定の組織の Model Armor の階数設定を表示します。

      gcloud model-armor floorsettings describe \
      --full-uri='organizations/ORGANIZATION_ID/locations/global/floorSetting'
  • 特定のフォルダの Model Armor の階数設定を表示する。

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

    次のように置き換えます。

    • PROJECT_ID は、テンプレートのプロジェクトの ID です。
    • FOLDER_ID は、テンプレートのフォルダの ID です。
    • ORGANIZATION_ID は、テンプレートの組織の ID です。

REST

  • 特定のプロジェクトの Model Armor の階数設定を表示する。

    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"
  • 特定のフォルダの Model Armor の階数設定を表示する。

    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"
  • 特定の組織の Model Armor の階数設定を表示します。

    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"

次のように置き換えます。

  • PROJECT_ID は、テンプレートのプロジェクトの ID です。
  • FOLDER_ID は、テンプレートのフォルダの ID です。
  • ORGANIZATION_ID は、テンプレートの組織の ID です。

Python

このコマンドを実行するには、まず Python で Model Armor クライアントを初期化します。

  • 特定のプロジェクトの Model Armor の階数設定を表示する。

    request = modelarmor_v1.GetFloorSettingRequest(
    floor_setting={
      "name": "projects/PROJECT_ID/locations/global/floorSetting",
    }
    )
    response = client.get_floor_setting(request=request)
  • 特定のフォルダの Model Armor の階数設定を表示する。

    request = modelarmor_v1.GetFloorSettingRequest(
    floor_setting={
      "name": "folders/FOLDER_ID/locations/global/floorSetting",
    }
    )
    response = client.get_floor_setting(request=request)
  • 特定の組織の Model Armor の階数設定を表示します。

    request = modelarmor_v1.GetFloorSettingRequest(
    floor_setting={
      "name": "organizations/ORGANIZATION_ID/locations/global/floorSetting",
    }
    )
    response = client.get_floor_setting(request=request)

    次のように置き換えます。

    • PROJECT_ID は、テンプレートが属するプロジェクトの ID です。
    • FOLDER_ID は、テンプレートのフォルダの ID です。
    • ORGANIZATION_ID は、テンプレートの組織の ID です。

Model Armor の階数設定を更新する

次のコマンドを実行して、Model Armor の床の設定を更新します。

gcloud

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

コマンドの例:

       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

FOLDER_ID は、テンプレートのフォルダの ID に置き換えます。

REST

  • 特定のプロジェクトの Model Armor の階数設定を更新します。

    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" }}},"enable_floor_setting_enforcement":"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"
  • 特定のフォルダの Model Armor の階数設定を更新します。

    curl -X PATCH \
    -d '{"filterConfig" :{"piAndJailbreakFilterSettings": { "filterEnforcement": "ENABLED"}, "maliciousUriFilterSettings": { "filterEnforcement": "ENABLED" }},"enable_floor_setting_enforcement":"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"
  • 特定の組織の Model Armor の階数設定を更新します。

    curl -X PATCH \
    -d '{"filterConfig" :{"piAndJailbreakFilterSettings": { "filterEnforcement": "ENABLED"}, "maliciousUriFilterSettings": { "filterEnforcement": "ENABLED" }},"enable_floor_setting_enforcement":"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"

    次のように置き換えます。

    • PROJECT_ID は、テンプレートのプロジェクトの ID です。
    • FOLDER_ID は、テンプレートのフォルダの ID です。
    • ORGANIZATION_ID は、テンプレートの組織の ID です。

    update コマンドは、次のレスポンスを返します。

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

Python

このコマンドを実行するには、まず Python で Model Armor クライアントを初期化します。

  • 特定のプロジェクトの Model Armor の階数設定を更新します。

    request = modelarmor_v1.UpdateFloorSettingRequest(
    floor_setting={
      "name": "projects/PROJECT_ID/locations/global/floorSetting",
      "filter_config": FILTER_CONFIG,
      "enable_floor_setting_enforcement": True
    }
    )
    response = client.update_floor_setting(request=request)
  • 特定のフォルダの Model Armor の階数設定を更新します。

    request = modelarmor_v1.UpdateFloorSettingRequest(
    floor_setting={
      "name": "folders/FOLDER_ID/locations/global/floorSetting",
      "filter_config": FILTER_CONFIG
      "enable_floor_setting_enforcement": True
    }
    )
    response = client.update_floor_setting(request=request)
  • 特定の組織の Model Armor の階数設定を更新します。

    request = modelarmor_v1.UpdateFloorSettingRequest(
    floor_setting={
      "name": "organizations/ORGANIZATION_ID/locations/global/floorSetting",
      "filter_config": FILTER_CONFIG
      "enable_floor_setting_enforcement": True
    }
    )
    response = client.update_floor_setting(request=request)

    次のように置き換えます。

  • FILTER_CONFIG は、テンプレートのフィルタ構成です。

  • PROJECT_ID は、テンプレートが属するプロジェクトの ID です。

  • FOLDER_ID: テンプレートのフォルダの ID。

  • ORGANIZATION_ID は、テンプレートの組織の ID です。

階数設定の違反

各 Model Armor サービスの検出結果は、Model Armor テンプレートがリソース階層のフロア設定で定義された最小セキュリティ基準を満たしていない場合に発生するフロア設定違反を特定します。下限の設定は、テンプレート内の各フィルタで許可される最も緩いレベルを指定します。フロア設定違反は、必須のフィルタが含まれていないテンプレートや、それらのフィルタの最小信頼レベルを満たしていないテンプレートに関するものです。違反が検出されると、重大度の検出結果が Security Command Center にパブリッシュされます。検出結果には、違反している床の設定、準拠していないテンプレート、違反の詳細が指定されます。詳細については、Model Armor サービスの検出結果をご覧ください。

床設定違反の検出結果の source_properties フィールドの例を次に示します。

{
  "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"
    }
  }
}

次のステップ