-
Notifications
You must be signed in to change notification settings - Fork 103
feat: add transitive dependency resolution to URL resolver #1923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ggallen
merged 1 commit into
fullsend-ai:main
from
ggallen:feat/adr0038-phase2-transitive-resolver
Jun 8, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| package resolve | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "net/url" | ||
| ) | ||
|
|
||
| // ResolveRelativeURL resolves a relative reference against a parent URL | ||
| // using RFC 3986 semantics. Absolute URLs are returned unchanged. The | ||
| // caller must validate the resolved URL against allowed prefixes. | ||
| func ResolveRelativeURL(parentURL, relRef string) (string, error) { | ||
| rel, err := url.Parse(relRef) | ||
| if err != nil { | ||
| return "", fmt.Errorf("parsing relative ref %q: %w", relRef, err) | ||
| } | ||
| if rel.IsAbs() { | ||
|
ggallen marked this conversation as resolved.
|
||
| return relRef, nil | ||
| } | ||
|
|
||
| parent, err := url.Parse(parentURL) | ||
| if err != nil { | ||
| return "", fmt.Errorf("parsing parent URL %q: %w", parentURL, err) | ||
| } | ||
|
|
||
| resolved := parent.ResolveReference(rel) | ||
| return resolved.String(), nil | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| package resolve | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| func TestResolveRelativeURL(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| parentURL string | ||
| relRef string | ||
| want string | ||
| wantErr bool | ||
| }{ | ||
| { | ||
| name: "sibling reference", | ||
| parentURL: "https://example.com/skills/rust/SKILL.md", | ||
| relRef: "../common/SKILL.md", | ||
| want: "https://example.com/skills/common/SKILL.md", | ||
| }, | ||
| { | ||
| name: "child reference", | ||
| parentURL: "https://example.com/skills/rust/SKILL.md", | ||
| relRef: "policies/sandbox.yaml", | ||
| want: "https://example.com/skills/rust/policies/sandbox.yaml", | ||
| }, | ||
| { | ||
| name: "absolute URL passthrough", | ||
| parentURL: "https://example.com/skills/rust/SKILL.md", | ||
| relRef: "https://other.com/skills/common/SKILL.md#sha256=abc", | ||
| want: "https://other.com/skills/common/SKILL.md#sha256=abc", | ||
| }, | ||
| { | ||
| name: "path traversal resolves correctly", | ||
| parentURL: "https://github.com/org/skills/rust/SKILL.md", | ||
| relRef: "../../../../attacker/evil.md", | ||
| want: "https://github.com/attacker/evil.md", | ||
| }, | ||
| { | ||
| name: "multiple parent segments", | ||
| parentURL: "https://example.com/a/b/c/d/SKILL.md", | ||
| relRef: "../../other/sub/SKILL.md", | ||
| want: "https://example.com/a/b/other/sub/SKILL.md", | ||
| }, | ||
| { | ||
| name: "fragment preservation", | ||
| parentURL: "https://example.com/skills/rust/SKILL.md", | ||
| relRef: "../common/SKILL.md#sha256=abc123", | ||
| want: "https://example.com/skills/common/SKILL.md#sha256=abc123", | ||
| }, | ||
| { | ||
| name: "bare fragment reference", | ||
| parentURL: "https://example.com/skills/rust/SKILL.md", | ||
| relRef: "#sha256=abc123", | ||
| want: "https://example.com/skills/rust/SKILL.md#sha256=abc123", | ||
| }, | ||
| { | ||
| name: "invalid parent URL", | ||
| parentURL: "://bad-url", | ||
| relRef: "../sibling.md", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "invalid relRef percent-encoding", | ||
| parentURL: "https://example.com/skills/rust/SKILL.md", | ||
| relRef: "%xy/invalid.md", | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "empty relRef resolves to parent URL", | ||
| parentURL: "https://example.com/skills/rust/SKILL.md", | ||
| relRef: "", | ||
| want: "https://example.com/skills/rust/SKILL.md", | ||
| }, | ||
| { | ||
| name: "empty parentURL with relative ref", | ||
| parentURL: "", | ||
| relRef: "other/SKILL.md", | ||
| want: "/other/SKILL.md", | ||
| }, | ||
| { | ||
| name: "parent URL with no path component", | ||
| parentURL: "https://example.com", | ||
| relRef: "../foo", | ||
| want: "https://example.com/foo", | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| got, err := ResolveRelativeURL(tt.parentURL, tt.relRef) | ||
| if tt.wantErr { | ||
| require.Error(t, err) | ||
| return | ||
| } | ||
| require.NoError(t, err) | ||
| assert.Equal(t, tt.want, got) | ||
| }) | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.