CATS is a REST API Fuzzer and negative testing tool for OpenAPI endpoints. CATS automatically generates, runs and reports tests with minimum configuration and no coding effort. Tests are self-healing and do not require maintenance.
Apache License 2.0
1.2k
stars
73
forks
source link
Very long string is getting generated for "zip" (zip code/pin code) field #105
What is the issue?
If any requestBody schema has "zip" field, the cats is generating very long string for this field. For other string field cats generated correct random strings of 5 - 10 char length.
petstore-country-code.json
In this file Pet is defined as below:
"Pet": { "type": "object", "required": [ "id", "name" ], "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" }, "tag": { "type": "string" }, "zip": { "type": "string" }, "countryCode": { "type": "string", "pattern": "^[A-Z]{2}$" } } },
When we execute HappyPath fuzzer for this file, CATS generates below fuzzed body:
Then from other machine run the cats tool with HappyPathFuzzer
Check the payload in the generated test cases.
Expected behaviour
Small and concise string should be generated for "zip" field
What is the root cause?
In the IPV4Generator.java class, we have below function:
public boolean appliesTo(String format, String propertyName) { return propertyName.toLowerCase().endsWith("ip") || propertyName.toLowerCase().endsWith("ipaddress") || "ip".equalsIgnoreCase(format) || "ipv4".equalsIgnoreCase(format); }
The "zip" propertyName matches here and it generated IPv4 random value for "zip" field.
But the Ipv4 random value generated is seems to be incorrect.
But the very long string for "zip" field is coming from IPv4 generator class
What is the fix?
I have added below fix for this issue. If you find is appropriate then please add it
t.patch
CATS version: 10.3.0
What is the issue? If any requestBody schema has "zip" field, the cats is generating very long string for this field. For other string field cats generated correct random strings of 5 - 10 char length. petstore-country-code.json
In this file Pet is defined as below:
"Pet": { "type": "object", "required": [ "id", "name" ], "properties": { "id": { "type": "integer", "format": "int64" }, "name": { "type": "string" }, "tag": { "type": "string" }, "zip": { "type": "string" }, "countryCode": { "type": "string", "pattern": "^[A-Z]{2}$" } } },
When we execute HappyPath fuzzer for this file, CATS generates below fuzzed body:
To Reproduce Steps to reproduce the behaviour:
Expected behaviour Small and concise string should be generated for "zip" field
What is the root cause?
public boolean appliesTo(String format, String propertyName) { return propertyName.toLowerCase().endsWith("ip") || propertyName.toLowerCase().endsWith("ipaddress") || "ip".equalsIgnoreCase(format) || "ipv4".equalsIgnoreCase(format); }
What is the fix? I have added below fix for this issue. If you find is appropriate then please add it t.patch