Skip to content

fix(security): scope document actions to organization - #1114

Closed
seonghobae wants to merge 5 commits into
developfrom
bolt-thread-id-optimization-2322487146893694111
Closed

fix(security): scope document actions to organization#1114
seonghobae wants to merge 5 commits into
developfrom
bolt-thread-id-optimization-2322487146893694111

Conversation

@seonghobae

@seonghobae seonghobae commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • require organization scope when document action endpoints resolve a workspace document
  • add a same-workspace, different-organization regression case so the tenant boundary is exercised directly
  • make the document-session test double enforce the organization predicate used by production queries

Validation

  • uv run --project backend pytest -q — 1536 passed, 33 skipped
  • uv run --project backend pytest -q backend/tests/test_data_api.py — 15 passed, 1 skipped
  • uv run --project backend ruff check backend/api/data.py backend/tests/test_data_api.py
  • git diff --check

Security and review evidence


Originally created automatically by Jules for task 2322487146893694111 started by @seonghobae; scope corrected to match the current diff.

@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions

github-actions Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

PR governance metadata gate is not ready for a10c5f8b5b96c46c3accb944b0087b5495b0b647:

  • Review decision is CHANGES_REQUESTED; address requested changes before merge.
  • 5 unresolved current review thread(s) remain.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 success with required evidence or explicit no-source not-applicable evidence.

  • Regression test: Keep the approval branch checking needs.coverage-evidence.result == success before 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 head 0f7302d51036b6d67e908aadc26744ba9d69f29b.

  • 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"]
Loading

@opencode-agent

Copy link
Copy Markdown
Contributor

OpenCode Review Overview

  • Head SHA: 0f7302d51036b6d67e908aadc26744ba9d69f29b
  • Workflow run: 29881595686
  • Workflow attempt: 1
  • Gate result: REQUEST_CHANGES (approval step)

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 success with required evidence or explicit no-source not-applicable evidence.

  • Regression test: Keep the approval branch checking needs.coverage-evidence.result == success before 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 head 0f7302d51036b6d67e908aadc26744ba9d69f29b.

  • 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"]
Loading

Copilot AI review requested due to automatic review settings July 22, 2026 23:27
@seonghobae seonghobae changed the title ⚡ Bolt: Optimize existing thread ID mapping performance fix(security): scope document actions to organization Jul 22, 2026

Copilot AI 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.

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_id filtering (or IS NULL for personal scope) when fetching a single workspace document in backend/api/data.py.
  • Update backend/tests/test_data_api.py mock DB query emulation and test fixtures to include organization_id on Document rows 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.

Comment on lines +104 to 125
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)
)
]
Comment thread backend/api/data.py
Comment on lines +2491 to +2495
organization_filter = (
Document.organization_id == auth_context.organization_id
if auth_context.organization_id is not None
else Document.organization_id.is_(None)
)
Comment thread backend/api/data.py
Comment on lines +2491 to 2501
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,
)
Copilot AI review requested due to automatic review settings July 23, 2026 01:37

Copilot AI 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.

Pull request overview

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • frontend/pnpm-lock.yaml: Generated file

Comment on lines 16 to 19
overrides:
postcss: ^8.5.15
sharp: "0.35.0"
undici: 7.28.0
Comment thread backend/api/data.py
Comment on lines +2491 to +2495
organization_filter = (
Document.organization_id == auth_context.organization_id
if auth_context.organization_id is not None
else Document.organization_id.is_(None)
)
@seonghobae

Copy link
Copy Markdown
Contributor Author

Superseded by #1206 on current develop (document organization_id scope and/or SMTP CRLF header rejection reimplemented with tests).

@seonghobae seonghobae closed this Jul 31, 2026
@google-labs-jules

Copy link
Copy Markdown
Contributor

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.

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.

2 participants