Skip to content

chore(attachments): align AttachmentResource with main (2.0) - #36544

Merged
yan-3005 merged 2 commits into
2.0from
fix/attachment-read-authz-4877-2.0
Oct 29, 2026
Merged

yan-3005 merged 2 commits into
2.0from
fix/attachment-read-authz-4877-2.0

Conversation

@yan-3005

@yan-3005 yan-3005 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Brings AttachmentResource on 2.0 in line with main: the parent-entity lookup for an attachment lives in one helper, and the attachment endpoints share it.

No API shape changes.

…ent entity (backport 2.0)

Backport of the attachment-access part of #33477 to 2.0.
GET /v1/attachments/{id} and GET /v1/attachments/fqn/{fqn}/{assetType}
now resolve the parent entity of each attachment and check VIEW_BASIC on
it, the same check the download path runs. The FQN list authorizes each
distinct parent, since one page can span more than one.

(cherry picked from commit f669f7d — AttachmentResource only)
@yan-3005
yan-3005 requested a review from a team as a code owner October 29, 2026 11:11
@yan-3005
yan-3005 requested review from IceS2 and removed request for a team October 29, 2026 11:11
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

  • No GitHub issue is linked. Link an issue in the Development section of the PR (or add Fixes #12345 to the description). For a same-org cross-repo issue, add Fixes open-metadata/<repo>#123 to the description.

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@github-actions github-actions Bot added backend safe to test Add this label to run secure Github workflows on PRs labels Oct 29, 2026
@yan-3005 yan-3005 changed the title fix(attachments): authorize attachment metadata reads against the parent entity (backport 2.0) chore(attachments): align AttachmentResource with main (2.0) Oct 29, 2026
@open-metadata open-metadata deleted a comment from gitar-bot Bot Oct 29, 2026
@open-metadata open-metadata deleted a comment from gitar-bot Bot Oct 29, 2026
@gitar-bot

gitar-bot Bot commented Oct 29, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 1 closed / 1 findings

🔴 High risk · Adding parent-entity VIEW_BASIC checks changes authorization for attachment reads; overly restrictive or mismatched permissions could block legitimate access.

Brings AttachmentResource on 2.0 in line with main by moving the parent-entity lookup into one shared helper used by the attachment endpoints, with no API shape changes. The authorization fix that was missing a regression test now has coverage for attachment reads under parent-entity permissions.

✅ 1 closed
✅ Quality: Authorization fix ships with no regression test

📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/attachments/AttachmentResource.java:102 📄 openmetadata-service/src/main/java/org/openmetadata/service/resources/attachments/AttachmentResource.java:304-307
This PR adds VIEW_BASIC checks to GET /v1/attachments/{id} and GET /v1/attachments/fqn/{fqn}/{assetType}, but it adds no test showing that a denied user now gets 403 on these endpoints. The repo guideline says bug fixes must include a failing test, and this is a high-risk security backport. Without a test, a later refactor could drop the check and nothing would catch it. Add resource tests, for example in an AttachmentResourceTest, that call both endpoints as a user denied ViewBasic on the parent entity and expect 403. Also call them as a permitted user and expect 200. Include a case where one parent in the FQN list is denied.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@sonarqubecloud

Copy link
Copy Markdown

@yan-3005
yan-3005 merged commit 5d0731c into 2.0 Oct 29, 2026
66 of 68 checks passed
@yan-3005
yan-3005 deleted the fix/attachment-read-authz-4877-2.0 branch October 29, 2026 12:15
@yan-3005 yan-3005 self-assigned this Nov 19, 2026

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants