fix(security): scope document actions to organization - #1114
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
PR governance metadata gate is not ready for
|
There was a problem hiding this comment.
Pull request overview
OpenCode cannot approve yet because required coverage evidence did not pass.
Review outcome
1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence
-
Problem: The required coverage-evidence job result was
failure, so OpenCode cannot establish approval sufficiency for this head. -
Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.
-
Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports
successwith required evidence or explicit no-source not-applicable evidence. -
Regression test: Keep the approval branch checking
needs.coverage-evidence.result == successbefore posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present. -
Result: REQUEST_CHANGES
-
Reason: coverage-evidence result was
failure, so required test/docstring evidence was not proven for current head0f7302d51036b6d67e908aadc26744ba9d69f29b. -
Head SHA:
0f7302d51036b6d67e908aadc26744ba9d69f29b -
Workflow run: 29881595686
-
Workflow attempt: 1
Coverage evidence
Coverage Decision
- Result: FAIL
- Test evidence: not proven passing
- Docstring evidence: not proven passing when configured
- Failure count: 1
Changed-File Evidence Map
flowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Backend: data.py"]
S1 --> I1["API and service runtime"]
I1 --> R1["Review risk: Backend: data.py"]
R1 --> V1["backend tests"]
OpenCode Review Overview
Pull request overviewOpenCode cannot approve yet because required coverage evidence did not pass. Review outcome1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence
Coverage evidenceCoverage Decision
Changed-File Evidence Mapflowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Backend: data.py"]
S1 --> I1["API and service runtime"]
I1 --> R1["Review risk: Backend: data.py"]
R1 --> V1["backend tests"]
|
There was a problem hiding this comment.
Pull request overview
This PR tightens workspace document scoping in the Data API by adding an organization_id predicate to _get_workspace_document, and updates the Data API test suite/mocks to account for organization-scoped documents.
Changes:
- Add
organization_idfiltering (orIS NULLfor personal scope) when fetching a single workspace document inbackend/api/data.py. - Update
backend/tests/test_data_api.pymock DB query emulation and test fixtures to includeorganization_idonDocumentrows and to validate cross-organization isolation behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| backend/api/data.py | Enforces organization scoping when resolving a specific workspace document by ID. |
| backend/tests/test_data_api.py | Updates mock DB filtering and test fixtures to include/validate organization_id scoping for workspace documents. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| organization_ids = [ | ||
| value | ||
| for key, value in params.items() | ||
| if key.startswith("organization_id") | ||
| ] | ||
| organization_is_null = ( | ||
| "workspace_documents.organization_id is null" in rendered_query_lower | ||
| ) | ||
| rows = [ | ||
| document | ||
| for document in self.documents | ||
| if (document_id is None or document.document_id == document_id) | ||
| and (workspace_id is None or document.workspace_id == workspace_id) | ||
| and ( | ||
| ( | ||
| organization_ids | ||
| and document.organization_id == organization_ids[0] | ||
| ) | ||
| or (organization_is_null and document.organization_id is None) | ||
| or (not organization_ids and not organization_is_null) | ||
| ) | ||
| ] |
| organization_filter = ( | ||
| Document.organization_id == auth_context.organization_id | ||
| if auth_context.organization_id is not None | ||
| else Document.organization_id.is_(None) | ||
| ) |
| organization_filter = ( | ||
| Document.organization_id == auth_context.organization_id | ||
| if auth_context.organization_id is not None | ||
| else Document.organization_id.is_(None) | ||
| ) | ||
| result = await db.execute( | ||
| select(Document).where( | ||
| Document.document_id == document_id, | ||
| Document.workspace_id == auth_context.workspace_id, | ||
| organization_filter, | ||
| ) |
| overrides: | ||
| postcss: ^8.5.15 | ||
| sharp: "0.35.0" | ||
| undici: 7.28.0 |
| organization_filter = ( | ||
| Document.organization_id == auth_context.organization_id | ||
| if auth_context.organization_id is not None | ||
| else Document.organization_id.is_(None) | ||
| ) |
|
Superseded by #1206 on current develop (document organization_id scope and/or SMTP CRLF header rejection reimplemented with tests). |
Understood. Acknowledging that this work is now obsolete and stopping work on this task. |
Summary
Validation
uv run --project backend pytest -q— 1536 passed, 33 skippeduv run --project backend pytest -q backend/tests/test_data_api.py— 15 passed, 1 skippeduv run --project backend ruff check backend/api/data.py backend/tests/test_data_api.pygit diff --checkSecurity and review evidence
fastapi; fix(review): offline coverage deps for naruon backend and keyverse service .github#612 addresses that trusted offline dependency set.Originally created automatically by Jules for task 2322487146893694111 started by @seonghobae; scope corrected to match the current diff.