b8788c239e
MCP Docker / build-and-push (push) Has been cancelled
- Remove telemetry: disabled all phone-home (installation notify, false positives, behavior tracking, upgrade tips) - Version branding: removed 'ce-' prefix, product name changed to '长亭雷池 WAF' - Detection engine enhancement: strict preset enables all 17 modules with aggressive configs - Multi-user RBAC: admin/operator/viewer roles with password + TOTP 2FA - Rate limiting: nginx limit_req per website (RPS, burst, action) - JS Challenge: browser fingerprint verification page with cookie-based bypass - Security fixes: removed InsecureSkipVerify, hardcoded credentials, NO_AUTH backdoor
36 lines
830 B
Go
36 lines
830 B
Go
package rule
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/chaitin/SafeLine/mcp_server/internal/api"
|
|
"github.com/chaitin/SafeLine/mcp_server/pkg/errors"
|
|
)
|
|
|
|
type CreateRuleRequest struct {
|
|
Name string `json:"name"`
|
|
IP []string `json:"ip"`
|
|
IsEnabled bool `json:"is_enabled"`
|
|
Pattern [][]api.Pattern `json:"pattern"`
|
|
Action int `json:"action"`
|
|
}
|
|
|
|
// CreateRule Create new rule
|
|
func CreateRule(ctx context.Context, req *CreateRuleRequest) (int64, error) {
|
|
if req == nil {
|
|
return 0, errors.New("request is required")
|
|
}
|
|
|
|
var resp api.Response[int64]
|
|
err := api.Service().Post(ctx, "/api/open/policy", req, &resp)
|
|
if err != nil {
|
|
return 0, errors.Wrap(err, "failed to create policy rule")
|
|
}
|
|
|
|
if resp.Err != nil {
|
|
return 0, errors.New(resp.Msg)
|
|
}
|
|
|
|
return resp.Data, nil
|
|
}
|