Skip to content

testing changed for python#26

Open
sa-ny wants to merge 1 commit into
mainfrom
sa-ny-patch-15
Open

testing changed for python#26
sa-ny wants to merge 1 commit into
mainfrom
sa-ny-patch-15

Conversation

@sa-ny
Copy link
Copy Markdown
Owner

@sa-ny sa-ny commented Sep 24, 2024

No description provided.

@github-actions
Copy link
Copy Markdown

Caution

Breaking Flaws identified in code!

Fixes for application/views/resetController.py:
Falws found for this file:
CWE 295 - Improper Certificate Validation - Severity 3 on line 63 for issue 1004
CWE 331 - Insufficient Entropy - Severity 3 on line 147 for issue 1008
CWE 331 - Insufficient Entropy - Severity 3 on line 159 for issue 1011
CWE 331 - Insufficient Entropy - Severity 3 on line 111 for issue 1006
CWE 331 - Insufficient Entropy - Severity 3 on line 151 for issue 1009
CWE 331 - Insufficient Entropy - Severity 3 on line 128 for issue 1007
CWE 331 - Insufficient Entropy - Severity 3 on line 155 for issue 1010

Fix suggestions:

--- application/views/resetController.py
+++ application/views/resetController.py
@@ -60,7 +60,7 @@
     elif(request.method == "POST"):
         return processReset(request)
     else:
-        h = httplib2.Http(".cache", disable_ssl_certificate_validation=True) #CWE-295
+        h = httplib2.Http(".cache", verify_ssl=True) #CWE-295
         h.add_credentials('thiswaskevinsidea','hardcode') #CWE-798
         data=h.request("http://localhost/",method='GET')
         return data
@@ -109,6 +109,7 @@
                 for blabber in users[2:]:
                     for listener in users[2:]:
                         if rand.choice([False, True]) and (blabber != listener):
+                            rand = random.SystemRandom()
                             
 
                             logger.info("Adding " + listener.username + " as a listener of " + blabber.username)
@@ -125,7 +126,8 @@
                 blabsStatement = "INSERT INTO blabs (blabber, content, timestamp) values (%s, %s, datetime('now'));"
                 for blabContent in blabsContent:
                     # Get the array offset for a random user
-                    randomUserOffset = rand.randint(2,len(users) - 1)
+                    rand = random.SystemRandom()
+                    randomUserOffset = rand.randint(2, len(users) - 1)
 
                     # get the number or seconds until some time in the last 30 days.
                     #vary = rand.randint(0,(30 * 24 * 3600)+1)
@@ -144,19 +146,20 @@
                 commentsStatement = "INSERT INTO comments (blabid, blabber, content, timestamp) values (%s, %s, %s, datetime('now'));"
                 for i in range(len(blabsContent)):
                     # Add a random number of comment
-                    count = rand.randint(0,5) # between 0 and 6
+                    rand = random.SystemRandom()
+                    count = rand.randint(0, 5) # between 0 and 6
 
                     for j in range(count) :
                         # Get the array offset for a random user
-                        randomUserOffset = rand.randint(2,len(users)-1) #removed +1 cause no admin,  removed -2 because no admin and inclusive.
+                        randomUserOffset = rand.SystemRandom().randint(2, len(users)-1) #removed +1 cause no admin,  removed -2 because no admin and inclusive.
                         username = users[randomUserOffset].username
 
                         # Pick a random comment to add
-                        commentNum = rand.randint(0,len(commentsContent)-1)
+                        commentNum = rand.SystemRandom().randint(0, len(commentsContent)-1)
                         comment = commentsContent[commentNum]
 
                         # get the number or seconds until some time in the last 30 days.
-                        vary = rand.randint(0,(30 * 24 * 3600)+1)
+                        vary = rand.SystemRandom().randint(0, (30 * 24 * 3600)+1)
 
                         logger.info("Adding a comment from " + username + " on blab ID " + str(i))
 

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