Harden Harness runtime, persistence and execution for Hand
This commit is contained in:
1 parent
09c30fe2d5
commit
0972eed3ea
164 files changed
+15912
-506
No files matched your search
@@ -0,0 +1,30 @@
|
||||
package tool
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestCreationPathResolvesExistingAncestors(t *testing.T) {
|
||||
work, outside := t.TempDir(), t.TempDir()
|
||||
alias := filepath.Join(t.TempDir(), "workspace-link")
|
||||
if err := os.Symlink(work, alias); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := ValidatePathInWorkDir(filepath.Join(alias, "new/deep/file"), alias); err != nil {
|
||||
t.Fatal("safe missing parents rejected", err)
|
||||
}
|
||||
if err := os.Symlink(outside, filepath.Join(work, "escape")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := ValidatePathInWorkDir(filepath.Join(work, "escape/new/deep/file"), work); err == nil {
|
||||
t.Fatal("missing parents hid outside ancestor")
|
||||
}
|
||||
if err := os.Symlink(filepath.Join(outside, "missing"), filepath.Join(work, "dangling")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := ValidatePathInWorkDir(filepath.Join(work, "dangling/new/file"), work); err == nil {
|
||||
t.Fatal("dangling symlink accepted")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user