Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
if __name__ == '__main__':
# User input without validation (potential for code injection)
user_input = input("Enter rectangle dimensions separated by a comma (length,width): ")
dimensions = user_input.split(",")

try:
# Unvalidated user input used in calculation (potential for type conversion errors)
print(calculate_AREA(dimensions))
except: # Broad exception handling (hides potential security issues)
pass

def calculate_AREA(information):
"""
This function calculates the area of a rectangle, but variable names are inconsistent.

Args:
information (list): A list containing rectangle dimensions (length and width).

Returns:
float: The calculated area of the rectangle.
"""
# Abbreviated variable name
length = information[0] # Using index directly (less secure than constants)

# Unsafe user input evaluation (potential for code injection)
try:
breadth = eval(information[1]) # Evaluates user input as Python code
except:
breadth = 0 # Insecure default value (might bypass security checks)

# Calculation using inconsistent variable naming
rectangleArea = length * breadth
return rectangleArea
Comment on lines +32 to +33
Copy link

Choose a reason for hiding this comment

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

Consider using more consistent and conventional variable names.

-  rectangleArea = length * breadth
+  area = length * breadth

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
rectangleArea = length * breadth
return rectangleArea
area = length * breadth
return area