Repository navigation
ref(lint): Resolve restricted calls through imports - #3447
Closed
sentry-junior[bot] wants to merge 10 commits into
Closed
sentry-junior[bot] wants to merge 10 commits into
sentry-junior[bot] wants to merge 10 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
27 screenshot changes — 27 changed · 0 added · 0 removed Review screenshots in Frameshift Show 12 more changed screenshots9 more changed screenshots in Frameshift. |
sentry-junior
Bot
force-pushed
the
oxlint-restricted-call
branch
from
November 14, 2026 21:38
ec3cce8 to
06aede5
Compare
This comment has been minimized.
This comment has been minimized.
Add junior/restricted-call, a data-driven oxlint rule that resolves each use of a restricted function back to its import with scope analysis. It catches renamed, namespace, destructured, dynamic, relative, and .js imports, plus re-exports. It also matches Slack Web API methods through member access, destructuring, and apiCall. Move no-direct-core-model-calls and the postSlackMessage and chat.postMessage parts of no-raw-slack-turn-post onto it. thread.post stays in ast-grep because thread is a parameter, not an import. Co-Authored-By: David Cramer <[email protected]>
TSInstantiationExpression wraps a value, so completeText<T> as a value must still report. Co-Authored-By: David Cramer <[email protected]>
Co-Authored-By: David Cramer <[email protected]>
Co-Authored-By: David Cramer <[email protected]>
Report computed chat methods through aliases and destructuring, destructured apiCall, restricted method strings passed to any call, typeof import() casts of restricted modules, and more visible-post Slack methods. Resolve option paths from the config directory so a package-rooted run works. Restrict rerankTexts. Move the thread.post ack exemptions inline. Co-Authored-By: David Cramer <[email protected]>
The moved Conversation's first post, the stop ack, and the opt-out ack now post as Conversation output with the footer. The moved post is standard Markdown, since sendSlackReply renders a markdown block, and a lost move race deletes every post. Remove the unreachable "account connected" post from the OAuth callback, and the OAuth state fields only it read. Co-Authored-By: David Cramer <[email protected]>
sentry-junior
Bot
force-pushed
the
oxlint-restricted-call
branch
from
November 14, 2026 22:22
87fd8c1 to
943de78
Compare
dcramer
approved these changes
Nov 14, 2026
Co-Authored-By: David Cramer <[email protected]>
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 5a99f02. Configure here.
Contributor
Author
|
Closing without merging. An independent audit found this check overbuilt for what it guards, and @dcramer approved replacing it with a smaller PR. The real fixes in it move to their own PRs. |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

