Skip to content
Draft
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
14 changes: 8 additions & 6 deletions addRepositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import json
import time

def listRepositoriesfromGithub(orgname,githubToken,githubBaseURL):
def listRepositoriesfromGithub(orgname, githubToken, githubBaseURL):
page = 1
listRepos = []
repositories = []
hasNextPage = True
headers = {
'Accept': 'application/vnd.github+json',
Expand All @@ -15,14 +15,16 @@ def listRepositoriesfromGithub(orgname,githubToken,githubBaseURL):
while(hasNextPage):
url = f'{githubBaseURL}/orgs/{orgname}/repos?page={page}'
response = requests.get(url, headers=headers)
repos = json.loads(response.text)
repos = json.loads(response.text)
Comment on lines 17 to +18
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 HIGH RISK

The GitHub API request lacks error handling. If the request fails (e.g., rate limiting or 404), the script will continue and likely crash when attempting to access repo['name']. It is safer to verify the response status before processing and use response.json().

Recommended fix:

response = requests.get(url, headers=headers)
response.raise_for_status()
repos = response.json()


if len(repos) > 0:
for repo in repos:
listRepos.append(repo['name'])
page+=1
repositories.append(repo['name'])
page += 1
else:
hasNextPage = False
return listRepos

return repositories

def addAllRepositories(baseurl,provider, organization, token,githubToken,githubBaseURL,reponame):
repositories = listRepositoriesfromGithub(organization,githubToken,githubBaseURL)
Expand Down
Loading