Skip to content

Fix repo-root-relative import path resolution in ResolveIncludePath#24501

Merged
pelikhan merged 8 commits intomainfrom
copilot/fix-import-path-resolution
Apr 4, 2026
Merged

Fix repo-root-relative import path resolution in ResolveIncludePath#24501
pelikhan merged 8 commits intomainfrom
copilot/fix-import-path-resolution

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

imports: [.github/agents/planner.md] was broken because ResolveIncludePath unconditionally joined import paths onto baseDir (.github/workflows/), producing .github/workflows/.github/agents/planner.md — a path that never exists.

Changes

  • pkg/parser/remote_fetch.go / remote_fetch_wasm.go: Before resolving, detect repo-root-relative paths and adjust the resolution base accordingly:

    • .github/-prefixed → resolve from repo root; security scope stays .github/
    • /-prefixed → strip leading slash, resolve from repo root; only .github/ and .agents/ subdirectories are accessible (all other paths are rejected with a security error)
    • All other paths → unchanged behavior (resolved relative to baseDir)
    • Fixed non-terminating loop on Windows volume roots by using parent == githubFolder as an additional termination condition
    • Normalized filePath with filepath.ToSlash before prefix checks to handle Windows-style path separators correctly
    • Security escape error messages now reflect the actual allowed folder (.github or .agents) rather than always saying .github
  • pkg/parser/frontmatter_utils_test.go: Comprehensive test coverage added across three test functions:

    • TestResolveIncludePath — core cases: .github/agents/ imports, /.github/- and /.agents/-prefixed repo-root imports, backward-compat relative imports, path traversal rejection, and rejection of /-prefixed paths outside .github/ or .agents/
    • TestResolveIncludePath_DotGithubRepo — verifies all resolution rules and traversal rejection work correctly when the repository itself is named .github (e.g. an org's org/.github repo), where the on-disk layout is <parent>/.github/.github/workflows/
    • TestResolveIncludePath_AllPathStyles — exhaustive coverage of every path form: bare filenames, ./-prefixed explicit relative, subdirectory relative, multi-level .github/agents/sub/nested.md, multi-level /.github/ and /.agents/ paths, intra-.github traversal that stays in scope, traversal attacks escaping all security scopes, slash-prefix to disallowed directories, and baseDir without any .github ancestor (plain relative fallback)

Example

# Previously failed (resolved to .github/workflows/.github/agents/planner.md)
imports: [.github/agents/planner.md]

# Now resolves correctly to <repo-root>/.github/agents/planner.md
# Also supported (restricted to .github/ and .agents/ only):
imports: [/.github/agents/planner.md]  # resolves to <repo-root>/.github/agents/planner.md
imports: [/.agents/agent.md]           # resolves to <repo-root>/.agents/agent.md

# Rejected — only .github/ and .agents/ are accessible from repo root:
imports: [/agents/agent.md]  # security error

Copilot AI changed the title [WIP] Fix repo-root-relative import path resolution in ResolveIncludePath Fix repo-root-relative import path resolution in ResolveIncludePath Apr 4, 2026
Copilot AI requested a review from pelikhan April 4, 2026 14:46
Copilot stopped work on behalf of pelikhan due to an error April 4, 2026 14:48
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 4, 2026

@copilot add tests to check that these rules work in the repo name ".github" as well

@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 4, 2026

@copilot only the .github, .agents folder are available when resolving imports. Other repo root path will be resolve

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 4, 2026

@copilot add tests to check that these rules work in the repo name ".github" as well

Added TestResolveIncludePath_DotGithubRepo in commit 2da3602. It simulates a repo whose root is a directory ending in .github (e.g. org/.github), with the layout <parent>/.github/.github/workflows/, and verifies that:

  • relative paths still resolve within the workflows dir
  • .github/agents/planner.md resolves from the repo root to <parent>/.github/.github/agents/planner.md
  • /agents/agent.md resolves from the repo root to <parent>/.github/agents/agent.md
  • traversal attacks via both prefixes are rejected

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 4, 2026

@copilot only the .github, .agents folder are available when resolving imports. Other repo root path will be resolve

The comment appears truncated — could you clarify the intended behavior? Specifically:

  1. Should /-prefixed paths (e.g. /agents/agent.md) be restricted to only .github/ and .agents/ subfolders at the repo root, with paths outside those two folders being rejected?
  2. Or should the current behavior (entire repo root is accessible via /-prefix) remain, and this comment is just describing a different constraint?

If (1), I'll update the security scope logic in ResolveIncludePath to only allow .github/ and .agents/ for /-prefixed paths, and update the tests accordingly.

@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 4, 2026

@copilot restrict workspace root to .github and .agents

Copilot AI and others added 2 commits April 4, 2026 15:49
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 4, 2026

@copilot restrict workspace root to .github and .agents

Done in commit cd24226. /-prefixed workspace-root imports are now restricted to .github/ and .agents/ only — any other path (e.g. /agents/agent.md) is immediately rejected with a security error. Tests updated accordingly.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw efaultBranchFromrev-parse ache/go/1.25.8/x--show-toplevel git rev-�� --show-toplevel ache/go/1.25.8/x64/pkg/tool/linuremote.origin.url /usr/bin/git 3706-31662/test-git GO111MODULE ache/go/1.25.8/x--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw go /usr/bin/git infocmp -1 xterm-color git /usr/bin/git 4628-48937/test-git /opt/hostedtoolcrev-parse ctl git (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw ster.patch /opt/hostedtoolc--show-toplevel git rev-�� --show-toplevel 4 -type d -nameowner /usr/bin/git lex-frontmatter-git --package-lock-orev-parse /usr/bin/git git (http block)
  • https://api.github.com/orgs/test-owner/actions/secrets
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name /tmp/go-build132-p o 64/bin/go -p github.com/githu-o -lang=go1.25 go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name /tmp/TestHashStaGOINSECURE git 64/bin/go --show-toplevel git /usr/bin/git go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name 20191771/001&#39; 20191771/001&#39; -nolocalimports -importcfg /tmp/go-build4184300624/b395/importcfg -pack /tmp/go-build4184300624/b395/_testmain.go sRem�� -json GO111MODULE k/gh-aw/gh-aw/actions/node_modules/.bin/sh GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha --git-dir go /usr/bin/git ub/workflows GO111MODULE 64/pkg/tool/linu--show-toplevel git rev-�� --show-toplevel 64/pkg/tool/linux_amd64/asm /usr/bin/git -json GO111MODULE 64/pkg/tool/linu--show-toplevel /usr/bin/git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha --show-toplevel sh /usr/bin/git ndLinux.slice GOPROXY /usr/bin/tail git rev-�� --show-toplevel tail /usr/bin/git LsRemoteWithRealgit LsRemoteWithRealrev-parse /usr/bin/gh git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha ache/node/24.14.--show-toplevel git /usr/local/sbin/iptables --show-toplevel git /usr/bin/git iptables -w -t security /usr/bin/git OUTPUT -d 168.63.129.16 git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha 2539197/b454/scripts.test git-receive-pack &#39;/tmp/TestParseDefaultBranchFromLsRemoteWithRealGitbranch_with_hyphen88481646/0rev-parse 2539197/b454/importcfg.link ACCEPT -trimpath 64/bin/go 7D8RXanEmFBss/sX9FX53sm1OTZ6jdpoJ_/CWrYu2czG7Ca7ylQP4Z8/vCNYLdc7D8RXanEmFBss remo�� s/test.md go 2539197/b454/_pkg_.a -json .go 64/bin/go gh (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha xterm-color go /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet 420191771/001&#39; 420191771/001&#39; ck /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -ato�� -bool -buildtags /usr/bin/git -errorsas -ifaceassert -nilfunc git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha --show-toplevel git ache/node/24.14.1/x64/bin/node --show-toplevel git /usr/bin/git git _cod�� --show-toplevel git 1/x64/bin/node --show-toplevel git /usr/bin/git git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha -obugO3Wj GO111MODULE ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile GOINSECURE %H %ct %D (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --paginate repos/{owner}/{repo}/actions/runs/5/artifacts /usr/bin/git .artifacts[].namgit til.go 64/pkg/tool/linu--show-toplevel git rev-�� --show-toplevel 64/pkg/tool/linux_amd64/compile /usr/bin/git til.go o 64/pkg/tool/linu--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel e/git /usr/bin/git 2158409/b144/impgit -trimpath 2539197/b284/vet--show-toplevel git rev-�� --show-toplevel /opt/hostedtoolcache/go/1.25.8/xv1.0.0 /usr/bin/git /tmp/go-build186git -trimpath /opt/hostedtoolc--show-toplevel git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha -m resolved$ /usr/bin/git lGitbranch_with_git lGitbranch_with_rev-parse x_amd64/compile git rev-�� --show-toplevel D8RXanEmFBss /usr/bin/git -json GO111MODULE ache/go/1.25.8/x--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha test.txt resolved$ /usr/bin/git -json GO111MODULE x_amd64/compile git rev-�� --show-toplevel x_amd64/compile /usr/bin/git -json GO111MODULE 64/pkg/tool/linu--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha -aw-actions/git/ref/tags/v1.2.3 ache/go/1.25.8/x64/pkg/tool/linux_amd64/link /usr/bin/git 3706-31662/test-git 1jro/oTW3DV5xy7Rrev-parse ache/go/1.25.8/x--show-toplevel git rev-�� --show-toplevel ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet /usr/bin/git ry=1 -trimpath 2539197/b070/_pk--show-toplevel git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha go1.25.8 -c=4 -nolocalimports -importcfg /tmp/go-build1862158409/b139/importcfg -pack /home/REDACTED/go/pkg/mod/github.com/modelcontextprotocol/go-sdk@v1.4.1/auth/auth.go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE x_amd64/asm GOINSECURE e5AwkbJ/TuEp7fbH--git-dir=/tmp/TestParseDefaultBranchFromLsRemoteWithRealGitbranch_with_hyphen88481646/001 GOMODCACHE x_amd64/asm (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha latted/flatted.go GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE x_amd64/asm GOINSECURE GOMOD GOMODCACHE x_amd64/asm (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha master x_amd64/compile /usr/bin/git -json n/codec.go x_amd64/compile git init�� GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha --show-toplevel e/git /usr/bin/git 3 GO111MODULE /home/REDACTED/wor--show-toplevel git chec�� -b l /usr/bin/git prettier --check ache/node/24.14.--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha --show-toplevel git /opt/hostedtoolcache/node/24.14.1/x64/bin/node --show-toplevel infocmp /usr/bin/git node js/f�� /opt/hostedtoolc--show-toplevel git /opt/hostedtoolcache/node/24.14.1/x64/bin/node --show-toplevel /opt/hostedtoolcrev-parse /usr/bin/git node (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha --show-current epo}/actions/runs/12345/artifacts /usr/bin/git e cii.go x_amd64/compile git rev-�� --show-toplevel x_amd64/compile /usr/bin/git -json GO111MODULE ache/go/1.25.8/x--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha --show-toplevel (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha --show-toplevel git /opt/hostedtoolcache/node/24.14.1/x64/bin/node --show-toplevel cvc7rdq5orYmv/jSrev-parse /usr/bin/git node js/f�� 4300624/b418/_pk--show-toplevel git /opt/hostedtoolcache/node/24.14.1/x64/bin/node --show-toplevel /opt/hostedtoolcrev-parse /usr/bin/git node (http block)
  • https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq .object.sha DJ3JnFq1XLtSaeZgGgAk/DJ3JnFq1XLtSaeZgGgAk -dwarf=false /usr/bin/git go1.25.8 -c=4 -nolocalimports git comm�� -m initial commit 1/x64/bin/node &#34;prettier&#34; --chegit node 64/bin/go 1/x64/bin/node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq .object.sha runs/20260404-154628-48937/test-3329155195 --property /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/link l GO111MODULE de_modules/.bin/--show-toplevel /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/link -o /tmp/go-build4184300624/b410/mathutil.test -importcfg ache/node/24.14.1/x64/bin/node -s -w -buildmode=exe git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq .object.sha --show-toplevel git 1/x64/bin/node 64/bin/go git /usr/bin/git git js --show-toplevel git 64/pkg/tool/linux_amd64/link --show-toplevel infocmp /usr/bin/git 64/pkg/tool/linux_amd64/link (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v0.1.2
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq .object.sha test.txt x_amd64/compile /usr/bin/git -json ase64.go x_amd64/compile git rev-�� --show-toplevel x_amd64/compile /usr/bin/git /001 GO111MODULE x_amd64/vet git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq .object.sha --show-toplevel n-YEHBy/TNAb19Ig-buildtags /usr/lib/git-core/git -json GO111MODULE /home/REDACTED/wor--show-toplevel /usr/lib/git-core/git main�� run --auto /usr/bin/git --detach GOPROXY x_amd64/vet git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq .object.sha --show-toplevel git /opt/hostedtoolcache/node/24.14.1/x64/bin/node --show-toplevel /usr/bin/git /usr/bin/git node js/f�� /opt/hostedtoolc--show-toplevel git 1762417/b371/vet.cfg --show-toplevel /opt/hostedtoolcrev-parse /usr/bin/git node (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha -bool -buildtags 1/x64/bin/node -errorsas -ifaceassert -nilfunc git-upload-pack t-ha�� ithub/workflows/auto-triage-issues.md -tests /usr/bin/git --check scripts/**/*.js 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha runs/20260404-15.artifacts[].name go tartedAt,updatedAt,event,headBranch,headSha,displayTitle l GO111MODULE ache/go/1.25.8/x--show-toplevel /usr/lib/git-core/git rev-�� --objects --stdin .git --exclude-hiddengit --all --quiet git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha --show-toplevel git 1/x64/bin/node --show-toplevel node /usr/bin/git git js --show-toplevel git 1/x64/bin/node --show-toplevel git /usr/bin/infocmp--show-toplevel git (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha runs/20260404-153706-31662/test-3392836456/custom/workflows -importcfg /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -s -w -buildmode=exe /opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/vet -ato�� -bool -buildtags /usr/bin/git -errorsas -ifaceassert -nilfunc git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha bility_SameInput.artifacts[].name go /usr/lib/git-core/git 66806673/.githubgit GO111MODULE ache/go/1.25.8/x--show-toplevel /usr/lib/git-core/git pack�� --all-progress-implied --revs t --thin --delta-base-offrev-parse -q git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha --show-toplevel git 1/x64/bin/node --show-toplevel gh /usr/bin/git git js --show-toplevel git 1/x64/bin/node --show-toplevel git /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/1/artifacts --jq .artifacts[].name 0/internal/catmsg/catmsg.go 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD abis 64/pkg/tool/linux_amd64/compile 64/s�� g_.a GO111MODULE ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile GOINSECURE r 64/src/reflect/a--git-dir ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 4.0/deviceauth.g-c=4 64/pkg/tool/linu-nolocalimports GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linu/tmp/go-build3072539197/b454/_testmain.go env g_.a diXaaNED5 ache/go/1.25.8/x64/pkg/tool/linux_amd64/asm GOINSECURE go-sdk/auth GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linux_amd64/asm (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/1/artifacts --jq .artifacts[].name GO111MODULE 1/x64/bin/node GOINSECURE GOMOD GOMODCACHE go 1/x6�� -json GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12345/artifacts --jq .artifacts[].name @v1.1.3/ascii/ascii.go 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env b/workflows B-Au8vNkW /opt/hostedtoolcache/go/1.25.8/x64/bin/go GOINSECURE cii GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 _3ywvdE5S 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env g_.a dq87ptaK6 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuremote.origin.url (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12345/artifacts --jq .artifacts[].name GO111MODULE 1/x64/bin/npx GOINSECURE GOMOD GOMODCACHE go env 8/001/test-inlined-imports-enabled-with-env-template-expressions-in-body.md GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12346/artifacts --jq .artifacts[].name @v1.1.3/keyset/keyset.go 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env b/workflows JtV1iahb4 x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 GO111MODULE 64/pkg/tool/linu-importcfg GOINSECURE GOMOD abis 64/pkg/tool/linu/home/REDACTED/work/gh-aw/gh-aw/pkg/timeutil/format_test.go 64/s�� g_.a GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE go-sdk/internal/rev-parse GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/12346/artifacts --jq .artifacts[].name GO111MODULE tions/setup/js/node_modules/.bin/node GOINSECURE GOMOD GOMODCACHE go 1/x6�� -json GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/2/artifacts --jq .artifacts[].name rotocol/go-sdk@v-c=4 64/pkg/tool/linu-nolocalimports GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linu/tmp/go-build3072539197/b446/_testmain.go env g_.a DfcRFzBGz ache/go/1.25.8/x64/pkg/tool/linux_amd64/asm GOINSECURE til GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linuremote.origin.url (http block)
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 rotocol/go-sdk@v1.4.1/auth/auth.go 64/pkg/tool/linux_amd64/compile GOINSECURE ty.o 64/src/internal/--show-toplevel 64/pkg/tool/linux_amd64/compile env g_.a tVIFB3NxN ache/go/1.25.8/x64/pkg/tool/linu-buildmode=exe GOINSECURE go-sdk/mcp GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linu-importcfg (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/2/artifacts --jq .artifacts[].name mLsRemoteWithRealGitcustom_branch474979282/001&#39; tions/setup/js/node_modules/.bin/sh GOINSECURE GOMOD GOMODCACHE go env y_with_repos_array_c1521532028/0remote.origin.url GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/3/artifacts --jq .artifacts[].name l.go 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD abis 64/pkg/tool/linux_amd64/compile env g_.a bt7zDc9ZF x_amd64/compile GOINSECURE g GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 4.0/internal/doc.go 64/pkg/tool/linux_amd64/compile GOINSECURE tants GOMODCACHE 64/pkg/tool/linux_amd64/compile env 4155064402 GO111MODULE x_amd64/link GOINSECURE GOMOD GOMODCACHE x_amd64/link (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/3/artifacts --jq .artifacts[].name GO111MODULE tions/setup/js/node_modules/.bin/sh GOINSECURE GOMOD GOMODCACHE go env y_with_repos_array_c1521532028/001 GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/4/artifacts --jq .artifacts[].name rotocol/go-sdk@v1.4.1/internal/json/json.go 64/pkg/tool/linux_amd64/compile GOINSECURE .o 64/src/internal/--git-dir 64/pkg/tool/linux_amd64/compile env l.go l_test.go ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile GOINSECURE go-sdk/internal/rev-parse GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linu-trimpath (http block)
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 dyvKs137W 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuTest User env 4155064402 QuPWq4ACQ ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/4/artifacts --jq .artifacts[].name GO111MODULE tions/setup/node_modules/.bin/sh GOINSECURE GOMOD GOMODCACHE go env y_with_repos_array_c1521532028/001 GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/5/artifacts --jq .artifacts[].name til.go 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env til.go o 64/pkg/tool/linux_amd64/compile GOINSECURE go-sdk/internal/rev-parse GOMODCACHE 64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD abis 64/pkg/tool/linutest@example.com env e-analyzer.md Bzwz7Kv-X ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api --paginate repos/{owner}/{repo}/actions/runs/5/artifacts --jq .artifacts[].name GO111MODULE tions/node_modules/.bin/sh GOINSECURE GOMOD GOMODCACHE go env */*.ts&#39; &#39;**/*.json&#39; --ignore-path ../../../.prettierignore GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path /tmp/go-build132-p -trimpath 64/bin/go ced successfully/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile main -lang=go1.25 go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 100 GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 6 GOMOD GOMODCACHE 64/pkg/tool/linuremote1 env mpiledOutput4162135394/001 Fs27lbYse 64/pkg/tool/linux_amd64/link GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/link (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v0.47.4
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq .object.sha xterm-color 64/pkg/tool/linuremote1 /usr/bin/git mpiledOutput4162git Fs27lbYse 64/pkg/tool/linu--show-toplevel git rev-�� --show-toplevel 64/pkg/tool/linux_amd64/link /usr/bin/git sole.test Y9sJvruy0 ortcfg.link git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq .object.sha b.actor }} git /usr/bin/git ithout_min-integgit config nch,headSha,disp--show-toplevel git rev-�� --show-toplevel resolved$ /usr/bin/git /tmp/gh-aw-test-/bin/sh config /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel git /usr/bin/infocmpgit-upload-pack &#39;origin&#39; git (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha edOutput2759410355/001 UHEwN-QbQ 64/pkg/tool/linux_amd64/vet GOINSECURE a20poly1305 GOMODCACHE 64/pkg/tool/linux_amd64/vet env ortcfg R30X4Bcts ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linuconfig (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha -json GO111MODULE /opt/hostedtoolcache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env b/workflows resolved$ 1740587/b395/vet.cfg GOINSECURE GOMOD GOMODCACHE node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha --show-toplevel git /usr/bin/git /tmp/TestGuardPonode remote /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git s/test.md remote /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE V8DPkJF/GIcQaFdIrev-parse (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha re GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE /opt/hostedtoolc--json /tmp�� github.token GOPROXY 64/bin/go GOSUMDB GOWORK /usr/bin/git go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha /../config GO111MODULE 1/x64/bin/node GOINSECURE GOMOD erignore ache/go/1.25.8/x64/pkg/tool/linux_amd64/vet t-ha�� ithub/workflows/agent-performance-analyzer.md GO111MODULE /opt/hostedtoolcache/go/1.25.8/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v2.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile 7292�� -json /context.go x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json color.go x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v3.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha sm-opt -Oz (sizeOUTPUT GO111MODULE x_amd64/asm GOINSECURE GOMOD GOMODCACHE x_amd64/asm env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha re GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha SameOutput2755742287/001/stability-test.md GO111MODULE 1/x64/bin/node GOINSECURE GOMOD erignore ache/go/1.25.8/x-test.count=1 t-ha�� ithub/workflows/agent-persona-explorer.md GO111MODULE 1/x64/bin/node GOINSECURE GOMOD GOMODCACHE 1/x64/bin/node (http block)
  • https://api.github.com/repos/nonexistent/action/git/ref/tags/v999.999.999
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha g_.a Hi02xO8a- 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env g_.a pKmvAbdZx ck GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x--json (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha -json GO111MODULE ache/node/24.14.1/x64/bin/node GOINSECURE GOMOD GOMODCACHE go t-20�� b/workflows GO111MODULE 1740587/b125/vet.cfg GOINSECURE GOMOD GOMODCACHE node (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha --show-toplevel git /usr/bin/git /tmp/TestGuardPonode config /usr/bin/gh git rev-�� --show-toplevel gh /usr/bin/git list --json /usr/bin/git git (http block)
  • https://api.github.com/repos/nonexistent/repo/actions/runs/12345
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet ortc�� LtLQ2zw4M g/tty/tty_wasm.go ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE ache/go/1.25.8/x64/pkg/tool/linux_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE GOMOD GOMODCACHE go tion�� b/workflows GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion th .prettierignogit GO111MODULE 64/bin/go git t-40�� sistency_GoAndJavaScript2548721206/001/test-frontmatter-with-nested-objects.md go 4300624/b412/vet.cfg -json GO111MODULE ache/go/1.25.8/x--show-toplevel systemctl (http block)
  • https://api.github.com/repos/owner/repo/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go npx prettier --w/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/compile 64/pkg/tool/linu-o 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD g/sig_other.s go (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go GOINSECURE GOMOD GOMODCACHE node /tmp�� ath ../../../.pr**/*.json GOPROXY 64/bin/go GOSUMDB GOWORK /usr/bin/git go (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build3072539197/b396/cli.test /tmp/go-build3072539197/b396/cli.test -test.testlogfile=/tmp/go-build3072539197/b396/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true -nolocalimports -importcfg /tmp/go-build1862158409/b198/importcfg -pack -o /tmp/go-build132-p o 64/bin/go -p github.com/githu-o -lang=go1.25 go (http block)
    • Triggering command: /tmp/go-build3591740587/b396/cli.test /tmp/go-build3591740587/b396/cli.test -test.testlogfile=/tmp/go-build3591740587/b396/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true GOINSECURE GOMOD GOMODCACHE ache/node/24.14.GO111MODULE 5765�� -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE node (http block)
    • Triggering command: /tmp/go-build4184300624/b223/cli.test /tmp/go-build4184300624/b223/cli.test -test.paniconexit0 -test.timeout=10m0s -test.count=1 env edOutput3209255487/001 GO111MODULE ache/go/1.25.8/x64/bin/go GOINSECURE GOMOD (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name 67292755/001&#39; 67292755/001&#39; 64/bin/go -p main -lang=go1.25 go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE node /tmp�� /home/REDACTED/worGOSUMDB GOPROXY 64/bin/go GOSUMDB GOWORK /usr/bin/git go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name -json (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@pelikhan pelikhan marked this pull request as ready for review April 4, 2026 15:58
Copilot AI review requested due to automatic review settings April 4, 2026 15:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes local include/import resolution so repo-root-relative paths (notably .github/... and /.github/...) resolve from the repository root instead of being incorrectly joined onto the workflow’s baseDir (e.g. .github/workflows/...). Also introduces controlled access to repo-root /.agents/... paths and adds tests for the new resolution and security rules.

Changes:

  • Update ResolveIncludePath to treat .github/... and /<repo-root>... paths as repo-root-relative with an explicit security scope.
  • Mirror the same path-resolution behavior in the Wasm build.
  • Add unit tests covering .github/agents imports, /.github / /.agents imports, traversal rejection, and the special case where the repository itself is named .github.
Show a summary per file
File Description
pkg/parser/remote_fetch.go Adjusts local include path resolution to support repo-root-relative .github/... and restricted /<...> imports with scoped security checks.
pkg/parser/remote_fetch_wasm.go Brings the Wasm implementation in line with the updated repo-root-relative resolution and security rules.
pkg/parser/frontmatter_utils_test.go Adds test coverage for repo-root-relative imports, .agents access rules, and traversal rejection (including .github-repo layout).

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

pkg/parser/remote_fetch.go:174

  • Repo-root-relative detection is currently hard-coded to POSIX-style prefixes (.github/, .agents/, and leading /). If an import path contains Windows separators (e.g., .github\\agents\\planner.md), it won’t be treated as repo-root-relative and will reintroduce the original bad join behavior. Consider normalizing filePath with filepath.ToSlash for prefix checks (or explicitly handling \\ variants) to keep behavior consistent across platforms.
	// Determine resolution base and security scope for the file path.
	// Paths starting with ".github/" or "/" are repo-root-relative and are resolved
	// from the repository root rather than from baseDir.
	resolveBase := baseDir
	securityBase := githubFolder
	if strings.HasSuffix(githubFolder, ".github") {
		repoRoot := filepath.Dir(githubFolder)
		if strings.HasPrefix(filePath, ".github/") {
			// .github/-prefixed path: resolve from repo root, security scope stays .github/
			resolveBase = repoRoot
		} else if stripped, ok := strings.CutPrefix(filePath, "/"); ok {
			// Repo-root-absolute path: only .github/ and .agents/ subdirectories are accessible.
			if !strings.HasPrefix(stripped, ".github/") && !strings.HasPrefix(stripped, ".agents/") {
				remoteLog.Printf("Security: Path not within .github or .agents: %s", filePath)
				return "", fmt.Errorf("security: path %s must be within .github or .agents folder", filePath)
			}
			filePath = stripped
			resolveBase = repoRoot
			if strings.HasPrefix(stripped, ".agents/") {
				securityBase = filepath.Join(repoRoot, ".agents")
			} else {
				// .github/-prefixed: security scope is the .github folder.
				securityBase = githubFolder
			}
		}
  • Files reviewed: 3/3 changed files
  • Comments generated: 4

Comment on lines 139 to 147
@@ -151,14 +147,44 @@ func ResolveIncludePath(filePath, baseDir string, cache *ImportCache) (string, e
}
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

The .github-folder search loop can become non-terminating on Windows when baseDir is not under a .github directory (e.g., C:\...), because filepath.Dir("C:\\") == "C:\\" and the loop only stops on "." or "/". Add a cross-platform termination condition (e.g., break when the parent dir equals the current dir, or handle volume roots) so local includes from non-.github directories don’t hang.

This issue also appears on line 150 of the same file.

See below for a potential fix:

		parent := filepath.Dir(githubFolder)
		if parent == githubFolder || parent == "." || parent == "/" {
			// If we can't find .github folder, use baseDir
			githubFolder = baseDir
			break
		}
		githubFolder = parent

Copilot uses AI. Check for mistakes.
Comment on lines 187 to 188
remoteLog.Printf("Security: Path escapes allowed folder: %s (resolves to: %s)", filePath, relativePath)
return "", fmt.Errorf("security: path %s must be within .github folder (resolves to: %s)", filePath, relativePath)
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

The security escape error message still says "must be within .github folder" even when securityBase is .agents (for /.agents/... imports). Update the error text to reflect the actual allowed base (e.g., mention .agents when applicable, or use a generic "allowed folder" message) so users aren’t misled during debugging.

Suggested change
remoteLog.Printf("Security: Path escapes allowed folder: %s (resolves to: %s)", filePath, relativePath)
return "", fmt.Errorf("security: path %s must be within .github folder (resolves to: %s)", filePath, relativePath)
allowedFolder := filepath.Base(normalizedSecurityBase)
remoteLog.Printf("Security: Path escapes allowed folder: %s (resolves to: %s)", filePath, relativePath)
return "", fmt.Errorf("security: path %s must be within %s folder (resolves to: %s)", filePath, allowedFolder, relativePath)

Copilot uses AI. Check for mistakes.
relativePath, err := filepath.Rel(normalizedGithubFolder, normalizedFullPath)
relativePath, err := filepath.Rel(normalizedSecurityBase, normalizedFullPath)
if err != nil || relativePath == ".." || strings.HasPrefix(relativePath, ".."+string(filepath.Separator)) || filepath.IsAbs(relativePath) {
return "", fmt.Errorf("security: path %s must be within .github folder (resolves to: %s)", filePath, relativePath)
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

In the Wasm implementation, the security escape error message always says "must be within .github folder" even though securityBase can be .agents for /.agents/... imports. Adjust the error text to reflect the actual security scope (or use a generic "allowed folder" message) to avoid misleading errors.

Suggested change
return "", fmt.Errorf("security: path %s must be within .github folder (resolves to: %s)", filePath, relativePath)
return "", fmt.Errorf("security: path %s must be within the allowed folder (resolves to: %s)", filePath, relativePath)

Copilot uses AI. Check for mistakes.
Comment on lines +80 to +99
resolveBase := baseDir
securityBase := githubFolder
if strings.HasSuffix(githubFolder, ".github") {
repoRoot := filepath.Dir(githubFolder)
if strings.HasPrefix(filePath, ".github/") {
resolveBase = repoRoot
} else if stripped, ok := strings.CutPrefix(filePath, "/"); ok {
// Repo-root-absolute path: only .github/ and .agents/ subdirectories are accessible.
if !strings.HasPrefix(stripped, ".github/") && !strings.HasPrefix(stripped, ".agents/") {
return "", fmt.Errorf("security: path %s must be within .github or .agents folder", filePath)
}
filePath = stripped
resolveBase = repoRoot
if strings.HasPrefix(stripped, ".agents/") {
securityBase = filepath.Join(repoRoot, ".agents")
} else {
// .github/-prefixed: security scope is the .github folder.
securityBase = githubFolder
}
}
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

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

Repo-root-relative detection here only recognizes POSIX-style prefixes (.github/, .agents/, leading /). If callers pass Windows-style paths (e.g., .github\\agents\\planner.md), the repo-root-relative logic won’t trigger. Consider normalizing filePath (e.g., filepath.ToSlash) for these prefix checks or handling \\ variants explicitly, consistent with other path-normalization code in the repo.

Copilot uses AI. Check for mistakes.
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 4, 2026

@copilot View comments

…th normalization

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/08030f89-48e0-4052-9704-8e8327ff2d94

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 4, 2026

@copilot View comments

Addressed all three review comments in commit 1367012:

  • Loop termination: Added parent == githubFolder check to handle Windows volume roots (both files)
  • Error messages: Now uses filepath.Base(normalizedSecurityBase) so the message reflects the actual allowed folder (.github or .agents)
  • Windows path normalization: Added filepath.ToSlash before prefix checks; filepath.FromSlash after stripping the leading / to restore native separators for file operations

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha -bool -buildtags /usr/bin/git -errorsas -ifaceassert -nilfunc git cat-�� --end-of-options blob /opt/hostedtoolcache/node/24.14.1/x64/bin/node (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha 3298855/b162/_pkg_.a --local 1/x64/bin/node commit.gpgsign chr/testify/asserev-parse (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha env.NODE_VERSION (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel x_amd64/vet /usr/bin/git llector.slice (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha k/gh-aw/gh-aw/.github/workflows/agentic-observability-kit.md /tmp/go-build2813298855/b054/vet.cfg 3298855/b351/vet.cfg (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha k/gh-aw/gh-aw/.github/workflows/auto-triage-issues.md /tmp/go-build2813298855/b111/vet.cfg 3298855/b329/vet.cfg (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha --show-toplevel x_amd64/vet /usr/bin/git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha sistency_WithImports1690320948/001/main.md /tmp/go-build2813298855/b004/vet.cfg 3298855/b308/vet.cfg (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha k/gh-aw/gh-aw/.github/workflows/artifacts-summary.md k/gh-aw/gh-aw/pkg/parser/import_cycle_test.go 3298855/b350/vet.cfg (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha k/gh-aw/gh-aw/.github/workflows/blog-auditor.md /tmp/go-build2813298855/b079/vet.cfg 3298855/b123/vet.cfg (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha k/gh-aw/gh-aw/.github/workflows/archie.md /tmp/go-build2813298855/b136/vet.cfg 3298855/b295/vet.cfg (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha k/gh-aw/gh-aw/.github/workflows/ai-moderator.md /tmp/go-build2813298855/b055/vet.cfg 3298855/b353/vet.cfg (http block)
  • https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq .object.sha --get-regexp .cfg 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v0.1.2
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq .object.sha sistency_InlinedImports2566361785/001/inlined-a.md /tmp/go-build2813298855/b042/vet.cfg 3298855/b294/vet.cfg ACCEPT (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha get .cfg 64/pkg/tool/linux_amd64/vet http.https://gitgit (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha get .cfg 64/pkg/tool/linux_amd64/vet http.https://gitgit (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v0.47.4
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq .object.sha --show-toplevel (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha (http block)
  • https://api.github.com/repos/nonexistent/action/git/ref/tags/v999.999.999
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 4, 2026

@copilot More tests covering all paths styles

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 4, 2026

@copilot More tests covering all paths styles

Added TestResolveIncludePath_AllPathStyles in commit 7043365 covering all path forms:

  • Bare filename and ./-prefixed explicit relative paths
  • Subdirectory relative paths (sub/nested.md)
  • Multi-level .github/agents/sub/nested.md (repo-root via .github/ prefix)
  • Multi-level /.github/agents/sub/nested.md and /.github/workflows/workflow.md (via /.github/ prefix)
  • Multi-level /.agents/sub/nested.md (via /.agents/ prefix)
  • Intra-.github traversal that stays in scope (.github/agents/../workflows/workflow.md → valid)
  • Traversal attacks escaping .github, /.github, and /.agents scope (all rejected)
  • Slash prefix to disallowed top-level directory (/src/main.go, /etc/passwd) — rejected
  • baseDir without any .github ancestor — falls back to plain relative resolution

@pelikhan pelikhan merged commit 6cfe66f into main Apr 4, 2026
85 checks passed
@pelikhan pelikhan deleted the copilot/fix-import-path-resolution branch April 4, 2026 17:04
@github-actions

This comment has been minimized.

@github-actions github-actions bot added the lgtm label Apr 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 4, 2026

🟢 Contribution Check — Aligned

Hey @Copilot 👋 — great work on this import-path fix! Resolving the long-standing bug where .github/-prefixed imports were incorrectly joined onto baseDir (producing paths like .github/workflows/.github/agents/planner.md) is a meaningful quality-of-life improvement for anyone using imports: in their agentic workflows.

Checklist

Check Result
On-topic ✅ yes — core bug fix in pkg/parser, directly relevant to workflow import resolution
Follows process ✅ yes — PR created by Copilot agent; pelikhan (COLLABORATOR) assigned and reviewing, matching the agentic-PR model described in CONTRIBUTING.md
Focused ✅ yes — single, cohesive fix touching only remote_fetch.go, remote_fetch_wasm.go, and their test file
New dependencies ✅ no — no changes to go.mod or go.sum
Has tests ✅ yes — 373 lines of new test coverage across TestResolveIncludePath, TestResolveIncludePath_DotGithubRepo, and TestResolveIncludePath_AllPathStyles
Has description ✅ yes — detailed PR body with per-change breakdown, before/after examples, and security scoping rationale
Diff size 472 lines (450 additions, 22 deletions)

Summary

This PR is well-aligned with the project's contribution guidelines. The fix is surgical (two mirrored files for native + Wasm), security considerations are explicitly handled, Windows path separators are normalized, and coverage is comprehensive — including the edge case of a repo named .github. This looks ready for maintainer review. 🎉

Generated by Contribution Check · ● 2.5M ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plan] Fix repo-root-relative import path resolution in ResolveIncludePath

3 participants