owasp-string-restricted
To avoid unexpected values being sent or leaked, ensure that strings have either a format
, RegEx pattern
, enum
, or `const
Bad example
openapi: "3.1.0"
info:
version: "1.0"
components:
schemas:
Foo:
type: string
Good Example
openapi: "3.1.0"
info:
version: "1.0"
components:
schemas:
Foo:
type: string
format: email
Another Good Example
openapi: "3.1.0"
info:
version: "1.0"
components:
schemas:
Foo:
type: string
format: hex
pattern: ^[0-9a-fA-F]+$
maxLength: 16
How do I fix this violation?
Ensure that strings have either a format
, RegEx pattern
, enum
, or `const for all string types.