- 48 个 Go 文件所有注释(行注释/块注释/行尾注释,含 _test.go)翻译为中文 - 保留技术标识符:SECURITY_TODO(n)、unsafe-inline、sqlite/mysql、路由参数等 - 代码、字符串字面量、日志消息保持英文原文,零逻辑改动 - go build/vet 通过,go test -count=1 ./... 全绿
23 lines
526 B
Go
23 lines
526 B
Go
package config
|
||
|
||
import (
|
||
"os"
|
||
"path/filepath"
|
||
"testing"
|
||
)
|
||
|
||
// TestConfigFileCreatedNotWorldReadable 覆盖 SECURITY_TODO #11:
|
||
// 配置文件(内嵌会话密钥)不得被组/其他用户读取。
|
||
func TestConfigFileCreatedNotWorldReadable(t *testing.T) {
|
||
path := filepath.Join(t.TempDir(), "config.yaml")
|
||
LoadConfig(path)
|
||
|
||
st, err := os.Stat(path)
|
||
if err != nil {
|
||
t.Fatalf("config file not created: %v", err)
|
||
}
|
||
if perm := st.Mode().Perm(); perm != 0640 {
|
||
t.Fatalf("config perms = %v, want 0640", perm)
|
||
}
|
||
}
|