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

Update flask.py #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Update flask.py #17

wants to merge 2 commits into from

Conversation

arielkru
Copy link
Owner

No description provided.

Copy link

@bridgecrew-dev bridgecrew-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bridgecrew has found errors in this PR ⬇️

@@ -11,6 +11,7 @@ def test_sources_7(something):
# comment
return "foo"
# comment
assert(True)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MEDIUM  Improper handling of checking for unusual or exceptional conditions
    File: flask.py | Checkov ID: CKV3_SAST_4

Description

CWE: CWE-754: Improper Check for Unusual or Exceptional Conditions

The assert statement in Python is used for debugging purposes. It lets you test if a certain condition is met, and if not, the program will raise an AssertionError exception.

The main problem with assert is that it can be globally disabled with the -O (optimize) option in Python, or by setting the environment variable PYTHONOPTIMIZE to a non-empty string. This means that when Python code is run in optimized mode, all assert statements are ignored.

Therefore, if you're using assert to check for conditions that should prevent the program from continuing (for example, validating user input or checking configuration files), those checks will be skipped in optimized mode, which could lead to incorrect program behavior or even security vulnerabilities.

Here is an example of problematic code:

def process_data(data):
    assert data is not None, "Data must not be None"
    # Continue with processing...

In this code, if Python is run with optimization enabled, the assert statement will be ignored, and the process_data function will proceed even if data is None, which could cause errors later on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant