diff --git a/README.md b/README.md index 1252fab43..072e91e90 100644 --- a/README.md +++ b/README.md @@ -152,12 +152,12 @@ Web interface is now available at http://localhost:8899 ``` Any request that contains `User-Agent` header with one of the specified values (`kube-probe` or `prometheus`) will not be captured -### API Rules validation +### Traffic validation rules -This feature allows you to define set of simple rules, and test the API against them. +This feature allows you to define set of simple rules, and test the traffic against them. Such validation may test response for specific JSON fields, headers, etc. -Please see [API RULES](docs/POLICY_RULES.md) page for more details and syntax. +Please see [TRAFFIC RULES](docs/POLICY_RULES.md) page for more details and syntax. ## How to Run local UI diff --git a/cli/cmd/tap.go b/cli/cmd/tap.go index 52d4e912d..effc83373 100644 --- a/cli/cmd/tap.go +++ b/cli/cmd/tap.go @@ -67,7 +67,7 @@ func init() { tapCmd.Flags().Bool(configStructs.DisableRedactionTapName, defaultTapConfig.DisableRedaction, "Disables redaction of potentially sensitive request/response headers and body values") tapCmd.Flags().String(configStructs.HumanMaxEntriesDBSizeTapName, defaultTapConfig.HumanMaxEntriesDBSize, "Override the default max entries db size") tapCmd.Flags().Bool(configStructs.DryRunTapName, defaultTapConfig.DryRun, "Preview of all pods matching the regex, without tapping them") - tapCmd.Flags().String(configStructs.EnforcePolicyFile, defaultTapConfig.EnforcePolicyFile, "Yaml file with policy rules") + tapCmd.Flags().String(configStructs.EnforcePolicyFile, defaultTapConfig.EnforcePolicyFile, "Yaml file path with policy rules") tapCmd.Flags().String(configStructs.EnforcePolicyFileDeprecated, defaultTapConfig.EnforcePolicyFileDeprecated, "Yaml file with policy rules") tapCmd.Flags().MarkDeprecated(configStructs.EnforcePolicyFileDeprecated, fmt.Sprintf("Use --%s instead", configStructs.EnforcePolicyFile)) diff --git a/cli/config/configStructs/tapConfig.go b/cli/config/configStructs/tapConfig.go index 729f582f8..861acea01 100644 --- a/cli/config/configStructs/tapConfig.go +++ b/cli/config/configStructs/tapConfig.go @@ -16,7 +16,7 @@ const ( DisableRedactionTapName = "no-redact" HumanMaxEntriesDBSizeTapName = "max-entries-db-size" DryRunTapName = "dry-run" - EnforcePolicyFile = "traffic-validation" + EnforcePolicyFile = "traffic-validation-file" EnforcePolicyFileDeprecated = "test-rules" ) @@ -33,7 +33,7 @@ type TapConfig struct { DisableRedaction bool `yaml:"no-redact" default:"false"` HumanMaxEntriesDBSize string `yaml:"max-entries-db-size" default:"200MB"` DryRun bool `yaml:"dry-run" default:"false"` - EnforcePolicyFile string `yaml:"traffic-validation"` + EnforcePolicyFile string `yaml:"traffic-validation-file"` EnforcePolicyFileDeprecated string `yaml:"test-rules"` ApiServerResources Resources `yaml:"api-server-resources"` TapperResources Resources `yaml:"tapper-resources"` diff --git a/docs/POLICY_RULES.md b/docs/POLICY_RULES.md index 23b3fdc50..fa92d92b4 100644 --- a/docs/POLICY_RULES.md +++ b/docs/POLICY_RULES.md @@ -1,34 +1,31 @@ -# API rules validation +# Traffic validation rules -This feature allows you to define set of simple rules, and test the API against them. +This feature allows you to define set of simple rules, and test the traffic against them. Such validation may test response for specific JSON fields, headers, etc. ## Examples - -Example 1: HTTP request (REST API call) that didn’t pass validation is highlighted in red +Example 1: HTTP request (REST API call) that didn't pass validation is highlighted in red ![Simple UI](../assets/validation-example1.png) - - - - Example 2: Details pane shows the validation rule details and whether it passed or failed ![Simple UI](../assets/validation-example2.png) ## How to use + To use this feature - create simple rules file (see details below) and pass this file as parameter to `mizu tap` command. For example, if rules are stored in file named `rules.yaml` — run the following command: - ```shell -mizu tap --traffic-validation rules.yaml PODNAME +mizu tap --traffic-validation-file rules.yaml ``` - ## Rules file structure The structure of the traffic-validation-file is: @@ -62,6 +59,7 @@ rules: service: "carts.*" ``` + ### Explanation: * First rule `holy-in-name-property`: @@ -74,5 +72,4 @@ rules: * Third rule `latency-test`: - > This rule will be applied to all request made to `carts.*` services. If the latency of the response is greater than `1` will be marked as failure, marked as success otherwise. - + > This rule will be applied to all request made to `carts.*` services. If the latency of the response is greater than `1ms` will be marked as failure, marked as success otherwise.