Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange values instead of Payloads #98

Closed
nrathaus opened this issue May 6, 2024 · 2 comments
Closed

Strange values instead of Payloads #98

nrathaus opened this issue May 6, 2024 · 2 comments
Assignees
Labels
bug-fix PR raised for fixing bug

Comments

@nrathaus
Copy link
Contributor

nrathaus commented May 6, 2024

I believe an issue with many of the false negative I am seeing:

def fill_params(params: list[dict], is_v3: bool) -> list[dict]:
    """fills params for OAS/swagger specs"""
    schema_params = []
    for index in range(len(params)):
        param_type = (
            params[index].get("schema", {}).get("type")
            if is_v3
            else params[index].get("type")
        )
        param_is_required = params[index].get("required")
        param_in = params[index].get("in")
        param_name = params[index].get("name", "")

        param_value = fuzz_type_value(param_type=param_type, param_name=param_name)

        if params[index].get("schema"):
            schema_type = params[index].get("schema", {}).get("type")
            if schema_type == "object":
                schema_obj = params[index].get("schema", {}).get("properties", {})
                filled_schema_params = fill_schema_params(
                    schema_obj, param_in, param_is_required
                )
            else:
                filled_schema_params = [
                    {
                        "in": param_in,
                        "name": param_name,
                        "required": param_is_required,
                        "value": param_value,
                    }
                ]

            schema_params.append(filled_schema_params)
        else:
            params[index]["value"] = param_value

This code does:

  1. Incorrectly store the string attribute - causing feature calls to the params to not see it as a string
  2. Overwrites the default value instead for example using the example field if it exists

I don't quite understand if this overwriting is intentional or not

Further the code could be easily written as:
for index, _ in enumerate(params):

Instead of:
for index in range(len(params)):

I believe the minimal fix to get it working would be to, change this:

                filled_schema_params = [
                    {
                        "in": param_in,
                        "name": param_name,
                        "required": param_is_required,
                        "value": param_value,
                    }
                ]

To this:

                filled_schema_params = [
                    {
                        "in": param_in,
                        "name": param_name,
                        "required": param_is_required,
                        "value": param_value,
                        "type": param_type
                    }
                ]
@nrathaus
Copy link
Contributor Author

nrathaus commented May 6, 2024

#99

@dmdhrumilmistry dmdhrumilmistry added the bug-fix PR raised for fixing bug label May 12, 2024
@dmdhrumilmistry
Copy link
Collaborator

respective PR has been merged and It should reduce no. of false positives as mentioned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-fix PR raised for fixing bug
Projects
None yet
Development

No branches or pull requests

2 participants