Skip to content

Commit 91a57ed

Browse files
committed
more tests
1 parent 3063818 commit 91a57ed

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

libs/python/interpreters.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func DetectInterpreters(ctx context.Context) (allInterpreters, error) {
7777
// help here.
7878
//
7979
// See https://github.com/databricks/cli/pull/805#issuecomment-1735403952
80+
log.Debugf(ctx, "%s is world-writeable (%s), skipping for security reasons", prefix, perm)
8081
continue
8182
}
8283
entries, err := os.ReadDir(prefix)

libs/python/interpreters_test.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package python
33
import (
44
"context"
55
"os"
6+
"path/filepath"
67
"testing"
78

89
"github.com/stretchr/testify/assert"
@@ -27,7 +28,19 @@ func TestNoInterpretersFound(t *testing.T) {
2728
}
2829

2930
func TestFilteringInterpreters(t *testing.T) {
30-
t.Setenv("PATH", "testdata/other-binaries-filtered"+string(os.PathListSeparator)+"testdata/world-writeable")
31+
rogueBin := filepath.Join(t.TempDir(), "rogue-bin")
32+
err := os.Mkdir(rogueBin, 0o777)
33+
assert.NoError(t, err)
34+
os.Chmod(rogueBin, 0o777)
35+
36+
raw, err := os.ReadFile("testdata/world-writeable/python8.4")
37+
assert.NoError(t, err)
38+
39+
binary := filepath.Join(rogueBin, "python8.4")
40+
err = os.WriteFile(binary, raw, 00777)
41+
assert.NoError(t, err)
42+
43+
t.Setenv("PATH", "testdata/other-binaries-filtered"+string(os.PathListSeparator)+rogueBin)
3144

3245
ctx := context.Background()
3346
all, err := DetectInterpreters(ctx)

0 commit comments

Comments
 (0)