Repository navigation
fix(security): enforce SAIKU_AI_POLICY on the Ossie AI REST and MCP surface - #2355
Conversation
…full AI policy tier Spec for saiku#2322: under the aggregated tier (the launcher demo default) POST /ai/ossie/row-detail must return the 403 PERMISSION_DENIED envelope (field ai.policy, available [full]) while GET /ai/ossie/schema stays 200. Red on base: row-detail currently returns 200 raw rows. Hive-Run: #2322 Hive-Plan: ossie-ai-policy-enforcement (spec-first) Hive-Spec: ossie-ai-policy-enforcement#spec-first Signed-off-by: spicule-hive-bot <spicule-hive-bot@users.noreply.github.com>
…urface (saiku#2322) AiPolicyGuard (saiku#903) was a no-op for the whole Ossie AI surface: the aiOssieResource bean never received the shared aiPolicyGuard singleton, the field defaulted to a permissive FULL guard, and seven of the eight data-returning methods never called assertCanSend at all — so any authenticated user (and any MCP host acting with their credentials) got aggregated warehouse values and raw rows through /ai/ossie/* regardless of SAIKU_AI_POLICY, while SECURITY.md advertised schema-only as the enforced fail-closed default and ai-audit.jsonl recorded the configured tier next to the unguarded responses. - AiOssieResource: pre-wiring guard default is now AiPolicy.DEFAULT (schema-only, fail closed) instead of FULL, and every data endpoint calls assertCanSend as its first statement, before the try so AiPolicyViolation reaches AiPolicyViolationMapper (403) rather than the generic 500: aggregated tier for /query, /query/execute-async, /query/result, /anomaly, /forecast and the shared runInternalQuery; full tier for /row-detail (the Ossie drillthrough); schema-only kinds recorded on /schema, /ontology, /query/preview and /values/search. - saiku-beans.xml: aiOssieResource now receives the aiPolicyGuard singleton (parity with aiQueryResource since saiku#903), so the operator's SAIKU_AI_POLICY / ai.policy resolves once at boot for Ossie too; the saikuGraphQlFetchers comment claiming the delegated resources re-check the policy is now true. - McpResource: an AiPolicyViolation surfaces as an MCP tool result with isError:true carrying the PERMISSION_DENIED envelope (status/field/ available) instead of the generic -32603 "Internal error" branch. - Tests: AiOssieResourcePolicyTest (call-site coverage on the model of AiQueryResourcePolicyTest, with an OssieQueryService stub that fails if execution is ever reached), AiPolicyGuardWiringTest + ai-policy-wiring-test.xml (wiring lock: both AI resources receive the same singleton; an unwired AiOssieResource fails closed to schema-only), and the MCP schema-only tool-error case; AiOssieAskGuardTest / AiOssieRoleGuardTest now wire an explicit FULL guard since they exercise the rate-limit/role guards, not the policy. - Docs: SECURITY.md states the fail-closed default covers the Ossie surface; docs/AI-OSSIE-API.md gains the per-endpoint tier table. - acceptance/2322/spec.json (previous commit) proves row-detail is refused under the aggregated demo tier while schema stays available. Note: AiQueryResource keeps its FULL pre-wiring default on purpose — it is wired in production and flipping its default would ripple through its documented back-compat test and dozens of unit tests; that hardening is left as its own follow-up. Hive-Run: #2322 Hive-Plan: ossie-ai-policy-enforcement Hive-Spec: ossie-ai-policy-enforcement#guard-default, #endpoint-gates, #spring-wiring, #mcp-error-shape, #tests, #docs Signed-off-by: spicule-hive-bot <spicule-hive-bot@users.noreply.github.com>
CI feedbackpassing · Nothing to fix: every check in this commit concluded successfully. |
46bda80
|
Semantic model diffSemantic model diffNo model changes and no broken references. saiku#1434 · reproduce locally with |
|
hive-base-moved: merged 🐝 Hive Agent: 🐝 Hive Agent: |
Merge adaptation: AiOssieResourceAsyncRoleTest (from saiku#2323, merged into development) constructs the resource with no policy guard, so with this PR's submit-time policy gate on executeAsync it dies with AiPolicyViolation (schema-only refuses AGGREGATED_RESULT_VALUES) before the role validation it exists to assert. Wire an explicit FULL guard, the same fixture AiOssieRoleGuardTest already uses — the class exercises role guards, not the policy.
|
Merge follow-up: the post-merge red 🐝 Hive Agent: 🐝 Hive Agent: |
|
🐝 Hive Agent: |
|
Merge follow-up: the post-merge red 🐝 Hive Agent: 🐝 Hive Agent: |
Signed-off-by: quality <334701613+spicule-hive[bot]@users.noreply.github.com>
|
Rework update on the existing branch (head
🐝 Hive Agent: — hive: agent=quality backend=codex model=gpt-6-sol codex=0.167.0 |
…to fix/2322-ossie-ai-policy-gate
|
…ie-ai-policy-gate
…iculedata/saiku into fix/2322-ossie-ai-policy-gate # Conflicts: # .claude/session-summary.md
|
hive-base-moved: merged current development (230bfb2) into this branch (plus reconciled the prior remote merge bcfa0cc). New head: de8c911. Conflict-free except a .claude/session-summary.md artifact; PR intent (fail-closed SAIKU_AI_POLICY enforcement, #2322) preserved. 🐝 Hive Agent: |
…uard (merge follow-up) The error-envelope test (saiku#1920) landed on development after the saiku#2322 policy gate and constructs AiOssieResource with no guard, so the schema-only policy now rejects executeAi/rowDetail with AiPolicyViolation before the envelope under test is built. Wire the same explicit FULL guard the async role test fixture uses; no production code touched.
|
Merge follow-up: the red 🐝 Hive Agent: |
PR acceptance metricAcceptance rate: 85.9% — 428 merged / 498 decided PRs (2 still open, excluded from the denominator).
Generated by |
Summary
SAIKU_AI_POLICY(the operator's AI data-exposure tier, saiku#903) was silently a no-op on the whole Ossie AI surface. TheaiOssieResourcebean never received the sharedaiPolicyGuardsingleton, the resource's field defaulted to a permissiveFULLguard, and 7 of the 8 data-returning methods never calledassertCanSendat all — so any authenticatedROLE_USER(and any MCP host acting with their credentials) got aggregated warehouse values and, via/row-detail, raw rows regardless of the configured policy. Only GraphQL'sexecuteOssie(own guard) and MDX/ai/*(wired bean) enforced it.SECURITY.md's fail-closed claim was not true for Ossie, andai-audit.jsonlrecordedpolicy: schema-onlynext to responses that returned data. CWE-862 / CWE-1188.What this PR changes
AiOssieResource— fail-closed default + guard at every data endpoint. The pre-wiring field default is nowAiPolicy.DEFAULT(schema-only) instead ofFULL, and each endpoint callsaiPolicyGuard.assertCanSend(...)as its first statement, before thetry, so anAiPolicyViolationreachesAiPolicyViolationMapper(403 +PERMISSION_DENIEDenvelope) rather than the genericcatch (Exception):AGGREGATED_RESULT_VALUES:/query,/query/execute-async,/query/result/{id},/anomaly,/forecast, and the sharedrunInternalQuery(belt-and-braces for future callers);RAW_ROW_DATA:/row-detail(the Ossie drillthrough — same tier as MDX/ai/drillthrough);SCHEMA_METADATA/SAMPLE_MEMBERSrecorded for symmetry on/schema,/ontology,/query/preview,/values/search(never block under the default).saiku-beans.xml.aiOssieResourcenow receives theaiPolicyGuardsingleton (parity withaiQueryResourcesince saiku#903), so the operator'sSAIKU_AI_POLICY/ai.policyresolves once at boot for Ossie too. ThesaikuGraphQlFetcherscomment claiming "the delegated AiOssieResource re-checks it" is now actually true.McpResourcemapsAiPolicyViolationto a tool result withisError: trueand the samePERMISSION_DENIEDenvelope (status/field/available) instructuredContent, instead of the generic-32603 "Internal error"branch (also improves the MDXrun_query/drillthroughtools).AiOssieResourcePolicyTest— call-site coverage modelled onAiQueryResourcePolicyTest, with anOssieQueryServicestub that fails the test if execution is ever reached: blocked per endpoint per tier, passes-guard cases, andunwiredResourceDefaultsToSchemaOnly.AiPolicyGuardWiringTest+ai-policy-wiring-test.xml— wiring lock: both AI resources receive the same singleton; the negative case asserts an unwired resource's field default isSCHEMA_ONLY, notFULL.McpResourceTest.runOssieQueryUnderSchemaOnlyReturnsPermissionDeniedToolError.AiOssieAskGuardTest/AiOssieRoleGuardTestwire an explicitFULLguard — they exercise the rate-limit/role guards, not the policy.SECURITY.mdstates the fail-closed default covers/ai/ossie/*and the MCP Ossie tools;docs/AI-OSSIE-API.mdgains the per-endpoint tier table (what needsaggregated, what needsfull).acceptance/2322/spec.json— under the demo default (aggregated),POST /ai/ossie/row-detailmust 403 withfield: ai.policy,available: [full]whileGET /ai/ossie/schemastays 200. Red on base: row-detail currently returns 200 raw rows.Verification
mvn -pl saiku-core/saiku-web test— 1373 tests green (includes the new policy/wiring/MCP tests).mvn -pl saiku-core/saiku-web spotless:check— clean.validateSpec().Deliberately out of scope
AiQueryResource(MDX) keeps itsFULLpre-wiring default: it is wired in production and flipping its default would ripple through its documented back-compat test (unwired_guard_defaults_permissive_for_back_compat) and dozens of unit tests that construct it unwired. That hardening deserves its own PR. The graph endpoints (/graph,/search,/entity,/signals) are a separate surface (#1410) and are not touched here; noted as follow-up material alongside #2323 (async RLS) and #2324 (field deny lists).Closes #2322
— hive: backend=pi model=openrouter/z-ai/glm-5.3-flash
🐝 Hive Agent:
contributor| SHA:46bda80bf