afero icon indicating copy to clipboard operation
afero copied to clipboard

MemMapFs not checking for permissions

Open staticdev opened this issue 3 years ago • 0 comments

How to reproduce:

package main

import (
	"log"

	"github.com/spf13/afero"
)

func main() {
	folderName := "secret"
	fsys := afero.NewMemMapFs()
	fsys.Mkdir(folderName, 0700)
	afero.WriteFile(fsys, "secret/filename", []byte(""), 0700)

	_, err := fsys.Stat("secret/filename")
	if err != nil {
		log.Fatal(err)
	}
	fsys.Chmod("secret", 0000)
	_, err = fsys.Stat("secret/filename")
	if err != nil {
		log.Fatal(err)
	}
}

If you do the same with NewOsFs() instead of NewMemMapFs() you get the error on second Stat (which is the intended behavior since the secret folder has no read permissions).

May be related to https://github.com/spf13/afero/issues/327

staticdev avatar Jan 30 '22 10:01 staticdev