cmd/go/internal/modload: MainModuleSet.DirImportPath
does not check module boundaries
#66119
Labels
FixPending
Issues that have a fix which has not yet been reviewed or submitted.
GoCommand
cmd/go
modules
Milestone
Go version
5dcc04a
Output of
go env
in your module/workspace:What did you do?
Reviewed test failures on pending https://go.dev/cl/567435.
Noticed an existing bug in
modload.MainModuleSet.DirImportPath
introduced in https://go.dev/cl/129798 (for #27022).Reproduced the bug as follows:
What did you see happen?
(no error)
What did you expect to see?
An error, because (per the behavior agreed upon in #23970) a package in the module
testdata/q
should not be allowed to import aninternal
module from a module that does not share its import path.Per https://go.dev/cl/129798:
go build testdata/q
confirms that the package inq.go
's directory is not allowed to import that package:The underlying problem is that
DirImportPath
is just checking for a file path prefix, not usingmodload.dirInModule
to properly check that the directory is contained in the module without interveninggo.mod
files carving out module boundaries.(CC @matloob @samthanawalla)
The text was updated successfully, but these errors were encountered: