File Operation
To prevent directory traversal and access to sensitive files, use the wrapper functions provided by Waffle.
When using os
If you are using the os
package to perform file operations, replace it with the waffle-go/contrib/os
package.
import (
...
"os"
waffleOs "github.com/sitebatch/waffle-go/contrib/os"
...
)
func someReadFileFunc() {
// insted of os.ReadFile
// ctx MUST be a context propagated from Waffle HTTP server middleware such as WafMiddleware
waffleOs.ProtectReadFile(ctx, path)
}
More information can be found in the contrib/os
.