-
Notifications
You must be signed in to change notification settings - Fork 0
Update app.py #2
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: master
Are you sure you want to change the base?
Conversation
| memeater[randrange(10000)] = bytearray(1024 * 1024 * 100 * memstressfactor, encoding='utf8') # eats 100MB * memstressfactor | ||
| print("You invoked the getheavyvotes API. I am eating some cpu * " + str(cpustressfactor) + " at every votes request") | ||
| processes = cpu_count() | ||
| pool = Pool(processes) |
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.
Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.
Problem
This line of code might contain a resource leak. Resource leaks can cause your system to slow down or crash.
Fix
Consider closing the following resource: pool. The resource is allocated by call multiprocessing.Pool. Execution paths that do not contain closure statements were detected. To prevent this resource leak, close pool in a try-finally block or declare it using a with statement.
More info
View details about the with statement in the Python developer's guide (external link).
| return string_votes | ||
| if __name__ == '__main__': | ||
| app.run(host=os.getenv('IP', '0.0.0.0'), port=int(os.getenv('PORT', 8080))) |
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.
Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.
The rule flags the use of host 0.0.0.0 in application configuration, which exposes the server to all network interfaces, potentially including public networks. This configuration poses a security risk by making the application accessible to unauthorized users on the internet. To remediate this issue, bind your application to localhost 127.0.0.1 during development or use a specific, secure IP address in production environments with proper firewall rules and authentication mechanisms.Learn more
| if __name__ == '__main__': | ||
| app.run(host=os.getenv('IP', '0.0.0.0'), port=int(os.getenv('PORT', 8080))) | ||
| app.debug =True |
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.
Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.
Enabling an application's debug or test feature makes it easier for developers to find bugs, but it also gives attackers access to detailed information about both the system running the application and users. To make your code secure, do not enable the debug or test feature on production servers. For more information, see CWE-489.
| x*x | ||
| def readvote(restaurant): | ||
| response = ddbtable.get_item(Key={'name': restaurant}) |
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.
Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.
Potential NoSQL Injection detected. Untrusted input is being used in a NoSQL database
operation without proper sanitization. NoSQL databases like MongoDB and DynamoDB are not
immune to injection attacks. User input should never be directly interpolated into query
objects or strings. Instead, use parameterized queries, proper sanitization techniques,
or type conversion specific to the NoSQL database you're using. For MongoDB, consider using
ObjectId() for IDs and validated operators. For DynamoDB, use boto3.dynamodb.conditions
classes for safe query construction. Learn more - https://cwe.mitre.org/data/definitions/943.html
| return str(votes) | ||
| def updatevote(restaurant, votes): | ||
| ddbtable.update_item( |
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.
Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.
Potential NoSQL Injection detected. Untrusted input is being used in a NoSQL database
operation without proper sanitization. NoSQL databases like MongoDB and DynamoDB are not
immune to injection attacks. User input should never be directly interpolated into query
objects or strings. Instead, use parameterized queries, proper sanitization techniques,
or type conversion specific to the NoSQL database you're using. For MongoDB, consider using
ObjectId() for IDs and validated operators. For DynamoDB, use boto3.dynamodb.conditions
classes for safe query construction. Learn more - https://cwe.mitre.org/data/definitions/943.html
| memeater[randrange(10000)] = bytearray(1024 * 1024 * 100 * memstressfactor, encoding='utf8') # eats 100MB * memstressfactor | ||
| print("You invoked the getheavyvotes API. I am eating some cpu * " + str(cpustressfactor) + " at every votes request") | ||
| processes = cpu_count() | ||
| pool = Pool(processes) |
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.
Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.
Problem
This line of code might contain a resource leak. Resource leaks can cause your system to slow down or crash.
Fix
Consider closing the following resource: pool. The resource is allocated by call multiprocessing.Pool. Execution paths that do not contain closure statements were detected. To prevent this resource leak, close pool in a try-finally block or declare it using a with statement.
More info
View details about the with statement in the Python developer's guide (external link).
| return string_votes | ||
| if __name__ == '__main__': | ||
| app.run(host=os.getenv('IP', '0.0.0.0'), port=int(os.getenv('PORT', 8080))) |
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.
Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.
The rule flags the use of host 0.0.0.0 in application configuration, which exposes the server to all network interfaces, potentially including public networks. This configuration poses a security risk by making the application accessible to unauthorized users on the internet. To remediate this issue, bind your application to localhost 127.0.0.1 during development or use a specific, secure IP address in production environments with proper firewall rules and authentication mechanisms.Learn more
| if __name__ == '__main__': | ||
| app.run(host=os.getenv('IP', '0.0.0.0'), port=int(os.getenv('PORT', 8080))) | ||
| app.debug =True |
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.
Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.
Enabling an application's debug or test feature makes it easier for developers to find bugs, but it also gives attackers access to detailed information about both the system running the application and users. To make your code secure, do not enable the debug or test feature on production servers. For more information, see CWE-489.
| x*x | ||
| def readvote(restaurant): | ||
| response = ddbtable.get_item(Key={'name': restaurant}) |
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.
Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.
Potential NoSQL Injection detected. Untrusted input is being used in a NoSQL database
operation without proper sanitization. NoSQL databases like MongoDB and DynamoDB are not
immune to injection attacks. User input should never be directly interpolated into query
objects or strings. Instead, use parameterized queries, proper sanitization techniques,
or type conversion specific to the NoSQL database you're using. For MongoDB, consider using
ObjectId() for IDs and validated operators. For DynamoDB, use boto3.dynamodb.conditions
classes for safe query construction. Learn more - https://cwe.mitre.org/data/definitions/943.html
| return str(votes) | ||
| def updatevote(restaurant, votes): | ||
| ddbtable.update_item( |
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.
Recommendation generated by Amazon CodeGuru Reviewer. Leave feedback on this recommendation by replying to the comment or by reacting to the comment using emoji.
Potential NoSQL Injection detected. Untrusted input is being used in a NoSQL database
operation without proper sanitization. NoSQL databases like MongoDB and DynamoDB are not
immune to injection attacks. User input should never be directly interpolated into query
objects or strings. Instead, use parameterized queries, proper sanitization techniques,
or type conversion specific to the NoSQL database you're using. For MongoDB, consider using
ObjectId() for IDs and validated operators. For DynamoDB, use boto3.dynamodb.conditions
classes for safe query construction. Learn more - https://cwe.mitre.org/data/definitions/943.html
No description provided.