refactor: use jsmod.Get for context configuration (by AI)
This commit is contained in:
parent
ba95b78adb
commit
a97e1f50bf
4
file.go
4
file.go
@ -308,9 +308,9 @@ func VerifyPathForSafeMode(ctx context.Context, path string) (string, error) {
|
|||||||
return RealPath(path), nil
|
return RealPath(path), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. 获取白名单 (约定从 ctx 获取 "AllowedDirs")
|
// 1. 获取白名单
|
||||||
var allowedDirs []string
|
var allowedDirs []string
|
||||||
cast.Convert(&allowedDirs, ctx.Value("AllowedDirs"))
|
cast.Convert(&allowedDirs, jsmod.Get(ctx, "AllowedDirs"))
|
||||||
if len(allowedDirs) == 0 {
|
if len(allowedDirs) == 0 {
|
||||||
return "", fmt.Errorf("file: access denied, AllowedDirs not found in context")
|
return "", fmt.Errorf("file: access denied, AllowedDirs not found in context")
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user