[dotnet-port-fixes] Revalidate file skill paths before use - #1089
Quim Muntal (qmuntal) merged 2 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical and moderate findings remain.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This pull request hardens file-backed skill resource and script access by revalidating discovered paths before use.
Changes:
- Adds scoped path and symlink validation.
- Applies validation before resource reads and script execution.
- Adds regression tests for path replacement scenarios.
Outstanding findings: critical (2 votes) symlink checks can be bypassed on link-unaware filesystems; moderate (1 vote) non-regular paths are not rejected.
File summaries
| File | Summary |
|---|---|
agent/skills/fsskills/source.go |
Applies validation to resources and scripts. |
agent/skills/fsskills/source_test.go |
Tests resource-path revalidation. |
agent/skills/fsskills/source_script_test.go |
Tests script-path revalidation. |
agent/skills/fsskills/path_scope.go |
Adds path containment and symlink validation helpers. |
Review details
Suppressed comments (1)
agent/skills/fsskills/path_scope.go:47
- After discovery, the path can be replaced by a directory, FIFO, device, or another non-regular node.
fs.Statonly checks that the path exists, so scripts still invoke the runner for such a path (and a custom runner can consume it), even though discovery only collects regular files; resources also get a later, less preciseReadFilefailure. Checkinfo.Mode().IsRegular()afterStatand reject non-regular paths before returning.
if _, err := fs.Stat(s.rootFS, fullPath); err != nil {
if errors.Is(err, fs.ErrNotExist) {
return "", fmt.Errorf("%s file %q was not found in the skill directory", kind, relativePath)
}
return "", err
- Files reviewed: 4/4 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| info, err := fs.Stat(filesystem, filePath) | ||
| if err != nil { | ||
| return true | ||
| } | ||
| return info.Mode()&fs.ModeSymlink != 0 |
This comment has been minimized.
This comment has been minimized.
|
Copilot address PR feedback |
Co-authored-by: michelle-clayton-work <262183035+michelle-clayton-work@users.noreply.github.com>
Addressed in |
|
Scope: internal-only Changed Go contract: None. All new/changed identifiers are unexported: Upstream evidence reviewed: This is a port of microsoft/agent-framework#8151 (commit
Result: aligned. Verified
|
Tip
Your pull request is ready to create! 🎉 ✅
Everything is OK—the changes have been pushed to branch
dotnet-port-fixes-file-skill-revalidation-20260916-d42056936256a58c. Please review the changes, including any protected files, before creating the pull request.Create the pull request
The original pull request description is below.
Summary
Ported .NET PRs
5b188dd80e46d6fe7ae57ca88c4a51bb2e10021bBreaking Changes
No. The Go public API is unchanged; discovered file-backed skills now fail safely if their underlying path is replaced by a symlink after discovery.
Tests and Examples
go test ./agent/skills/fsskills ./agent/skillsNotes
Closes #1081