Skip to content

pySCG: Modifying the description of CWE-197 so that it captures the CWE better #635

Open
@openrefactorymunawar

Description

@openrefactorymunawar

CWE-197 is about numeric truncation error (https://cwe.mitre.org/data/definitions/197.html).

The description of CWE-197 in the python secure coding guide section talks about predictable outcomes in loops by using int instead of float.

That is fine, we may want to narrow the scope of the CWE when we are creating a guideline. However, the examples that follow are not necessarily about loops.

Consider this example.

""" Non-compliant Code Example """
counter = 0.0
while counter <= 1.0:
    if counter == 0.8:
        print("we reached 0.8")  
        break  # never going to reach this
    counter += 0.1

Here the problem is in the if statement, not the loop.

In fact, the float issue may be in any equality case, even if it is not in a loop.

We need to update this description to either align more with numeric truncation (generalize the content) or keep the scope and make it more appropriate.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions