Skip to content

Conditional expression returns the same value whether the condition is "true" or "false" #4269

@agigleux

Description

@agigleux

Hello,

I scan the code with SonarCloud and found 3 interesting bugs reported.
There is a conditional expression that is copy/pasted 3 times that is always returning the value of conf.method whatever the results of the conditional expression:

(conf.method if conf.method != HTTPMETHOD.GET else conf.method)

The files impacted here:

image

Example on lib/controller/controller.py:

image

One can look at the results directly here: https://sonarcloud.io/project/issues?id=agigleux_sqlmap&languages=py&open=AXNWC5usfcjDL5qbLEcX&resolved=false&rules=python%3AS3923&severities=MAJOR&types=BUG

If I understand well the code, I believe the expression:

((conf.method if conf.method != HTTPMETHOD.GET else conf.method) or HTTPMETHOD.POST)

could be simplified to:

((HTTPMETHOD.POST if conf.method is None else conf.method))

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions