[TT-16337] prevent use of special characters in policyID#7711
[TT-16337] prevent use of special characters in policyID#7711NurayAhmadova wants to merge 4 commits intomasterfrom
Conversation
|
API Changes --- prev.txt 2026-02-24 17:00:13.013097880 +0000
+++ current.txt 2026-02-24 17:00:02.497004053 +0000
@@ -6833,6 +6833,9 @@
// JWKS holds the configuration for Tyk JWKS functionalities
JWKS JWKSConfig `json:"jwks"`
+
+ // DisableCustomIdValidation disables custom id validation and enables legacy behaviour
+ DisableCustomIdValidation bool `json:"disable_custom_id_validation"`
}
Config is the configuration object used by Tyk to set up various parameters.
@@ -10500,6 +10503,7 @@
StorageConnectionHandler *storage.ConnectionHandler
BundleChecksumVerifier bundleChecksumVerifyFunction
+
// Has unexported fields.
}
@@ -13260,6 +13264,8 @@
func Domain(msg string) Error
+func Domainf(format string, a ...any) Error
+
func Infra(msg string) Error
func New(msg string, opts ...Option) Error
@@ -13271,6 +13277,8 @@
func (e Error) Error() string
+func (e Error) Is(err error) bool
+
func (e Error) TypeOf(typ Type) bool
type Option func(*Error)
@@ -13281,6 +13289,45 @@
// Has unexported fields.
}
+# Package: ./pkg/identifier
+
+package identifier // import "github.com/TykTechnologies/tyk/pkg/identifier"
+
+
+VARIABLES
+
+var (
+ ErrInvalidCustomId = errpack.Domain("Invalid custom ID: Allowed characters: a-z, A-Z, 0-9, ., _, -, ~")
+)
+
+TYPES
+
+type Custom string
+ Custom (user-defined-identifier)
+
+func (c Custom) String() string
+
+func (c Custom) Validate() error
+
+# Package: ./pkg/validator
+
+package validator // import "github.com/TykTechnologies/tyk/pkg/validator"
+
+
+TYPES
+
+type Option func(*validatorCfg)
+
+func WithDisabledPolicyIdValidation(disabled bool) Option
+
+type ValidateFn func(val reflect.Value) error
+
+type Validator interface {
+ Validate(v any) error
+}
+
+func New(opts ...Option) Validator
+
# Package: ./regexp
package regexp // import "github.com/TykTechnologies/tyk/regexp" |
|
This PR introduces a validation mechanism to prevent the use of special characters in policy IDs. A new, reusable validation service is created in the A new configuration flag, Files Changed Analysis
Architecture & Impact Assessment
sequenceDiagram
participant Client
participant Gateway API
participant Validator Service
Client->>Gateway API: POST /tyk/policies (policy with ID)
Gateway API->>Validator Service: Validate(policy.ID)
alt Invalid Policy ID
Validator Service-->>Gateway API: Return error
Gateway API-->>Client: 400 Bad Request
else Valid Policy ID
Validator Service-->>Gateway API: Return success
Gateway API->>Gateway API: Save policy
Gateway API-->>Client: 200 OK
end
Scope Discovery & Context Expansion
Metadata
Powered by Visor from Probelabs Last updated: 2026-02-24T17:02:16.800Z | Triggered by: pr_updated | Commit: 60751d9 💡 TIP: You can chat with Visor using |
Security Issues (1)
Architecture Issues (3)
✅ Performance Check PassedNo performance issues found – changes LGTM. Quality Issues (3)
Powered by Visor from Probelabs Last updated: 2026-02-24T17:02:19.938Z | Triggered by: pr_updated | Commit: 60751d9 💡 TIP: You can chat with Visor using |
deee8a5 to
8eeb795
Compare
3227372 to
9e6e18a
Compare
5cf4036 to
60751d9
Compare
|



Description
Related Issue
Motivation and Context
How This Has Been Tested
Screenshots (if appropriate)
Types of changes
Checklist
Ticket Details
TT-16337
Generated at: 2026-02-24 16:59:44