ast-grep matches text, so its "only the owner may call this" rules miss aliases.
no-direct-core-model-callsmatched only a named import from the exact string@/chat/pi/client. Namespace imports (already inchat/core-model.ts), relative paths, and.jsspecifiers got past it.This adds
junior/restricted-call, a data-driven oxlint rule. Each entry in.oxlintrc.jsonnames a module and its restricted exports, or Slack Web API methods, plus the owner files inallowand a message. Each owner needs areason.aliasesmaps@/topackages/junior/src/. Paths resolve from the directory of the nearest.oxlintrc.json, so a run from a package directory (editor, language server) gives the same result. The rule uses scope analysis to resolve each use back to its import.What it reports
Outside an owner, any use that is not in a type position:
gateway["completeText"], aliases, destructuring, and a namespace passed elsewhereimport x = require(...),require(...),await import(...), andimport(...).then(...)export { x } from,export * from)typeof import("<restricted module>"),typeof import(...).completeText, andtypeof <namespace>. These are how a computedimport(spec)gets typed as the module.@/, relative paths,.js/.ts,.., a trailing/, or different case, all resolved to the same modulechat.postMessage,chat.scheduleMessage,chat.meMessage,chat.startStream,files.uploadV2,filesUploadV2,files.completeUploadExternal):apiCall("chat.postMessage"),apiCall.call(client, "chat.postMessage"), orfn.apply(client, ["chat.postMessage"])apiCallwith a computed method,apiCallread without a call, and{ apiCall }destructuringchat, including through an alias (const c = client.chat,const { chat } = client) or a computed destructuring key (const { [m]: post } = client.chat)api/<method>, such as a rawfetchURLrerankTextsis now restricted with the otherpi/clientmodel calls.In an owner, only a direct call is allowed. Exporting, aliasing, destructuring, or passing the function, or a wrapper that only forwards its parameters, is reported as an owner leak.
pnpm restricted-call-exceptions:checkruns inpnpm lint. It fails when anallowowner exempts no use or does not exist. It also fails when a disable is notoxlint-disable-next-line junior/restricted-call -- <reason>; oxlint cannot report that itself, because a file-wide disable would also hide the report.unicorn/no-abusive-eslint-disableis now on, so a disable that names no rule fails.thread.poststays in ast-grep (no-raw-slack-turn-post).threadis a Chat SDK parameter, not an import, so there is nothing to resolve. Nothread.postcall is left inpackages/junior/src, so the rule is now a plain ban on.post(...)on any variable whose name ends inthread, with no exemptions.Exceptions
Before, on
main: 16. Three rule-levelignores(plugins/model.ts,slack/outbound.ts,slack/reply.ts), 11 inlineast-grep-ignorecomments, and a pattern-level exemption inno-raw-slack-turn-postfor 2 ack posts.core-model.tswas also exempt in practice, because its namespace import got past the rule.After: 5. Four owners and one inline disable.
chat/core-model.ts: owns the boundary. It names each core model call's operation and records its cost.chat/plugins/model.ts: owns the plugin model boundary. Plugin calls name prompts<plugin>.<role>, record cost as events in the plugin's namespace through the host recorder (plugins/model-cost.ts), and include reranking. core-model names promptsjunior.<operation>, records onlyjunioroperations, and has no rerank wrapper, so folding this in would move plugin attribution into core.chat/slack/reply.ts(postSlackMessageonly): owns Turn reply delivery, with the Conversation footer and the thread fromresolveSlackReplyTarget.chat/slack/outbound.ts(Slack post methods only): owns the Slack Web API boundary.slack/review-item-card-sync.ts(inline disable): an external API constraint. The card is one message thatchat.updatelater replaces in place.sendSlackReplysplits text and adds a footer, so it cannot post an updatable card. The thread already comes fromresolveSlackReplyTarget.Fixed:
automations/blocked-notice.tsandoauth-flow.ts(2 sites): they now use the newpostSlackDirectMessageinslack/outbound.ts. It posts only into one user's DM and refuses a non-DM channel. The DM fallback inoauth-flow.tsnow usesopenSlackDirectMessageinstead of its own copy ofconversations.open.slack/continue-in-slack.ts: it posts throughsendSlackReply, and the permalink comes from a separategetSlackMessagePermalinkcall. The text is now standard Markdown (**[title](url)**), becausesendSlackReplyrenders amarkdownblock, and mrkdwn links or entities would show up literally there. If the move loses its race, every returned post is deleted.postSlackMessageno longer takesincludePermalink, since this was its only caller.handlers/oauth-callback.ts: the "account is now connected" thread post could never run, so it is deleted. Only two flows start OAuth. DashboardstartConnectionsets no channel or thread. Plugin auth sets a channel only for Slack destinations, and it always sets the resume Conversation and Turn ids, soresumesAgentTurnis true whenever a channel is set. The unused "you'll see a confirmation in Slack" completion text and thechannelId/threadTsOAuth state fields, which only that branch read, are deleted too.ingress/slack-stop.ts) and opt-out ack (providers/slack/runtime.ts): they post throughsendSlackReplywith the Conversation id. Bot posts are ignored at ingress, so an ack cannot start a Turn.User-visible changes
The footer calls the plugin hook
getPluginSlackConversationLinksynchronously and does not catch its errors. A throwing plugin hook can now also fail these three posts. That is already true for every reply, and it is tracked separately.Gaps the rule cannot close
(p) => completeText({ ...p }), looks the same as a real wrapper. Only review catches it.const m = "chat.postMessage"; client[k].call(client, m).`${base}/chat.${verb}`..postMessageand{ postMessage }on Worker, window, or MessagePort are false positives. There are none inpackages/junior/src..post(...)on a Chat SDK Thread held in a variable whose name does not end inthreadgets past the ast-grep rule.import f = ns.completeText(TS1294 undererasableSyntaxOnly),Reflect.get(anti-slop), andObject.values(client.chat)(needsany).packages/junior/src.packages/junior-evals/src/fixture/judge.tscallscompleteTextfrompi/clientfor the eval judge, outside it.no-slack-thread-from-conversation-idand the secret env reads rule are separate PRs.via @dcramer.
--
View Session [Sentry]