Add internal debug bundle collaborators
This commit is contained in:
28
internal/framework/debug/recorder_test.go
Normal file
28
internal/framework/debug/recorder_test.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFilesystemRecorderWritesWithinTraceRoot(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
recorder, err := NewFilesystemRecorder(root)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := recorder.WriteBytes("attempt/data", []byte("payload")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
info, err := os.Stat(filepath.Join(root, "attempt", "data"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if info.Mode().Perm() != 0o600 {
|
||||
t.Fatalf("mode=%#o", info.Mode().Perm())
|
||||
}
|
||||
if err := recorder.WriteBytes("../outside", nil); err == nil {
|
||||
t.Fatal("accepted traversal")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user