mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-10 23:10:32 +00:00
This reverts commit c4afeee5b3
.
This commit is contained in:
@@ -3,7 +3,6 @@ package rules
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"mizuserver/pkg/models"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
@@ -93,35 +92,19 @@ func MatchRequestPolicy(harEntry har.Entry, service string) (int, []RulesMatched
|
||||
return len(enforcePolicy.Rules), resultPolicyToSend
|
||||
}
|
||||
|
||||
func PassedValidationRules(rulesMatched []RulesMatched) models.ApplicableRules {
|
||||
func PassedValidationRules(rulesMatched []RulesMatched, numberOfRules int) (bool, int64, int) {
|
||||
if len(rulesMatched) == 0 {
|
||||
return models.ApplicableRules{
|
||||
Status: false,
|
||||
Latency: 0,
|
||||
NumberOfRules: 0,
|
||||
}
|
||||
return false, 0, 0
|
||||
}
|
||||
for _, rule := range rulesMatched {
|
||||
if rule.Matched == false {
|
||||
return models.ApplicableRules{
|
||||
Status: false,
|
||||
Latency: -1,
|
||||
NumberOfRules: len(rulesMatched),
|
||||
}
|
||||
return false, -1, len(rulesMatched)
|
||||
}
|
||||
}
|
||||
for _, rule := range rulesMatched {
|
||||
if strings.ToLower(rule.Rule.Type) == "latency" {
|
||||
return models.ApplicableRules{
|
||||
Status: true,
|
||||
Latency: rule.Rule.Latency,
|
||||
NumberOfRules: len(rulesMatched),
|
||||
}
|
||||
return true, rule.Rule.Latency, len(rulesMatched)
|
||||
}
|
||||
}
|
||||
return models.ApplicableRules{
|
||||
Status: true,
|
||||
Latency: -1,
|
||||
NumberOfRules: len(rulesMatched),
|
||||
}
|
||||
return true, -1, len(rulesMatched)
|
||||
}
|
||||
|
Reference in New Issue
Block a user