Explorar o código

Stop ADD from following symlinks outside the context when passed as the first argument

Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)

Docker-DCO-1.1-Signed-off-by: Tianon Gravi <admwiggin@gmail.com> (github: crosbymichael)
Tianon Gravi %!s(int64=11) %!d(string=hai) anos
pai
achega
ad69836247
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  1. 5 0
      buildfile.go

+ 5 - 0
buildfile.go

@@ -287,6 +287,11 @@ func (b *buildFile) CmdVolume(args string) error {
 
 func (b *buildFile) checkPathForAddition(orig string) error {
 	origPath := path.Join(b.contextPath, orig)
+	if p, err := filepath.EvalSymlinks(origPath); err != nil {
+		return err
+	} else {
+		origPath = p
+	}
 	if !strings.HasPrefix(origPath, b.contextPath) {
 		return fmt.Errorf("Forbidden path outside the build context: %s (%s)", orig, origPath)
 	}