app:
  description: 提示されたIAMポリシーを解析し、最小権限化と危険な許可を指摘するワークフロー
  icon: 🔐
  icon_background: '#FFEAD5'
  mode: workflow
  name: IAMポリシー簡易レビュー
  use_icon_as_answer_icon: false
kind: app
version: 0.6.0
workflow:
  conversation_variables: []
  environment_variables: []
  features:
    file_upload:
      image:
        enabled: false
    opening_statement: ''
    suggested_questions: []
    suggested_questions_after_answer:
      enabled: false
    text_to_speech:
      enabled: false
  graph:
    edges:
    - data:
        sourceType: start
        targetType: code
      id: start-to-code1
      source: start
      target: code1
    - data:
        sourceType: code
        targetType: llm
      id: code1-to-llm1
      source: code1
      target: llm1
    - data:
        sourceType: llm
        targetType: end
      id: llm1-to-end
      source: llm1
      target: end
    nodes:
    - data:
        title: 開始
        type: start
        variables:
        - label: query
          max_length: 2048
          options: []
          required: true
          type: paragraph
          variable: query
      height: 90
      id: start
      position:
        x: 80
        y: 282
      type: custom
      width: 244
    - data:
        title: ポリシーパース（JSON整形）
        type: code
        code_language: python3
        code: "def _safe_str(v):\n    \"\"\"Convert any value to string safely.\"\"\
          \"\n    if v is None:\n        return \"\"\n    if isinstance(v, list):\n\
          \        return \"\\n\".join(str(i) for i in v)\n    return str(v)\n\ndef\
          \ _safe_list(v):\n    \"\"\"Ensure value is a list.\"\"\"\n    if v is None:\n\
          \        return []\n    if isinstance(v, str):\n        return [v]\n   \
          \ if isinstance(v, list):\n        return v\n    return [v]\n\ndef main(**kwargs)\
          \ -> dict:\n    inputs = kwargs\n    import json\n    raw = inputs.get(\"\
          policy_text\")\n    if raw is None:\n        raw = \"\"\n    s = str(raw)\n\
          \    try:\n        parsed = json.loads(s)\n        normalized = json.dumps(parsed,\
          \ indent=2, ensure_ascii=False)\n        valid = True\n    except Exception:\n\
          \        normalized = s\n        valid = False\n    header = \"VALID_JSON:\
          \ \" + (\"true\" if valid else \"false\")\n    result = header + \"\\n\"\
          \ + normalized\n    return dict(policy_text=result)\n"
        variables:
        - value_selector:
          - start
          - query
          variable: policy_text
        outputs:
          policy_text:
            type: string
            children: null
      height: 90
      id: code1
      position:
        x: 380
        y: 282
      type: custom
      width: 244
    - data:
        title: IAMポリシー診断（AI）
        type: llm
        model:
          provider: openai
          name: gpt-5-mini
          mode: chat
          completion_params:
            temperature: 0.2
        prompt_template:
        - role: system
          text: "あなたはクラウドセキュリティの専門家です。与えられたIAMポリシーを解析し、以下を出力してください。\n\n出力フォーマット（JSON）:\n\
            {\n  \"summary\": \"短い要約（日本語）\",\n  \"dangerous_permissions\": [\"権限を列挙\"\
            ],\n  \"least_privilege_recommendations\": [\"改善案を箇条書き\"],\n  \"remediation_steps\"\
            : [\"具体的な修正手順\"],\n  \"example_least_privilege_policy\": \"最小権限化したポリシー（JSON文字列）\"\
            \n}\n\n注意:\n- 危険と判断する根拠を各項目で簡潔に記載すること。\n- example_least_privilege_policy\
            \ は動作確認のための簡易例とし、コメントではなく有効なJSON文字列を返すこと。"
        - role: user
          text: '以下の正規化されたポリシーをレビューし、上記フォーマットで返してください。


            ポリシー:

            {{#code1.policy_text#}}'
        vision:
          enabled: false
        memory: null
        context:
          enabled: false
      height: 90
      id: llm1
      position:
        x: 680
        y: 282
      type: custom
      width: 244
    - data:
        title: 終了
        type: end
        outputs:
        - value_selector:
          - llm1
          - text
          variable: result
      id: end
      position:
        x: 980
        y: 282
      type: custom
      height: 90
      width: 244
  hash: null
