Skip to content

Commit e7f630f

Browse files
committed
Bumping to minor v1.0.17.3 to include support for blocked/disabled repositories and while we're at it, to add some extra type validation.
1 parent 7dd8446 commit e7f630f

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/gitxray/gitxray.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def gitxray_cli():
2020
░░██████ ░░██████
2121
░░░░░░ ░░░░░░
2222
gitxray: X-Ray and analyze GitHub Repositories and their Contributors. Trust no one!
23-
v1.0.17.2 - Developed by Kulkan Security [www.kulkan.com] - Penetration testing by creative minds.
23+
v1.0.17.3 - Developed by Kulkan Security [www.kulkan.com] - Penetration testing by creative minds.
2424
"""+"#"*gx_definitions.SCREEN_SEPARATOR_LENGTH)
2525

2626
# Let's initialize a Gitxray context, which parses arguments and more.
@@ -70,17 +70,20 @@ def gitxray_cli():
7070
try:
7171
for repo in gx_context.getRepositoryTargets():
7272
r_started_at = datetime.datetime.now()
73-
try:
74-
repository = gh_api.fetch_repository(repo)
75-
gx_output.r_log(f"X-Ray on repository started at: {r_started_at}", repository=repository.get('full_name'), rtype="metrics")
76-
gx_output.stdout("#"*gx_definitions.SCREEN_SEPARATOR_LENGTH)
77-
gx_output.stdout("Now verifying repository: {}".format(repository.get('full_name')))
78-
except Exception as ex:
79-
print("Unable to pull data for the repository that was provided. Is it a valid repo URL?")
80-
if gx_context.debugEnabled():
81-
print(ex)
82-
sys.exit()
83-
73+
74+
repository = gh_api.fetch_repository(repo)
75+
if "full_name" not in repository.keys():
76+
if "block" in repository.keys(): repository["full_name"] = "/".join(repo.rstrip("/").split("/")[-2:])
77+
else:
78+
print("Unable to pull data for the repository that was provided. Is it a valid repo URL?")
79+
sys.exit()
80+
81+
gx_output.r_log(f"X-Ray on repository started at: {r_started_at}", repository=repository.get('full_name'), rtype="metrics")
82+
gx_output.stdout("#"*gx_definitions.SCREEN_SEPARATOR_LENGTH)
83+
gx_output.stdout("Now verifying repository: {}".format(repository.get('full_name')))
84+
85+
if "block" in repository.keys(): gx_output.r_log(f"WARNING: The repository was DISABLED and BLOCKED by GitHub. Reason: {repository['block']['reason']}", rtype="profiling")
86+
8487
# Let's keep track of the repository that we're X-Raying
8588
gx_context.setRepository(repository)
8689

@@ -89,7 +92,6 @@ def gitxray_cli():
8992

9093
# Now call our xray modules! Specifically by name, until we make this more plug and play
9194
# The standard is that a return value of False leads to skipping additional modules
92-
9395
if not contributors_xray.run(gx_context, gx_output, gh_api): continue
9496
if not repository_xray.run(gx_context, gx_output, gh_api): continue
9597
if not workflows_xray.run(gx_context, gx_output, gh_api): continue

0 commit comments

Comments
 (0)