From 07e5df93d3f5bc7ec280019b45872885ac19bff8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Aug 2026 00:28:09 +0000 Subject: [PATCH 1/2] Initial plan From ab30530baf2534d5a83610ea299b5eb5e86b0efa Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Aug 2026 00:34:21 +0000 Subject: [PATCH 2/2] Avoid CodeQL redirect false positive in path guard Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com> --- pkg/cli/add_package_manifest.go | 2 +- pkg/cli/add_package_manifest_mapping_test.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/cli/add_package_manifest.go b/pkg/cli/add_package_manifest.go index 19b33049289..0886ee0ae51 100644 --- a/pkg/cli/add_package_manifest.go +++ b/pkg/cli/add_package_manifest.go @@ -576,7 +576,7 @@ func parseManifestIncludeMapping(mapping map[string]any, manifestPath string) (r // paths that escape their root. func cleanManifestRelativePath(p string) (string, error) { slashed := filepath.ToSlash(p) - if strings.HasPrefix(slashed, "/") || strings.HasPrefix(slashed, "\\") || filepath.IsAbs(p) || isWindowsDriveRelativePath(slashed) { + if len(slashed) > 0 && (slashed[0] == '/' || slashed[0] == '\\') || filepath.IsAbs(p) || isWindowsDriveRelativePath(slashed) { return "", errors.New("absolute paths are not allowed") } cleaned := path.Clean(slashed) diff --git a/pkg/cli/add_package_manifest_mapping_test.go b/pkg/cli/add_package_manifest_mapping_test.go index 425f9d3f22b..52254a14489 100644 --- a/pkg/cli/add_package_manifest_mapping_test.go +++ b/pkg/cli/add_package_manifest_mapping_test.go @@ -13,6 +13,18 @@ import ( "github.com/stretchr/testify/require" ) +func TestCleanManifestRelativePathRejectsAbsoluteForms(t *testing.T) { + t.Parallel() + + for _, input := range []string{"/tmp/reviewer.md", `\tmp\reviewer.md`, `C:/tmp/reviewer.md`} { + t.Run(input, func(t *testing.T) { + t.Parallel() + _, err := cleanManifestRelativePath(input) + assert.EqualError(t, err, "absolute paths are not allowed") + }) + } +} + // setupMappingPackageTest wires the package resolution hooks so that only the manifest and // README of a package are available, and auto-scan is disabled. func setupMappingPackageTest(t *testing.T, manifest map[string]string) {