From 5487e30969af9b758b8f79fa7c25f891bc4c43a9 Mon Sep 17 00:00:00 2001 From: Virendra Bhalothia Date: Wed, 22 May 2024 11:39:33 +0200 Subject: [PATCH 1/3] feat(py): adding a sample python file --- main.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..ef005ec --- /dev/null +++ b/main.py @@ -0,0 +1,2 @@ +if __name__ == '__main__': + print('Hello, World!') From 9310a907fb781d8580b94d2ca1c0c111b4924cad Mon Sep 17 00:00:00 2001 From: Virendra Bhalothia Date: Wed, 22 May 2024 11:48:59 +0200 Subject: [PATCH 2/3] fix: new method to caculate area --- main.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/main.py b/main.py index ef005ec..8fc2677 100644 --- a/main.py +++ b/main.py @@ -1,2 +1,21 @@ if __name__ == '__main__': print('Hello, World!') + +def calculate_AREA(information): # Mixed case for function name + """ + 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[ZERO_INDEX] # Using constant instead of variable name + # Descriptive but misspelled variable name + breadth = information[ONE_INDEX] # Using constant instead of variable name + + # Calculation using inconsistent variable naming + rectangleArea = length * breadth + return rectangleArea From 963974fc8fc20ab1dc6ba26a5d4beff3c8e36a4a Mon Sep 17 00:00:00 2001 From: Virendra Bhalothia Date: Wed, 22 May 2024 11:54:41 +0200 Subject: [PATCH 3/3] fix(user-input): updating use rinput --- main.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 8fc2677..3412961 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,15 @@ if __name__ == '__main__': - print('Hello, World!') + # User input without validation (potential for code injection) + user_input = input("Enter rectangle dimensions separated by a comma (length,width): ") + dimensions = user_input.split(",") -def calculate_AREA(information): # Mixed case for function name + 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. @@ -12,9 +20,13 @@ def calculate_AREA(information): # Mixed case for function name float: The calculated area of the rectangle. """ # Abbreviated variable name - length = information[ZERO_INDEX] # Using constant instead of variable name - # Descriptive but misspelled variable name - breadth = information[ONE_INDEX] # Using constant instead of 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