限制Linux管理服务回环监听并补齐安全回归
This commit is contained in:
1 parent
0b74886c45
commit
1150c3904e
13 files changed
+233
-4
No files matched your search
@@ -40,6 +40,9 @@ func Run(ctx context.Context, options ServerOptions) (bool, error) {
|
||||
if options.Config.SetupReady {
|
||||
return false, errors.New("已经初始化,不能启动临时初始化服务")
|
||||
}
|
||||
if err := options.Config.ValidateServerListener(); err != nil {
|
||||
return false, err
|
||||
}
|
||||
firewallManager, err := firewall.NewManagerWithMode(options.FirewallMode)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package bootstrap
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"git.pcux.cn/xuans/Scert/backend/internal/config"
|
||||
)
|
||||
|
||||
func TestRunRejectsNonLoopbackBeforeInitialization(t *testing.T) {
|
||||
cfg := config.Default(t.TempDir())
|
||||
cfg.Server.Host = "0.0.0.0"
|
||||
completed, err := Run(context.Background(), ServerOptions{Config: cfg})
|
||||
if completed || err == nil || !strings.Contains(err.Error(), "只允许监听回环") {
|
||||
t.Fatalf("初始化入口未在创建资源前拒绝非回环监听:%v", err)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user