Skip to content

[] Create helm/values.schema.json with JSON Schema validation including enum, minimum, and if/then dependency rules#289

Merged
zoetaka38 merged 2 commits into
mainfrom
feature/019f0d78fbc2-019f0d78fbc2
Jun 29, 2026
Merged

[] Create helm/values.schema.json with JSON Schema validation including enum, minimum, and if/then dependency rules#289
zoetaka38 merged 2 commits into
mainfrom
feature/019f0d78fbc2-019f0d78fbc2

Conversation

@red-codens

@red-codens red-codens Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Type of Change

  • feat — new feature
  • fix — bug fix
  • chore — tooling / maintenance
  • docs — documentation only
  • refactor — code change that neither fixes a bug nor adds a feature
  • test — adding or updating tests
  • ci — CI/CD configuration

Testing

Checklist

  • Tests pass locally
  • Lint clean (task lint)
  • Commit messages follow Conventional Commits

Task Goal

Target Repository

Corevice/open-git
All work for this task belongs in this repository. Do the implementation inside this repository's directory in the workspace; do not search or edit other repositories unless this task explicitly requires a cross-repo change.

Context

The PRD requires values.schema.json to reject bad installs at helm install time: wrong databaseType, missing externalDatabase.host when external mode is chosen, missing ingress.host when ingress is enabled, and non-integer replica counts. This file must be valid JSON Schema draft-07 understood by Helm.

Steps

  1. Create helm/values.schema.json — root {"$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "additionalProperties": true, "properties": {...}}
  2. Add global property with nested databaseType: {type: "string", enum: ["internal", "external"]} and storageClass: {type: "string"}
  3. Add replicaCount: {type: "integer", minimum: 1}
  4. Add autoscaling object with enabled: {type: "boolean"}, minReplicas: {type: "integer", minimum: 1}, maxReplicas: {type: "integer", minimum: 1}, targetCPUUtilizationPercentage: {type: "integer", minimum: 1, maximum: 100}
  5. Add ingress property object; add a top-level if/then block: if: {properties: {ingress: {properties: {enabled: {const: true}}}}, required: ["ingress"]} then {properties: {ingress: {required: ["host"], properties: {host: {minLength: 1}}}}}
  6. Add second top-level if/then block for external database: if: {properties: {global: {properties: {databaseType: {const: "external"}}}}} then {properties: {externalDatabase: {required: ["host"], properties: {host: {minLength: 1}}}}}
  7. Add persistence.repositories.size: {type: "string", pattern: "^[0-9]+[KMGT]i?$"} and persistence.repositories.retainOnDelete: {type: "boolean"}
  8. Add ssh.serviceType: {type: "string", enum: ["LoadBalancer", "NodePort", "ClusterIP"]}

Verification Checklist

  • helm/values.schema.json is valid JSO

Changes Made

Creating
helm /values.schema.json per the PR
D. Checking whether
it already
exists and the repo
layout
.

Creating helm/values.schema .json with the
required
properties
and conditional
validation blocks
.

Created
helm/values .schema.json with
JSON
Schema draft-07
validation for
Helm install
-time
checks
.

**
Schema structure
:**

  • Root object
    with additional Properties: true

  • global .databaseType enum
    : internal
    | external

  • re plicaCount integer
    with
    minimum: 1

  • aut oscaling with
    typed
    fields
    and
    CPU
    percentage
    bounds (
    1–100)

  • Top
    -level if /then
    requiring non
    -empty ingress.host when ingress.enabled is
    true

  • Second
    if/then (
    via
    allOf)
    requiring non-empty externalDatabase.host
    when global.database Type is external

  • persistence.repositories.size pattern
    for
    Kubernetes quantity strings

  • ssh .serviceType enum
    : LoadBalancer, NodePort, ClusterIP

[P
URPLE-M
ODIFIED-FILES
]
helm/values
.schema.json
[/
PURPLE
-MODIFIED-F
ILES]

Task ID: 019f0d78-fbc2-7333-a937-caab02a15c93
Generated by Purple Codens

…luding enum, minimum, and if/then dependency rules

@orange-codens orange-codens Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍊 Orange Codens レビュー

重大な構造問題が1件あります。 トップレベルに if/then を直書きしつつ allOf も併置している構造は、PRD の設計意図(両ルールを allOf で管理)と不整合であり、将来的な保守性を損ないます(critical)。また allOf 内の外部DB条件に required: ["global"] が欠落しており、global キー省略時に then が誤発動する可能性があります(high)。persistence.repositories.size の Kubernetes quantity パターンも一部不完全です(medium)。全体的に JSON Schema 自体は valid な draft-07 であり Helm は読み込めますが、上記の条件漏れによりバリデーションの抜けが発生します。

🔒 セキュリティ: このPRはHelm install時のバリデーションスキーマを追加するものです。セキュリティ観点での主要な問題は、if/then 条件ブロックにおける required の不備により、ingress.enabledglobal.databaseType を省略することでバリデーションチェックがバイパスされる点です(CWE-20)。外部DBモード時の externalDatabase.host 必須チェックも同様のバイパスリスクがあり、意図した安全な設定の強制が機能しない恐れがあります。persistence.size のパターン正規表現も Kubernetes の実際の quantity 仕様と乖離があるため修正を推奨します。

🔴 critical: 1 / 🟠 high: 1 / 🟡 medium: 4 / 🔵 low: 3

その他の指摘 (7 件)
  • 🟡 [medium] helm/values.schema.json:73persistence.repositories.size の pattern が Kubernetes quantity の一部しかカバーしていない (confidence: 0.85, code.schema.pattern_incomplete_quantity)
  • 🟡 [medium] helm/values.schema.json:97 — ingress.enabled が required でないため if/then 条件が空オブジェクトでバイパス可能 (confidence: 0.85, sec.sast.validation.schema_bypass)
  • 🟡 [medium] helm/values.schema.json:117 — external DB の if/then で global が required でないため条件バイパス可能 (confidence: 0.82, sec.sast.validation.schema_bypass)
  • 🟡 [medium] helm/values.schema.json:32autoscaling.maxReplicas >= minReplicas の制約が存在しない (confidence: 0.80, code.schema.autoscaling_maxreplicas_no_relation)
  • 🔵 [low] helm/values.schema.json:1 — 各プロパティに description フィールドがなく、helm show values / IDE での補完が機能しない (confidence: 0.75, maintainability.schema.no_description)
  • 🔵 [low] helm/values.schema.json:71 — persistence.size のパターンが Ki/Mi/Gi/Ti 単位を制限せず不完全 (confidence: 0.70, sec.sast.validation.weak_pattern)
  • 🔵 [low] helm/values.schema.json:4 — additionalProperties: true により未定義キーが無制限に受け入れられる (confidence: 0.55, sec.sast.validation.open_schema)

head: 3ad9b18 | Orange Codens (P1)

Comment thread helm/values.schema.json
},
"allOf": [
{
"if": {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 [critical] トップレベルの if/thenallOf を併用するとセマンティクスが壊れる

JSON Schema draft-07 ではキーワードは独立して評価されます。if/then をトップレベルに直書きしつつ allOf も存在する場合、両者は問題なく共存しますが、トップレベルの if/thenallOf 内に入っていないため、外側の iffalse の場合(ingress が存在しないか enabledtrue でない場合)に then は無視されます。これ自体はドラフト-07 の仕様通りですが、より重大な問題は allOf と同階層に if/then を置く構造の一貫性のなさです。PRD では「外部DBのif/thenallOf 経由」と明示されているのに、ingress の if/then だけがトップレベルに分離されており、将来ルールを追加する際に allOf と混在して管理が困難になります。両方を allOf に統一すべきです。

該当箇所:

  "if": {
    "properties": {
      "ingress": {
        "properties": {
          "enabled": {
            "const": true
          }
        }
      }
    },
    "required": ["ingress"]
  },
  "then": { ... },
  "allOf": [ { "if": ..., "then": ... } ]
@@ -93,25 +93,30 @@
-  "if": {
-    "properties": {
-      "ingress": {
-        "properties": {
-          "enabled": {
-            "const": true
-          }
-        }
-      }
-    },
-    "required": ["ingress"]
-  },
-  "then": {
-    "properties": {
-      "ingress": {
-        "required": ["host"],
-        "properties": {
-          "host": {
-            "minLength": 1
-          }
-        }
-      }
-    }
-  },
   "allOf": [
+    {
+      "if": {
+        "properties": {
+          "ingress": {
+            "properties": { "enabled": { "const": true } }
+          }
+        },
+        "required": ["ingress"]
+      },
+      "then": {
+        "properties": {
+          "ingress": {
+            "required": ["host"],
+            "properties": { "host": { "minLength": 1 } }
+          }
+        }
+      }
+    },
     {

code.schema.if_then_allof_conflict | confidence: 0.92

Comment thread helm/values.schema.json
},
"then": {
"properties": {
"externalDatabase": {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 [high] allOf 内の外部DB if 条件に required: ["global"] がなく、global キーが存在しない場合も条件が通過してしまう

JSON Schema では properties 内のキーワードはそのプロパティが存在する場合にのみ検証されます。globalvalues.yaml に含まれていない場合、ifproperties.global スキーマは「適用対象なし→ true」と評価されてしまい、thenexternalDatabase.host required が誤って発動するリスクがあります。

ingress側(トップレベル if)では "required": ["ingress"] が付与されているのに、allOf 内の external DB 側 if には同等の "required": ["global"] が欠落しています。

該当箇所:

      "if": {
        "properties": {
          "global": {
            "properties": {
              "databaseType": {
                "const": "external"
              }
            }
          }
        }
      },

実際には global.databaseType"external"明示されていない限り then は発動しないため誤検知の頻度は低いですが、global キーが丸ごと省略された values では iftrue になり externalDatabase.host が要求されてしまいます。

@@ -116,7 +116,8 @@
       "if": {
         "properties": {
           "global": {
             "properties": {
               "databaseType": { "const": "external" }
             }
           }
-        }
+        },
+        "required": ["global"]
       },

code.schema.if_condition_missing_required | confidence: 0.88

@zoetaka38
zoetaka38 merged commit 38a00e6 into main Jun 29, 2026
12 of 16 checks passed

@orange-codens orange-codens Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍊 Orange Codens レビュー

PRD で要求されたプロパティ定義・enum・minimum・if/then の骨格は概ね揃っていますが、external モード時に externalDatabase オブジェクト自体が欠落してもスキーマを通過する点は PRD 要件を満たさず、マージ前に修正すべきです。ingress 側の条件付きルールは比較的厳密ですが、external 側と enabled の扱いに揃えの余地があります。PRD 検証項目を担保する自動テストも diff には含まれていません。

🔒 セキュリティ: 本 PR は Helm インストール時の values 検証用 JSON Schema (helm/values.schema.json) の新規追加のみで、認証・認可・SQL/コマンド実行・SSRF・暗号処理などのアプリケーション実行パスは diff に含まれていません。additionalProperties: true や host フィールドの minLength のみの制約は設定の柔軟性・入力検証の粒度に関する設計判断ですが、diff 単体から OWASP Top 10 / CWE Top 25 に該当する論理的脆弱性(悪用可能な exploit パス)を確信を持って特定できません。

🔴 critical: 1 / 🟡 medium: 3 / 🔵 low: 1

その他の指摘 (4 件)
  • 🟡 [medium] helm/values.schema.json:1 — スキーマ拒否ケースの自動テストが diff に含まれない (confidence: 0.85, maintainability.test.missing_schema_validation)
  • 🟡 [medium] helm/values.schema.json:117 — external 用 if が global 不在時に常真になり then が弱く適用される (confidence: 0.78, code.logic.if_vacuous_match)
  • 🟡 [medium] helm/values.schema.json:90 — ingress.enabled=true 未指定でも host 必須が発火する (confidence: 0.72, code.logic.ingress_enabled_not_required)
  • 🔵 [low] helm/values.schema.json:90 — 条件付きルールの配置が ingress と external で不統一 (confidence: 0.70, maintainability.structure.inconsistent_conditional_placement)

head: 7abdb30 | Orange Codens (P1)

Comment thread helm/values.schema.json
}
}
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 [critical] external モード時に externalDatabase オブジェクト欠落を検証できない

PRD は global.databaseTypeexternal のとき externalDatabase.host 欠落を helm install 時に拒否することを要求していますが、then ブロックは properties.externalDatabase 内の required: ["host"] だけを定義しています。JSON Schema draft-07 では、ルートに externalDatabase キーが存在しない場合、そのサブスキーマは適用されず、required も評価されません。したがって global.databaseType: external だけを渡し externalDatabase を丸ごと省略した values は、このスキーマを通過します。

該当箇所:

      "then": {
        "properties": {
          "externalDatabase": {
            "required": ["host"],
            "properties": {
              "host": {
                "minLength": 1
              }
            }
          }
        }
      }

ingress 側は ifrequired: ["ingress"] を付け、theningress.required: ["host"] としているため、オブジェクト存在時の必須チェックは機能します。external 側にも同様に then 直下へ required: ["externalDatabase"] が必要です。

@@ -129,6 +129,7 @@
       "then": {
+        "required": ["externalDatabase"],
         "properties": {
           "externalDatabase": {
             "required": ["host"],

code.logic.conditional_required_gap | confidence: 0.93

@zoetaka38
zoetaka38 deleted the feature/019f0d78fbc2-019f0d78fbc2 branch July 2, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant