Repository navigation
feat(github): Load PR description images through the image proxy - #3370
Conversation
Object cards now show the description images of a pull request through /api/images with signed ids, never as raw URLs. The GitHub plugin adds an images source that checks the viewer's repository access on each read. Private attachments are read through host egress with the App credential, and only the signed redirect target is fetched for the image. Co-Authored-By: BYK <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…s reads A viewer without access gets 404 from the image route, so the card hides that image. A GitHub permission read that fails with a status other than 404, such as a rate limit, is not cached as a denial.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b955da3. Configure here.
A GitHub permission read that fails with a status other than 404 now logs a warning and denies only that read, instead of an unhandled 500.
…-proxy # Conflicts: # packages/junior-github/src/plugin.ts # packages/junior/tests/integration/api/conversations/detail.test.ts
| async resolve(ctx, ref): Promise<ImageFetch | undefined> { | ||
| const image = decodeObjectImageRef(ref); | ||
| const key = image && OBJECT_KEY.exec(image.key); | ||
| if (!image || !key || !URL.canParse(image.url)) return undefined; | ||
| const kind = githubImageKind(new URL(image.url)); | ||
| const login = linkedGitHubLogin(ctx.viewer); | ||
| if (!kind || !login) return undefined; | ||
| const repository = { name: key[2]!, owner: key[1]! }; | ||
| if (!(await canSeeRepository(ctx, repository, login))) return undefined; | ||
| return kind === "artifact" | ||
| ? { url: image.url } | ||
| : { | ||
| url: image.url, | ||
| location: () => githubAttachmentLocation(ctx.egress, image.url), | ||
| }; |
There was a problem hiding this comment.
Attachment fetch authorized by object repo, not attachment access
After a collaborator check on the annotation repo key, Junior fetches any allowlisted user-attachments URL with the GitHub App credential. Embed a private attachment UUID in a PR on a still-accessible repo to read private images the viewer can no longer access on GitHub.
Evidence
resolvetakeskeyandurlfromdecodeObjectImageRef(ref)and only runsOBJECT_KEY+githubImageKindvalidation on them.- Authorization is solely
canSeeRepository(ctx, repositoryFromKey, linkedGitHubLogin)againstowner/repofromkey. - On success, attachments call
githubAttachmentLocation(ctx.egress, image.url), which uses system/App egress togithub.comand returns the signed redirect target. - Nothing binds
image.urlto that repository, so a viewer with access to repo A can cause the App to load a private attachment that belongs to repo B.
Also found at 5 additional locations
packages/junior-github/src/plugin.ts:70-70packages/junior-github/src/plugin.ts:179-179packages/junior/src/chat/images/read.ts:56-60packages/junior-github/src/tool-support/github-api.ts:91-105packages/junior-plugin-api/src/object-facts.ts:36-37
Identified by Warden · security-review · XS4-RNG
## Problem
Google link cards match only `docs.google.com`. A `drive.google.com`
link gets no card. Drive has no oEmbed provider, and Drive serves a
sign-in page to anonymous fetches, so the `web_page` card cannot preview
it either.
## Fix
- The Google `document` link type now also matches `drive.google.com`
`/file/d/<id>`, `/file/u/<n>/d/<id>`, `/open?id=<id>`,
`/drive/folders/<id>`, and `/drive/u/<n>/...`. These filters have a
host, so they win over the `web_page` catch-all.
- A Drive link to a Doc, Sheet, or Slides file gets the same card as its
`docs.google.com` link. It uses the shared `FILE_TYPES` map and file
card.
- Other files and folders use the existing `document` object type, with
a type label from the MIME type ("PDF", "Image", "Google Drive folder").
They show the name, owner, and modified time. I did not add a new object
type: the card has the same fields as a Doc card, and only the label
changes.
- File thumbnails go through the image proxy. The Google plugin adds an
`images` source that does the same viewer check as the card on each
read, through `ImageSourceContext.egress` (#3370), then fetches
`thumbnailLink` with Junior's Google token. It sends the token only to
`*.googleusercontent.com`. Facts hold only a signed `/api/images/...`
path, never `thumbnailLink`.
- Access uses the same viewer rule as Doc cards (`viewerCanOpen`). For
cards, the rule runs in `canView` (#3376), which shares one cached Drive
read with `resolve`. Thumbnails run it again on each image read, with no
cache (`readViewerFile`). Group-only shares, trashed files, and
shortcuts get no card and no thumbnail.
- Plugin API changes:
- `ObjectLinkContext.imagePath(ref, version?)` makes a signed image path
for a card.
- `readTool` is now a function of the resolved object, because a Drive
URL does not show its type before the lookup. Docs, Sheets, and Slides
from Drive name `readGoogleFile`. Other files name no tool.
- The `document` and `web_page` facts share one `thumbnailUrl` schema.
- No new OAuth scopes and no migration. `drive.readonly` is already
granted.
| | Dark | Light |
| --- | --- | --- |
| Before: Drive links stay plain links |

|

|
| After: PDF chip and hover card |

|

|
| After: folder chip and hover card |

|

|
The before shots use the same mock thread with the Drive results removed
from `/api/objects`, which is what main returns for them.
<!-- junior-request-attribution:start -->
via @BYK.
<!-- junior-request-attribution:end -->
<!-- junior-session-footer:start -->
<!-- junior-conversation-id:agent%3Ab4ab1661aa9222ed540303a34bce2d99 -->
--
[View
Session](https://junior-prod.sentry.dev/conversations/agent%3Ab4ab1661aa9222ed540303a34bce2d99)
[[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3Ab4ab1661aa9222ed540303a34bce2d99/?project=4510944073809921)
<!-- junior-session-footer:end -->
---------
Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: BYK <[email protected]>

Problem
PR cards cannot show the images in a PR description. Most of them are
github.com/user-attachmentsimages, and they need GitHub auth on private repositories. The dashboard must not load a raw image URL.Fix
previewImagesto each object annotation whose plugin serves images. Eachsrcis an/api/images/:id?w=320path with a signed id, with a?w=6402xsrcSet. Hover cards, transcript cards and known objects show them as WebP.imagessource. On each read it checks that the viewer's linked GitHub login can see the repository (collaborator permission, cached for 10 minutes). A viewer without access, or without a linked login, gets 404.github.comonly. Junior then fetches the signed redirect target with no credential.ImageFetch.locationis new. Junior calls it only on a cache miss.ImageSourceContextnow hasegress.github.com/user-attachments/assets/<uuid>. Signedprivate-user-imagesURLs are never saved. The 4 KiB facts limit stays. No migration and no new OAuth scopes.Not verified: that GitHub accepts an App installation token on
github.com/user-attachmentsfor private repositories. If it does not, the image route returns 404 and the card shows no image.The Inbox row image is in #3035, which is not merged. It can use
objectPreviewImages.Screenshots
PR card (mock dashboard):
Tests
images.test.ts: a repository member gets WebP at 640x400. An outsider and an unlinked viewer get 404, and nothing is fetched with the App credential for them. The signed URL gets no credential.detail.test.ts:previewImagesare signed/api/images/paths for the GitHub source.get-pull-request.test.ts: a UUID attachment is saved. Other attachment paths and signed URLs are dropped.conversation-object-links: the card imagesrcandsrcsetare/api/images/paths, and the image loads.via @BYK.
--
View Session [Sentry]