Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Avoid CodeQL redirect false positive in path guard
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
  • Loading branch information
Copilot and pelikhan authored Aug 20, 2026
commit ab30530baf2534d5a83610ea299b5eb5e86b0efa
2 changes: 1 addition & 1 deletion pkg/cli/add_package_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions pkg/cli/add_package_manifest_mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down