Skip to content

[dotnet-port-fixes] Revalidate file skill paths before use #1081

Description

@github-actions

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

  • Revalidate discovered file-skill resource and script paths against the original discovery root immediately before reading or running them.
  • Preserve the existing file-backed skill API and runner metadata while rejecting parent-directory or skill-directory symlink swaps after discovery.
  • Add regression tests covering resource reads and script runs after a discovered parent path is replaced with a symlink.

Ported .NET PRs

Breaking 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/skills
  • Added regression tests for resource reads and script runs after parent-directory symlink replacement
  • No example changes

Notes

  • I classified this as a fixes port because the upstream diff only added internal path-scope and validation helpers plus resource/script call-site checks; it did not add public options, builders, or exported contract changes.
  • Recent upstream work such as the session-store promotion and OpenTelemetry source-name changes was deferred because it changes public API or targets .NET-only surfaces.

Note

GitHub Actions is not permitted to create or approve pull requests in this repository.

The changes have been pushed to branch dotnet-port-fixes-file-skill-revalidation-20260916-d42056936256a58c and are ready to review.

To fix the permissions issue, go to SettingsActionsGeneral and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ

Show patch preview (62 of 329 lines)
From a58c9e2588a88c6b03fd3aab937aaddc19f49aa4 Mon Sep 17 00:00:00 2001
X-GH-AW-Base-Commit: 4b46045b01079041f0b8f5121b4cf66a79be8bd3
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Wed, 16 Sep 2026 02:48:21 +0000
Subject: [PATCH] [dotnet-port-fixes] Revalidate file skill paths before use

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 agent/skills/fsskills/path_scope.go         | 92 +++++++++++++++++++++
 agent/skills/fsskills/source.go             | 39 +++++----
 agent/skills/fsskills/source_script_test.go | 35 ++++++++
 agent/skills/fsskills/source_test.go        | 25 ++++++
 4 files changed, 177 insertions(+), 14 deletions(-)
 create mode 100644 agent/skills/fsskills/path_scope.go

diff --git a/agent/skills/fsskills/path_scope.go b/agent/skills/fsskills/path_scope.go
new file mode 100644
index 0000000..20ecbea
--- /dev/null
+++ b/agent/skills/fsskills/path_scope.go
@@ -0,0 +1,92 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+package fsskills
+
+import (
+	"errors"
+	"fmt"
+	"io/fs"
+	"path"
+	"strings"
+)
+
+type skillPathScope struct {
+	rootFS         fs.FS
+	skillDirPath   string
+	skillDirPrefix string
+}
+
+func newSkillPathScope(rootFS fs.FS, skillDirPath string) skillPathScope {
+	skillDirPath = path.Clean(skillDirPath)
+	skillDirPrefix := ""
+	if skillDirPath != "." {
+		skillDirPrefix = skillDirPath + "/"
+	}
+	return skillPathScope{
+		rootFS:         rootFS,
+		skillDirPath:   skillDirPath,
+		skillDirPrefix: skillDirPrefix,
+	}
+}
+
+func (s skillPathScope) validateDiscoveredPathForUse(relativePath, kind string) (string, error) {
+	fullPath := path.Clean(relativePath)
+	if s.skillDirPath != "." {
+		fullPath = path.Clean(path.Join(s.skillDirPath, relativePath))
+	}
+	if !s.contains(fullPath) {
+		return "", fmt.Errorf("%s file %q references a path outside the skill directory", kind, relativePath)
+	}
+	if hasLinkOrInspectionFailureInPath(s.rootFS, fullPath) {
+		return "", fmt.Errorf
... (truncated)

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • github.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"

See Network Configuration for more information.

Generated by .NET to Go Fixes and Test Porting Agent · copilot · gpt54 · 210.3 AIC · ⌖ 10.7 AIC · ⊞ 19K ·

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions