fix(region): waf rule create (#22737)

This commit is contained in:
屈轩
2025-06-18 20:06:00 +08:00
committed by GitHub
parent b931b70911
commit 93466228d5
5 changed files with 8 additions and 10 deletions

View File

@@ -41,6 +41,8 @@ type WafRuleListInput struct {
// WAF规则组Id
WafRuleGroupId string `json:"waf_rule_group_id"`
Type string `json:"type"`
}
type WafRuleCreateInput struct {

View File

@@ -60,7 +60,7 @@ type SWafRule struct {
db.SExternalizedResourceBase
// 规则优先级
Priority int `nullable:"false" list:"domain" create:"required"`
Priority int `nullable:"false" default:"0" list:"domain" create:"optional"`
// 规则默认行为
Action *cloudprovider.DefaultAction `charset:"utf8" nullable:"true" list:"user" update:"domain" create:"required"`
// 条件
@@ -213,6 +213,10 @@ func (manager *SWafRuleManager) ListItemFilter(
return nil, errors.Wrap(err, "SExternalizedResourceBaseManager.ListItemFilter")
}
if len(query.Type) > 0 {
q = q.Equals("type", query.Type)
}
if len(query.WafInstanceId) > 0 {
_, err := validators.ValidateModel(ctx, userCred, WafInstanceManager, &query.WafInstanceId)
if err != nil {

View File

@@ -394,10 +394,6 @@ func (self *SAwsRegionDriver) ValidateCreateWafInstanceData(ctx context.Context,
return input, nil
}
func (self *SAwsRegionDriver) ValidateCreateWafRuleData(ctx context.Context, userCred mcclient.TokenCredential, waf *models.SWafInstance, input api.WafRuleCreateInput) (api.WafRuleCreateInput, error) {
return input, nil
}
func (self *SAwsRegionDriver) ValidateCreateSecurityGroupInput(ctx context.Context, userCred mcclient.TokenCredential, input *api.SSecgroupCreateInput) (*api.SSecgroupCreateInput, error) {
for i := range input.Rules {
if input.Rules[i].Action != string(secrules.SecurityRuleAllow) {

View File

@@ -76,10 +76,6 @@ func (self *SAzureRegionDriver) ValidateCreateWafInstanceData(ctx context.Contex
return input, nil
}
func (self *SAzureRegionDriver) ValidateCreateWafRuleData(ctx context.Context, userCred mcclient.TokenCredential, waf *models.SWafInstance, input api.WafRuleCreateInput) (api.WafRuleCreateInput, error) {
return input, nil
}
func (self *SAzureRegionDriver) ValidateCreateSecurityGroupInput(ctx context.Context, userCred mcclient.TokenCredential, input *api.SSecgroupCreateInput) (*api.SSecgroupCreateInput, error) {
for i := range input.Rules {
rule := input.Rules[i]

View File

@@ -403,7 +403,7 @@ func (self *SBaseRegionDriver) ValidateCreateWafInstanceData(ctx context.Context
}
func (self *SBaseRegionDriver) ValidateCreateWafRuleData(ctx context.Context, userCred mcclient.TokenCredential, waf *models.SWafInstance, input api.WafRuleCreateInput) (api.WafRuleCreateInput, error) {
return input, errors.Wrapf(cloudprovider.ErrNotImplemented, "ValidateCreateWafRuleData")
return input, nil
}
func (self *SBaseRegionDriver) RequestCreateNetwork(ctx context.Context, userCred mcclient.TokenCredential, net *models.SNetwork, task taskman.ITask) error {