GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(core): normalize webfetch permission rules like requested URLs by rekram1-node · Pull Request #62260 · anomalyco/opencode

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Nov 6, 2026 •
edited by opencodejr Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Problem

#60505 started checking webfetch permissions against the parsed URL (new URL(input).href), which lowercases the host, punycodes it, drops a default port and adds a / path. Rules from config are still matched as written, so some rules that used to match stopped matching:

Rule Request Before 60505 Since 60505
https://example.com https://example.com deny allow
https://Internal.Corp/* https://Internal.Corp/docs deny allow
https://пример.срб/* https://пример.срб/docs deny allow
https://port.test:443/* https://port.test/docs deny allow

A deny rule silently stops blocking, and an allow rule starts prompting.

Change

Rewrite the scheme and host of each webfetch rule the same way when agent permissions are loaded, next to the existing ~ expansion for path rules. The path and everything after it stays as written, so wildcards keep working.

https://example.com       → https://example.com/
HTTPS://Internal.Corp/*   → https://internal.corp/*
https://пример.срб/*      → https://xn--e1afmkfd.xn--90a3ac/*
https://port.test:443/*   → https://port.test/*
https://prefix.test*      → unchanged (trailing wildcard, no `/` added)
https://query.test?q=*    → unchanged (`?` is also a wildcard, so ambiguous)
*                         → unchanged

Image downloads in image_generate also check webfetch, but with the raw URL, so they now use the parsed URL too to match the same rules.

Out of scope

  • Paths are not re-encoded, so a rule with a literal space in its path still won't match %20.
  • A trailing-dot host (evil.com.) still differs from evil.com, same as before.

Verification

  • bun test test/config/agent.test.ts: 38 pass. The new test fails without the change.
  • bun test test/permission.test.ts test/tool-webfetch.test.ts test/codemode test/tool-image-generate.test.ts test/config: 531 pass.
  • bun typecheck in packages/core: clean.

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" fill="none" stroke="currentColor" font-family="ui-monospace,monospace" font-size="9">
  <style>
    .r{animation:m 3s ease-in-out infinite}
    .k{opacity:1;animation:k 3s ease-in-out infinite}
    @keyframes m{0%,20%{transform:translateY(0)}50%,100%{transform:translateY(20px)}}
    @keyframes k{0%,45%{opacity:.15}60%,100%{opacity:1}}
    @media (prefers-reduced-motion:reduce){.r,.k{animation:none}.r{transform:translateY(20px)}}
  </style>
  <rect x="8" y="34" width="150" height="20" rx="4" opacity=".4"/>
  <text x="16" y="47" fill="currentColor" stroke="none" opacity=".8">https://example.com/</text>
  <g class="r">
    <rect x="8" y="8" width="150" height="20" rx="4"/>
    <text x="16" y="21" fill="currentColor" stroke="none">rule → example.com/</text>
  </g>
  <path class="k" d="M190 40l8 8 16-18" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

Added by the opencode bot (AI-generated).

Related: #55232

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node
fix(core): normalize webfetch permission rules like requested URLs
3bb8eb5
@github-actions github-actions Bot added the contributor label Nov 6, 2026
opencodejr[bot]
opencodejr Bot reviewed Nov 6, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The change looks sound. I copied the new test into the base checkout, where it fails (allow instead of deny for rules like https://example.com and https://port.test:443/*). With this PR it passes, and the permission, webfetch, image_generate and Code Mode tests pass too (251). tsc -b is clean in packages/core. I also ran the rewrite on its own against wildcard hosts and ports, IPv6, percent-encoded hosts, file: and fragment rules. It handles them well, and anything it can't rewrite safely stays as written.

Public API is unchanged. Existing webfetch rules match the way they did before #60505, and no config needs editing.

One small point inline on image_generate: it doesn't drop the fragment the way webfetch and Code Mode fetch do.

Related: #55232

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/src/tool/plugin/image-generate.ts Outdated
yield* permission.assert({
action: "webfetch",
resources: [source],
resources: [URL.parse(source)?.href ?? source],

@opencodejr opencodejr Bot Nov 6, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This now checks the parsed URL, but unlike the webfetch tool and Code Mode fetch it keeps the #fragment and doesn't reject user@host credentials. So an exact-URL rule like https://cdn.test/a.png still won't match https://cdn.test/a.png#x here, while it does match in webfetch. Clearing hash on the parsed URL, as those two do, would make all three match the same rules.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node
fix(core): drop the fragment from image download permission URLs
181629b
opencodejr[bot]
opencodejr Bot reviewed Nov 6, 2026
View reviewed changes

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

The new commit fixes my earlier point: image downloads now drop the #fragment before the webfetch check, so an exact-URL rule matches them the same way it matches webfetch. Image-generate and agent config tests pass (53), and tsc -b is clean in packages/core. Public API is unchanged. Nothing else to raise.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rekram1-node rekram1-node mentioned this pull request Nov 6, 2026
fix(core): match webfetch rules against the URL as written #62373
Merged
3 of 6 tasks
@rekram1-node

rekram1-node commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

Superseded by #62373, which matches webfetch rules against the URL as written again, so rules no longer need normalizing.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rekram1-node rekram1-node closed this Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencodejr opencodejr[bot] opencodejr[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

contributor

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@rekram1-node
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.