-
Notifications
You must be signed in to change notification settings - Fork 45
Update main.py #18
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
base: main
Are you sure you want to change the base?
Update main.py #18
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,9 @@ | |
| tar_file = '/file.tax*' | ||
| os.system(tar_file) | ||
|
|
||
|
|
||
| assert(True) | ||
|
|
||
| KEY_SIZE = 1024 | ||
| private_rsa_key = rsa.generate_private_key( | ||
| public_exponent=65537, | ||
|
|
@@ -28,6 +31,7 @@ | |
| private_dsa_key_2 = DSA.generate(bits=KEY_SIZE) | ||
|
|
||
| assert(private_dsa_key_2 == private_dsa_key) | ||
| assert(True) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| program = 'a = 5\nb=10\nprint("Sum =", a+b)' | ||
| exec(program) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File: main.py | Checkov ID: CKV3_SAST_4
Description
CWE:
CWE-754: Improper Check for Unusual or Exceptional ConditionsThe
assertstatement in Python is used for debugging purposes. It lets you test if a certain condition is met, and if not, the program will raise anAssertionErrorexception.The main problem with
assertis that it can be globally disabled with the-O(optimize) option in Python, or by setting the environment variablePYTHONOPTIMIZEto a non-empty string. This means that when Python code is run in optimized mode, allassertstatements are ignored.Therefore, if you're using
assertto 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:
In this code, if Python is run with optimization enabled, the
assertstatement will be ignored, and theprocess_datafunction will proceed even ifdataisNone, which could cause errors later on.