Skip to content

Commit 67704e6

Browse files
committed
Added a new "--shush" parameter which turns "shushable" mode on, discarding any progress output from stdout.
Added a new stdout method in gx_output to act as a proxy for print() calls, discarding "shushable" output. Turned gh_api into a class named GitHubRESTAPI which stores a references to gx_output. Added a "WARNING" label/prefix on a couple of Workflow findings which deserve an extra highlight. Added a new finding under the "personal" category which tells if the contributor has enabled "Available for hire" in their profile (docs describe it here: https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-user-account-settings/about-available-for-hire) Bumping version to 1.0.17
1 parent f00026e commit 67704e6

File tree

11 files changed

+318
-291
lines changed

11 files changed

+318
-291
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## Release v1.0.17 (January 26th, 2025)
4+
* Added a new "--shush" parameter which turns "shushable" mode on, discarding any progress output from stdout.
5+
* Added a new stdout method in gx_output to act as a proxy for print() calls, discarding "shushable" output.
6+
* Turned gh_api into a class named GitHubRESTAPI which stores a references to gx_output.
7+
* Added a "WARNING" label/prefix on a couple of Workflow findings which deserve an extra highlight.
8+
* Added a new finding under the "personal" category which tells if the contributor has enabled "Available for hire" in their profile (docs describe it here: https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-user-account-settings/about-available-for-hire)
9+
310
## Release v1.0.16.5 (January 18th, 2025)
411
* Fixed an error case (an unhandled exception) that showed up when scanning repositories with a very large list of contributors (e.g. torvalds/linux, or MicrosoftDocs/azure-docs), which leads to GitHub REST APIs responding in an undocumented manner, stating that: "The history or contributor list is too large to list contributors for this repository via the API".
512

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "gitxray"
7-
version = "1.0.16.5"
7+
version = "1.0.17"
88
authors = [
99
{ name="Lucas Lavarello", email="llavarello@kulkan.com" },
1010
]

src/gitxray/gitxray.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22
import os, sys, datetime
3-
from gitxray.include import gh_api, gx_output as gx_output_class, gx_context as gx_context_class, gx_definitions
3+
from gitxray.include import gh_api as gh_api_class, gx_output as gx_output_class, gx_context as gx_context_class, gx_definitions
44
from gitxray.xrays import repository_xray
55
from gitxray.xrays import contributors_xray
66
from gitxray.xrays import association_xray
@@ -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.16.5 - Developed by Kulkan Security [www.kulkan.com] - Penetration testing by creative minds.
23+
v1.0.17 - 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.
@@ -29,6 +29,9 @@ def gitxray_cli():
2929
# Let's initialize our Output object that handles stdout and file writing in text or json
3030
gx_output = gx_output_class.Output(gx_context)
3131

32+
# And GitHub's REST API, sharing a ref to the Output object
33+
gh_api = gh_api_class.GitHubRESTAPI(gx_output)
34+
3235
# Let's warn the user that unauth RateLimits are pretty low
3336
if not gx_context.usingToken():
3437
gx_output.warn(f"{gx_definitions.ENV_GITHUB_TOKEN} environment variable not set, using GitHub RateLimits unauthenticated.")
@@ -50,18 +53,18 @@ def gitxray_cli():
5053

5154
if gx_context.getOrganizationTarget():
5255
org_repos = gh_api.fetch_repositories_for_org(gx_context.getOrganizationTarget())
53-
print("#"*gx_definitions.SCREEN_SEPARATOR_LENGTH)
56+
gx_output.stdout("#"*gx_definitions.SCREEN_SEPARATOR_LENGTH)
5457
if isinstance(org_repos, list) and len(org_repos) > 0:
5558
gx_output.notify(f"YOU HAVE EXPANDED THE SCOPE TO AN ORGANIZATION: A list of {len(org_repos)} repositories have been discovered. Sit tight.")
5659
if gx_context.listAndQuit():
57-
gx_output.notify(f"LISTING REPOSITORIES FOR THE ORGANIZATION AND EXITING..")
58-
print(", ".join([r.get('full_name') for r in org_repos]))
60+
gx_output.notify(f"LISTING REPOSITORIES FOR THE ORGANIZATION AND EXITING..", False)
61+
gx_output.stdout(", ".join([r.get('full_name') for r in org_repos]), False)
5962
sys.exit()
6063
gx_context.setRepositoryTargets([r.get('html_url') for r in org_repos])
6164
else:
6265
gx_output.warn("Unable to pull repositories for the organization URL that was provided. Is it a valid Organization URL?")
6366
if gx_context.debugEnabled():
64-
print(org_repos)
67+
gx_output.stdout(org_repos, shushable=False)
6568
sys.exit()
6669

6770
try:
@@ -70,8 +73,8 @@ def gitxray_cli():
7073
try:
7174
repository = gh_api.fetch_repository(repo)
7275
gx_output.r_log(f"X-Ray on repository started at: {r_started_at}", repository=repository.get('full_name'), rtype="metrics")
73-
print("#"*gx_definitions.SCREEN_SEPARATOR_LENGTH)
74-
print("Now verifying repository: {}".format(repository.get('full_name')))
76+
gx_output.stdout("#"*gx_definitions.SCREEN_SEPARATOR_LENGTH)
77+
gx_output.stdout("Now verifying repository: {}".format(repository.get('full_name')))
7578
except Exception as ex:
7679
print("Unable to pull data for the repository that was provided. Is it a valid repo URL?")
7780
if gx_context.debugEnabled():
@@ -87,18 +90,18 @@ def gitxray_cli():
8790
# Now call our xray modules! Specifically by name, until we make this more plug and play
8891
# The standard is that a return value of False leads to skipping additional modules
8992

90-
if not contributors_xray.run(gx_context, gx_output): continue
91-
if not repository_xray.run(gx_context, gx_output): continue
92-
if not workflows_xray.run(gx_context, gx_output): continue
93+
if not contributors_xray.run(gx_context, gx_output, gh_api): continue
94+
if not repository_xray.run(gx_context, gx_output, gh_api): continue
95+
if not workflows_xray.run(gx_context, gx_output, gh_api): continue
9396

9497
# Now that we're done, let's cross reference everything in the repository.
95-
association_xray.run(gx_context, gx_output)
98+
association_xray.run(gx_context, gx_output, gh_api)
9699

97100
r_ended_at = datetime.datetime.now()
98101
gx_output.r_log(f"X-Ray on repository ended at: {r_ended_at} - {((r_ended_at-r_started_at).seconds/60):.2f} minutes elapsed", rtype="metrics")
99102
gx_output.doOutput()
100103

101-
print(f"\rRepository has been analyzed.." + " "*40)
104+
gx_output.stdout(f"\rRepository has been analyzed.." + " "*40)
102105

103106
# We're resetting our context on every new repo; eventually we'll maintain a context per Org.
104107
gx_context.reset()

0 commit comments

Comments
 (0)