Repository navigation
feat(google): Search only files the requester could find - #3208
Conversation
Co-Authored-By: David Cramer <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Is there anything else you can do to provide evidence that the APIs you're using will correctly limit this? It's OK to accidentally limit it too much, but it's not OK to expose things that shouldn't be exposed |
|
Short version: Google's docs support the filter, but they don't prove it. I found one real gap, and only a live run with fixture files can give hard evidence. I can't run that from here, because sandbox commands get no Google credential and the What the docs support (search terms, examples)
Not covered by the docs (needs a live check)
Real gap: What I can do next
If you want hard evidence before merge, I'd do 1 and 2. |
…p search off until it passes Co-Authored-By: David Cramer <[email protected]>
|
this is primarily an improvement upon what we have today so we'll be able to verify life. clean up the PR description so it focuses on whats in this PR, and the known concerns |
|
remove this verify-search junk. we dont ship things like that to prod. you follow the docs, implement it per spec, make sure your code is correct, and thats the limit of your job. |
|
i dont want a constant like this to turn it on/off. we could use an experiment temporarily, but our goal is to make the bot behave well not have a ton of variable behaviors we have to think about this |
Co-Authored-By: David Cramer <[email protected]>
|
does the meet handling even make sense? i get having the calendar events be meeting transcript aware, but thats different than trying to special case all those files |
|
Fair challenge. I don't think the file-side special case earns its keep. The only argument for it: Meet shares records with every invitee automatically, so Junior's account gets transcripts just by being on an invite, not because someone chose to share them with Junior. But under this PR's model, reading one still needs the link. Someone holding the link of a meeting they weren't in is the same case as holding the link of any private Doc shared with Junior, and we already accept that for every other Doc. Search doesn't leak them either. Meet records aren't The title match is also the weakest part of the PR. It refuses ordinary files with "transcript" or "Gemini" in the name, it misses renamed records, and it pulled in the My proposal: drop the Meet title refusal from the file readers, drop the |
Co-Authored-By: David Cramer <[email protected]>
|
Following up on #3208 (comment): done in 8b56f95.
This reverses the earlier fix for the Warden finding on localized Meet titles. That's on purpose: under this model, a record link is treated like any other Doc link. |
## Problem A Google Docs, Sheets, Slides, or Calendar event link in a Conversation, an Inbox row, or a hover card shows as a bare link. The Google plugin has no Google credentials for each viewer. It reads only as Junior's own Workspace account. Also, a link resolver gets no provider credentials at all. ## Fix **Core: `egress` on `ObjectLinkContext`.** A link resolver gets the same host-owned `PluginEgress` that tools use. Junior builds it for a system Actor (`object-link`). It gets only credentials that the plugin owns, such as an app or Junior's account, and never the viewer's. It never asks anyone to authorize. The title-context hook already uses this shape. I chose it over a plugin-owned credential read because the plugin keeps its operation allowlist (`grantForEgress`), lease caching, and audit, and no plugin reads tokens itself. Resolvers that do not use `egress` do not change. No new OAuth scopes, no migration. **Google plugin: two link types.** Each one checks that the viewer could open the object. - Docs, Sheets, and Slides. The filters are `docs.google.com` with `pathPrefix` `/document/d/`, `/spreadsheets/d/`, and `/presentation/d/`, plus the signed-in `/u/` forms such as `/document/u/0/d/`. Junior reads the file metadata. Then it asks Drive, limited to files with that name, if one of these is true: - The file names the viewer's email as a reader, writer, or owner. - The file is `anyoneWithLink` or `anyoneCanFind`. - The file is `domainWithLink` or `domainCanFind`, the viewer's domain is in `GOOGLE_WORKSPACE_ALLOWED_DOMAINS`, and an owner is in that domain. A shared-drive file has no owner, so only a share that names the viewer counts. This is the rule of `searchGoogleFiles` (#3208). A share to a group does not name the viewer, so it gets no card. A file of the wrong type, in the trash, after the first 100 results, or in a rejected query also gets no card. - Calendar events. The filters are `calendar.google.com` and `www.google.com` with the path `/calendar/event`, and `calendar.google.com` with `/calendar/r/eventedit/*` and `/calendar/u/*/r/eventedit/*`. The `eid` must name Junior's calendar. The event must list the viewer as organizer, creator, or attendee. - Card contents: - A file card has the title, type (`Google Doc`, `Google Sheet`, or `Google Slides`), owner, and modified time. - An event card has the title and time. The time is the start and end in the event's own time zone, or the date of an all-day event. The resolver does not know the viewer's time zone, and the dashboard shows `when` as text. - Cards have no content, no guests, and no images. - New object type `document` (Octicon `file`) with the facts `owner` and `modifiedAt`. Calendar uses the existing `calendar_event`. ## Tests - `tests/integration/api/object-link-egress.test.ts`: a plugin link type reads through `/api/objects` with its own lease. The credential Actor is the system Actor, not the viewer. The test fails without the core change. - `junior-google/tests/links.test.ts`: - Files: a signed-in `/u/1/` link matches and resolves. A viewer that the file names and a viewer in the file's domain get a card. These get no card: a viewer that the file does not name, a viewer outside the domain (Junior does not send the domain query), a share only to a group, a file that Junior cannot open, and a link of the wrong type. - Calendar: an attendee gets a card with the event time, and the card has no guest email. An all-day event shows its date. An event with a guest that has no email still resolves. A viewer who is not on the event gets no card. A link to another calendar gets no card, and Junior sends no Google request for it. - Dashboard e2e: the Doc and Calendar links show as chips and hover cards, and the event card shows the time. The existing object-link test now waits for resolved links before it hovers, because a late render could drop the hover when the file ran in parallel. - Also ran `pnpm typecheck`, `pnpm lint`, the dashboard and plugin-api unit tests, and the dashboard e2e. ## Screenshots (1440 wide) Google Doc | | Before | After | | --- | --- | --- | | Dark |  |  | | Light |  |  | Calendar event | | Before | After | | --- | --- | --- | | Dark |  |  | | Light |  |  | <!-- 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]>
Narrows
searchGoogleFilesto files the requester could find in Drive themselves. Today, search returns anything shared with Junior's account. Reads by link are unchanged.Changes
trashed = false:GOOGLE_WORKSPACE_ALLOWED_DOMAINSowns it, becausedomainCanFinddoes not say which domain. Shared-drive files have no owners, so they show only when the named query finds them. A file with no owner data never shows.PluginToolInputErrorthat asks for a link. It never retries without the filter.Known concerns
visibilityandin readers/writers/owners. They do not say whether these terms behave the same when Junior's account can only view a file, or how shared drives and group grants match. These need a live check.readMeetingTranscriptstays the invite-checked path from a calendar event.allowedDomainsnow also decides file ownership for search. This assumes that every allowed domain is part of the company Workspace.Testing
packages/junior-google: 34 tests pass. They cover both queries, the owner guard, an unknown or outside requester, and a rejected query.via @dcramer.
--
View Session [Sentry]