mirror of
https://github.com/bellingcat/octosuite.git
synced 2026-06-09 20:08:33 +03:00
Compare commits
169 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
646ea3cb51 | ||
|
|
3e18a3301a | ||
|
|
d4b595d79e | ||
|
|
0f247d1dd8 | ||
|
|
1b2c441237 | ||
|
|
2723c2f8dd | ||
|
|
7576fa64a1 | ||
|
|
79a97a7883 | ||
|
|
ac6ebc6d72 | ||
|
|
a12210cfa2 | ||
|
|
47e0b4c64a | ||
|
|
c4847773a0 | ||
|
|
832e887302 | ||
|
|
8487898f93 | ||
|
|
4d8b7394f0 | ||
|
|
e925c9cb8a | ||
|
|
dd2edfd204 | ||
|
|
13efce4f9c | ||
|
|
928ba6580f | ||
|
|
457c2a5472 | ||
|
|
c6c037247f | ||
|
|
f84fcf0d35 | ||
|
|
8424c94bec | ||
|
|
a14b356b18 | ||
|
|
f60f088f05 | ||
|
|
c2a5dc89ea | ||
|
|
6a7b61b1f2 | ||
|
|
4427f30f77 | ||
|
|
9982727de1 | ||
|
|
866621db18 | ||
|
|
48b86cb2d0 | ||
|
|
96b10f0bf9 | ||
|
|
53ccc9899b | ||
|
|
bb82427abe | ||
|
|
ee4af7d266 | ||
|
|
3bd6af4f28 | ||
|
|
7531aa4f02 | ||
|
|
f9d56c51a0 | ||
|
|
5bff3ccc12 | ||
|
|
272fcc36ed | ||
|
|
64c1063ea5 | ||
|
|
4c7109f4f0 | ||
|
|
d907167713 | ||
|
|
9eec2e323d | ||
|
|
ead76074f5 | ||
|
|
e87560939f | ||
|
|
3f1191758b | ||
|
|
34c7cd3918 | ||
|
|
52c4101a7a | ||
|
|
0677b901f7 | ||
|
|
49215fd03e | ||
|
|
8fc14d3ec4 | ||
|
|
3da2b91fb2 | ||
|
|
b6908a19f4 | ||
|
|
4db8300e2c | ||
|
|
07ca8c486c | ||
|
|
9473b0278d | ||
|
|
4113c62d09 | ||
|
|
f235bc1186 | ||
|
|
4d0e7beea7 | ||
|
|
7b1fd3addc | ||
|
|
3968f53e98 | ||
|
|
bd9c1f210f | ||
|
|
0518f33571 | ||
|
|
c783a717a0 | ||
|
|
ea3b8bcd71 | ||
|
|
cdf04fe443 | ||
|
|
f3b90f2e6d | ||
|
|
bf77bc4dfe | ||
|
|
157cb68142 | ||
|
|
53433c119b | ||
|
|
5d41e07bc2 | ||
|
|
331c81ac46 | ||
|
|
e3c151e2d3 | ||
|
|
a89596efc2 | ||
|
|
283a92fa84 | ||
|
|
beb8d561f8 | ||
|
|
b68842df1c | ||
|
|
dd7fcc455d | ||
|
|
b3ae15a062 | ||
|
|
4c8d3626b3 | ||
|
|
1f86ad4034 | ||
|
|
e151f81d76 | ||
|
|
a69fbf33d9 | ||
|
|
227fcd0482 | ||
|
|
8d04112d32 | ||
|
|
66373fd96e | ||
|
|
c4f1940bb6 | ||
|
|
f79813ed45 | ||
|
|
ffd162d881 | ||
|
|
558715fdab | ||
|
|
9984c71a57 | ||
|
|
bb2efb903b | ||
|
|
defe1b1159 | ||
|
|
347acea797 | ||
|
|
46937abb7e | ||
|
|
2963db3608 | ||
|
|
92d4f3f9f2 | ||
|
|
02df05df39 | ||
|
|
549f1940f9 | ||
|
|
e936525f81 | ||
|
|
29eb2bde95 | ||
|
|
d27d9b9168 | ||
|
|
a6ca1e3c0c | ||
|
|
5bf7ef3f39 | ||
|
|
ae73fdffde | ||
|
|
7c8fea02e6 | ||
|
|
40fffcab73 | ||
|
|
9a6127d6bc | ||
|
|
eb724f629f | ||
|
|
6d04b990db | ||
|
|
2537bcbab8 | ||
|
|
bb6c5a09e9 | ||
|
|
083d3e9f71 | ||
|
|
497c855648 | ||
|
|
c2641b3134 | ||
|
|
a108b4784e | ||
|
|
597ad07490 | ||
|
|
94c1e0a737 | ||
|
|
6e83bcf367 | ||
|
|
a57f5d47e2 | ||
|
|
3fa3e7a182 | ||
|
|
d42b7af59f | ||
|
|
8d337c621c | ||
|
|
5842a13975 | ||
|
|
e739f78eb9 | ||
|
|
26cf25bf91 | ||
|
|
ad6959d1b9 | ||
|
|
d7af8602fe | ||
|
|
29d40ec27e | ||
|
|
6a0953401b | ||
|
|
e87e5c64c8 | ||
|
|
c53ab2a00b | ||
|
|
b30ad16719 | ||
|
|
cfa032f7cb | ||
|
|
87f287bfb9 | ||
|
|
ab70a10d19 | ||
|
|
02e19baa93 | ||
|
|
0b76846968 | ||
|
|
9614785455 | ||
|
|
6ae34437a4 | ||
|
|
5a1b5378ee | ||
|
|
64d1b6bf38 | ||
|
|
09fffdf192 | ||
|
|
8e4520b6d2 | ||
|
|
420186bec4 | ||
|
|
758676ac88 | ||
|
|
310b1fb702 | ||
|
|
6822806a77 | ||
|
|
4eddd20480 | ||
|
|
95dcfbea6e | ||
|
|
258be0a2d7 | ||
|
|
3b329d039a | ||
|
|
fec88ac343 | ||
|
|
272cd49d0e | ||
|
|
cea07f187a | ||
|
|
0f96785123 | ||
|
|
000eb80fbc | ||
|
|
e4f1e2928a | ||
|
|
73fa406e82 | ||
|
|
e99e0c317e | ||
|
|
7d2eada3f9 | ||
|
|
f706a08859 | ||
|
|
b3ccb713e1 | ||
|
|
0bb330d771 | ||
|
|
df339d33df | ||
|
|
c296f09e0e | ||
|
|
04ea880276 | ||
|
|
eef44716d5 |
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
FROM python:latest
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN pip install --upgrade pip && pip install build && python -m build && pip install dist/*.whl
|
||||
|
||||
ENTRYPOINT ["octosuite"]
|
||||
40
README.md
40
README.md
@@ -1,22 +1,29 @@
|
||||

|
||||
|
||||
[](https://github.com/rly0nheart/octosuite/actions/workflows/python-publish.yml)
|
||||
[](https://github.com/rly0nheart/octosuite/actions/workflows/codeql.yml)
|
||||

|
||||
A framework for gathering open-source intelligence on GitHub users, repositories and organizations
|
||||
|
||||
[](https://github.com/bellingcat/octosuite/actions/workflows/python-publish.yml)
|
||||
[](https://github.com/bellingcat/octosuite/actions/workflows/codeql.yml)
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
> *Simply gather OSINT on Github users & organizations like a God🔥*
|
||||

|
||||

|
||||
> About
|
||||

|
||||
|
||||
> User profile
|
||||

|
||||
|
||||
> Organisation profile
|
||||

|
||||
|
||||
|
||||
## Wiki
|
||||
[Refer to the Wiki](https://github.com/rly0nheart/octosuite/wiki) for installation instructions, in addition to all other documentation.
|
||||
# Wiki
|
||||
[Refer to the Wiki](https://github.com/bellingcat/octosuite/wiki) for installation instructions, in addition to all other documentation.
|
||||
|
||||
## Features
|
||||
# Features
|
||||
- [x] Fetches an organization's profile information
|
||||
- [x] Fetches an oganization's events
|
||||
- [x] Returns an organization's repositories
|
||||
@@ -46,18 +53,19 @@
|
||||
- [x] Searches commits
|
||||
- [x] Automatically logs network activity (.logs folder)
|
||||
- [x] User can view, read and delete logs
|
||||
- [x] All the above can be used with command-line arguments (PyPI Package only)
|
||||
- [x] ...And more
|
||||
|
||||
## Note
|
||||
> octosuite automatically logs network and minor user activity of each session. The logs are saved by date and time in the .logs folder
|
||||
>> If you believe octosuite can be better, feel free to open a pull request with your improvements✌🏾🙂
|
||||
> Octosuite automatically logs network and user activity of each session, the logs are saved by date and time in the .logs folder
|
||||
|
||||
## License
|
||||
|
||||
# License
|
||||

|
||||
|
||||
## Donations
|
||||
Love octosuite and would like to donate? You can buy me a coffee using the button below.
|
||||
# Donations
|
||||
If you like OctoSuite and would like to show support, you can Buy A Coffee for the developer using the button below
|
||||
|
||||
<a href="https://www.buymeacoffee.com/189381184" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
|
||||
|
||||
Your support is much appreciated!☕👌🏾😊
|
||||
Your support will be much appreciated😊
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
import getpass
|
||||
from octosuite.colors import red, white, green, reset
|
||||
from octosuite.config import red, white, green, reset, Tree
|
||||
|
||||
'''
|
||||
banner.py
|
||||
This file holds the program's banner logo and version tag
|
||||
'''
|
||||
version_tag = "2.2.2"
|
||||
name_logo = f"""{white}
|
||||
|
||||
# banner.py
|
||||
# This file holds the program's banner and version tag
|
||||
version_tag = "3.0.4"
|
||||
|
||||
|
||||
def banner():
|
||||
banner_tree = Tree(getpass.getuser())
|
||||
banner_tree.add(f"use ‘{green}help{reset}’ command for usage")
|
||||
banner_tree.add(f"commands are case insensitive\n")
|
||||
return f"""
|
||||
_______ __ _______ __ __
|
||||
| |.----.| |_.-----.| __|.--.--.|__| |_.-----.
|
||||
| - || __|| _| _ ||__ || | || | _| -__|
|
||||
|_______||____||____|_____||_______||_____||__|____|_____|
|
||||
v{version_tag}
|
||||
v{version_tag}
|
||||
{white}— Advanced Github {red}OSINT{white} Framework
|
||||
|
||||
|
||||
|
||||
.:{getpass.getuser()}:.
|
||||
├─ use ‘{green}help{reset}{white}’ command for usage
|
||||
└╼ commands are case insensitive{reset}
|
||||
"""
|
||||
""", banner_tree
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
import platform
|
||||
from datetime import datetime
|
||||
|
||||
# This file is responsible for enabling/disabling colors in OctoSuite
|
||||
# This file gets called first at start up before any other file gets called
|
||||
# colors.py is the reason why users get to choose whether to enable/disable colors
|
||||
system_info = [("Processor",platform.processor),
|
||||
("Node", platform.node),
|
||||
("Release", platform.release),
|
||||
("Architecture", platform.architecture),
|
||||
("Version", platform.version)]
|
||||
banner = f"""
|
||||
OCTOSUITE © 2022 Richard Mwewa
|
||||
{datetime.now().strftime('%A %d %B %Y, %H:%M:%S%p')}
|
||||
|
||||
"""
|
||||
|
||||
print(banner)
|
||||
print(f"\t{platform.system()}")
|
||||
for key, value in system_info:
|
||||
print(f"\t├─ {key}: {value()}")
|
||||
print("\n")
|
||||
while True:
|
||||
try:
|
||||
color_chooser = input(f"[ ? ] Welcome, would you like to enable colors for this session? (Y/n) ").lower()
|
||||
if color_chooser == "y":
|
||||
header_title = "bold white"
|
||||
red = "[red]"
|
||||
white = "[white]"
|
||||
green = "[green]"
|
||||
red_bold = "[white bold]"
|
||||
white_bold = "[white bold]"
|
||||
green_bold = "[green bold]"
|
||||
reset = "[/]"
|
||||
break
|
||||
elif color_chooser == "n":
|
||||
header_title = red = white = green = red_bold = white_bold = green_bold = reset = ""
|
||||
break
|
||||
else:
|
||||
print(f"\n[ ! ] Your response '{color_chooser}' is invalid (expected y or n)")
|
||||
|
||||
except KeyboardInterrupt:
|
||||
exit(f"[ ! ] Process interrupted with [Ctrl+C].")
|
||||
200
octosuite/config.py
Normal file
200
octosuite/config.py
Normal file
@@ -0,0 +1,200 @@
|
||||
import psutil
|
||||
import platform
|
||||
import argparse
|
||||
from rich.tree import Tree
|
||||
from rich.text import Text
|
||||
from rich.table import Table
|
||||
from datetime import datetime
|
||||
from rich import print as xprint
|
||||
from rich.prompt import Prompt, Confirm
|
||||
|
||||
|
||||
def usage():
|
||||
return """
|
||||
Basic Usage
|
||||
===========
|
||||
|
||||
Get User Profile Info
|
||||
---------------------
|
||||
octosuite --method user_profile --username <username>
|
||||
|
||||
|
||||
Get User Repos
|
||||
--------------
|
||||
octosuite --method user_repos --username <username>
|
||||
|
||||
|
||||
Get Organi[sz]ation Profile Info
|
||||
-----------------------------
|
||||
octosuite --method org_profile --organization <organization_name>
|
||||
|
||||
|
||||
Get Organi[sz]ation Repos
|
||||
-----------------------------
|
||||
octosuite --method org_repos --organization <organization_name>
|
||||
|
||||
|
||||
Get Repo Profile Info
|
||||
---------------------
|
||||
octosuite --method repo_profile --username <username> --repository <repo_name>
|
||||
|
||||
|
||||
Get Repo Forks
|
||||
--------------
|
||||
octosuite --method repo_forks --username <username> --repository <repo_name>
|
||||
|
||||
|
||||
|
||||
Searching
|
||||
=========
|
||||
|
||||
Search Users
|
||||
------------
|
||||
octosuite --method users_search --query <query>
|
||||
|
||||
|
||||
Search Issues
|
||||
-------------
|
||||
octosuite --method issues_search --query <query>
|
||||
|
||||
|
||||
Search Commits
|
||||
--------------
|
||||
octosuite --method commits_search --query <query>
|
||||
|
||||
|
||||
Search Topics
|
||||
-------------
|
||||
octosuite --method topics_search --query <query>
|
||||
|
||||
|
||||
Search Repositories
|
||||
-------------------
|
||||
octosuite --method repos_search --query <query>
|
||||
|
||||
|
||||
|
||||
Log Management
|
||||
==============
|
||||
|
||||
View logs
|
||||
---------
|
||||
octosuite --method view_logs
|
||||
|
||||
|
||||
Read log
|
||||
--------
|
||||
octosuite --method read_log --log-file <log_file>
|
||||
|
||||
|
||||
Delete log
|
||||
----------
|
||||
octosuite --method delete_log --log-file <log_file>
|
||||
|
||||
|
||||
Clear logs
|
||||
----------
|
||||
octosuite --method clear_logs
|
||||
|
||||
|
||||
|
||||
CSV Management
|
||||
==============
|
||||
|
||||
View CSV
|
||||
---------
|
||||
octosuite --method view_csv
|
||||
|
||||
|
||||
Read CSV
|
||||
--------
|
||||
octosuite --method read_csv --csv-file <csv_file>
|
||||
|
||||
|
||||
Delete CSV
|
||||
----------
|
||||
octosuite --method delete_csv --csv-file <csv_file>
|
||||
|
||||
|
||||
Clear CSV's
|
||||
-----------
|
||||
octosuite --method clear_csv
|
||||
"""
|
||||
|
||||
|
||||
def create_parser():
|
||||
parser = argparse.ArgumentParser(description='OCTOSUITE: Advanced GitHub osint framework — by Richard Mwewa | https://about.me/rly0nheart', usage=usage())
|
||||
parser.add_argument('-m', '--method', help='method', choices=['user_profile', 'user_repos', 'user_gists', 'user_orgs', 'user_events',
|
||||
'user_subscriptions', 'user_following', 'user_followers', 'user_follows',
|
||||
'org_profile', 'org_repos', 'org_events', 'org_member',
|
||||
'repo_profile', 'repo_contributors', 'repo_stargazers', 'repo_forks',
|
||||
'repo_issues', 'repo_releases', 'repo_path_contents', 'users_search', 'issues_search',
|
||||
'commits_search', 'topics_search', 'repos_search', 'view_logs', 'read_log', 'delete_log',
|
||||
'clear_logs', 'view_csv', 'read_csv', 'delete_csv', 'clear_csv', 'about', 'author'])
|
||||
parser.add_argument('-u', '--username', help='username')
|
||||
parser.add_argument('-uB', '--username_b', help='username_B (used with user_follows)')
|
||||
parser.add_argument('-o', '--organization', '--organisation', help='organi[sz]ation name')
|
||||
parser.add_argument('-r', '--repository', help='repository name')
|
||||
parser.add_argument('-p', '--path_name', help='path name (used with repo_path_contents)')
|
||||
parser.add_argument('-q', '--query', help='query (used with search methods)')
|
||||
parser.add_argument('-l', '--limit', help='output limit (used with methods that return results in bulk) (default: %(default)s)', default=10)
|
||||
parser.add_argument('-c', '--colors', '--colours', help='specify to run octosuite cli with colo[u]rs enabled', action='store_true')
|
||||
parser.add_argument('--csv_file', help='csv file (used with csv management methods)')
|
||||
parser.add_argument('--log_file', help='log file (used with logs management methods)')
|
||||
parser.add_argument('--log-to-csv', help='log output to a csv file', action='store_true', dest='log_csv')
|
||||
return parser
|
||||
|
||||
|
||||
parser = create_parser()
|
||||
args = parser.parse_args()
|
||||
|
||||
# This file is responsible for enabling/disabling colo[u]rs and configuring argparse in OctoSuite
|
||||
# This file gets called first at start up before any other file
|
||||
# config.py is the reason why users get to choose whether to enable/disable colo[u]rs, and call the program with command line arguments
|
||||
# delete this file (I dare you), the entire program breaks
|
||||
system_info = [("RAM", f"{str(round(psutil.virtual_memory().total / (1024.0 ** 3)))}GB"),
|
||||
("Node", platform.node()),
|
||||
("Release", platform.release()),
|
||||
("Version", platform.version()),
|
||||
("Processor", platform.processor()),
|
||||
("Architecture", platform.architecture())]
|
||||
first_banner = f"""
|
||||
OCTOSUITE © 2023 Richard Mwewa
|
||||
{datetime.now().strftime('%A %d %B %Y, %H:%M:%S%p')}
|
||||
|
||||
"""
|
||||
|
||||
if args.colors:
|
||||
header_title = "bold white"
|
||||
red = "[red]"
|
||||
white = "[white]"
|
||||
green = "[green]"
|
||||
yellow = "[yellow]"
|
||||
red_bold = "[white bold]"
|
||||
white_bold = "[white bold]"
|
||||
green_bold = "[green bold]"
|
||||
reset = "[/]"
|
||||
else:
|
||||
print(first_banner)
|
||||
system_tree = Tree(platform.system())
|
||||
for system_key, system_value in system_info:
|
||||
system_tree.add(f"{system_key}: {system_value}")
|
||||
xprint(system_tree)
|
||||
print("\n")
|
||||
try:
|
||||
color_chooser = Confirm.ask(f"Welcome, would you like to enable colo(u)rs for this session?")
|
||||
if color_chooser:
|
||||
header_title = "bold white"
|
||||
red = "[red]"
|
||||
white = "[white]"
|
||||
green = "[green]"
|
||||
yellow = "[yellow]"
|
||||
red_bold = "[white bold]"
|
||||
white_bold = "[white bold]"
|
||||
green_bold = "[green bold]"
|
||||
reset = "[/]"
|
||||
else:
|
||||
header_title = red = white = green = red_bold = white_bold = green_bold = reset = yellow = ""
|
||||
except KeyboardInterrupt:
|
||||
exit(f"[WARNING] Process interrupted with Ctrl+C.")
|
||||
|
||||
@@ -1,447 +1,442 @@
|
||||
import os
|
||||
import csv
|
||||
import logging
|
||||
from rich import print as xprint
|
||||
from octosuite.sign_vars import SignVar
|
||||
from octosuite.log_roller import logRoller
|
||||
from octosuite.colors import red, white, green, reset
|
||||
|
||||
'''
|
||||
csvLogger
|
||||
This class holds the methods for creating .csv files of each functionality in main
|
||||
'''
|
||||
class csvLogger:
|
||||
# .csv for organization' profile
|
||||
def logOrgProfile(response):
|
||||
org_profile_fields = ['Profile photo', 'Name', 'Username', 'ID', 'Node ID', 'Email', 'About', 'Location', 'Blog', 'Followers', 'Following', 'Twitter handle', 'Gists', 'Repositories', 'Account type', 'Is verified?', 'Has organization projects?', 'Has repository projects?', 'Created at', 'Updated at']
|
||||
org_profile_row = [response.json()['avatar_url'], response.json()['name'], response.json()['login'], response.json()['id'], response.json()['node_id'], response.json()['email'], response.json()['description'], response.json()['location'], response.json()['blog'], response.json()['followers'], response.json()['following'], response.json()['twitter_username'], response.json()['public_gists'], response.json()['public_repos'], response.json()['type'], response.json()['is_verified'], response.json()['has_organization_projects'], response.json()['has_repository_projects'], response.json()['created_at'], response.json()['updated_at']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{response.json()['name']}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(org_profile_fields)
|
||||
writecsv.writerow(org_profile_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
from octosuite.log_roller import prompt_log_csv, logged_to_csv
|
||||
from octosuite.message_prefixes import PROMPT, WARNING, POSITIVE, NEGATIVE, INFO
|
||||
|
||||
|
||||
# Creating a .csv file of a user' profile
|
||||
def logUserProfile(response):
|
||||
user_profile_fields = ['Profile photo', 'Name', 'Username', 'ID', 'Node ID', 'Bio', 'Blog', 'Location', 'Followers', 'Following', 'Twitter handle', 'Gists', 'Repositories', 'Organization', 'Is hireable?', 'Is site admin?', 'Joined at', 'Updated at']
|
||||
user_profile_row = [response.json()['avatar_url'], response.json()['name'], response.json()['login'], response.json()['id'], response.json()['node_id'], response.json()['bio'], response.json()['blog'], response.json()['location'], response.json()['followers'], response.json()['following'], response.json()['twitter_username'], response.json()['public_gists'], response.json()['public_repos'], response.json()['company'], response.json()['hireable'], response.json()['site_admin'], response.json()['created_at'], response.json()['updated_at']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{response.json()['login']}.csv", 'w',) as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(user_profile_fields)
|
||||
writecsv.writerow(user_profile_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
# csv_loggers.py
|
||||
# This file holds the functions for creating .csv files of each functionality in main
|
||||
def log_org_profile(response):
|
||||
org_profile_fields = ['Profile photo', 'Name', 'Username', 'ID', 'Node ID', 'Email', 'About', 'Location', 'Blog',
|
||||
'Followers', 'Following', 'Twitter handle', 'Gists', 'Repositories', 'Account type',
|
||||
'Is verified?', 'Has organization projects?', 'Has repository projects?', 'Created at',
|
||||
'Updated at']
|
||||
org_profile_row = [response.json()['avatar_url'], response.json()['name'], response.json()['login'],
|
||||
response.json()['id'], response.json()['node_id'], response.json()['email'],
|
||||
response.json()['description'], response.json()['location'], response.json()['blog'],
|
||||
response.json()['followers'], response.json()['following'], response.json()['twitter_username'],
|
||||
response.json()['public_gists'], response.json()['public_repos'], response.json()['type'],
|
||||
response.json()['is_verified'], response.json()['has_organization_projects'],
|
||||
response.json()['has_repository_projects'], response.json()['created_at'],
|
||||
response.json()['updated_at']]
|
||||
|
||||
with open(os.path.join("output", f"{response.json()['name']}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(org_profile_fields)
|
||||
write_csv.writerow(org_profile_row)
|
||||
|
||||
|
||||
# create .csv for repository profile
|
||||
def logRepoProfile(response):
|
||||
repo_profile_fields = [ 'Name','ID', 'About', 'Forks', 'Stars', 'Watchers', 'License', 'Branch', 'Visibility', 'Language(s)', 'Open issues', 'Topics', 'Homepage', 'Clone URL', 'SSH URL', 'Is fork?', 'Is forkable?', 'Is private?', 'Is archived?', 'Is template?', 'Has wiki?', 'Has pages?', 'Has projects?', 'Has issues?', 'Has downloads?', 'Pushed at', 'Created at', 'Updated at']
|
||||
repo_profile_row = [response.json()['name'], response.json()['id'], response.json()['description'], response.json()['forks'], response.json()['stargazers_count'], response.json()['watchers'], response.json()['license'], response.json()['default_branch'], response.json()['visibility'], response.json()['language'], response.json()['open_issues'], response.json()['topics'], response.json()['homepage'], response.json()['clone_url'], response.json()['ssh_url'], response.json()['fork'], response.json()['allow_forking'], response.json()['private'], response.json()['archived'], response.json()['is_template'], response.json()['has_wiki'], response.json()['has_pages'], response.json()['has_projects'], response.json()['has_issues'], response.json()['has_downloads'], response.json()['pushed_at'], response.json()['created_at'], response.json()['updated_at']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{response.json()['name']}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(repo_profile_fields)
|
||||
writecsv.writerow(repo_profile_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
|
||||
|
||||
# create .csv for repository path contents
|
||||
def logRepoPathContents(content, repo_name):
|
||||
path_content_fields = ['Filename', 'Size (bytes)', 'Type', 'Path', 'SHA', 'URL']
|
||||
path_content_row = [content['name'], content['size'], content['type'], content['path'], content['sha'], content['html_url']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{content['name']}_content_from_{repo_name}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(path_content_fields)
|
||||
writecsv.writerow(path_content_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# create .csv for repository stargazer
|
||||
def logRepoStargazers(stargazer, repo_name):
|
||||
user_follower_fields = ['Profile photo', 'Username', 'ID', 'Node ID', 'Gravatar ID', 'Account type', 'Is site admin?', 'URL']
|
||||
user_follower_row = [stargazer['avatar_url'], stargazer['login'], stargazer['id'], stargazer['node_id'], stargazer['gravatar_id'], stargazer['type'], stargazer['site_admin'], stargazer['html_url']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{stargazer['login']}_stargazer_of_{repo_name}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(user_follower_fields)
|
||||
writecsv.writerow(user_follower_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
# Creating a .csv file of a user' profile
|
||||
def log_user_profile(response):
|
||||
user_profile_fields = ['Profile photo', 'Name', 'Username', 'ID', 'Node ID', 'Bio', 'Blog', 'Location', 'Followers',
|
||||
'Following', 'Twitter handle', 'Gists', 'Repositories', 'Organization', 'Is hireable?',
|
||||
'Is site admin?', 'Joined at', 'Updated at']
|
||||
user_profile_row = [response.json()['avatar_url'], response.json()['name'], response.json()['login'],
|
||||
response.json()['id'], response.json()['node_id'], response.json()['bio'],
|
||||
response.json()['blog'], response.json()['location'], response.json()['followers'],
|
||||
response.json()['following'], response.json()['twitter_username'],
|
||||
response.json()['public_gists'], response.json()['public_repos'], response.json()['company'],
|
||||
response.json()['hireable'], response.json()['site_admin'], response.json()['created_at'],
|
||||
response.json()['updated_at']]
|
||||
|
||||
with open(os.path.join("output", f"{response.json()['login']}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(user_profile_fields)
|
||||
write_csv.writerow(user_profile_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# create .csv for repository profile
|
||||
def log_repo_profile(response):
|
||||
repo_profile_fields = ['Name', 'ID', 'About', 'Forks', 'Stars', 'Watchers', 'License', 'Branch', 'Visibility',
|
||||
'Language(s)', 'Open issues', 'Topics', 'Homepage', 'Clone URL', 'SSH URL', 'Is fork?',
|
||||
'Is forkable?', 'Is private?', 'Is archived?', 'Is template?', 'Has wiki?', 'Has pages?',
|
||||
'Has projects?', 'Has issues?', 'Has downloads?', 'Pushed at', 'Created at', 'Updated at']
|
||||
repo_profile_row = [response.json()['name'], response.json()['id'], response.json()['description'],
|
||||
response.json()['forks'], response.json()['stargazers_count'], response.json()['watchers'],
|
||||
response.json()['license'], response.json()['default_branch'], response.json()['visibility'],
|
||||
response.json()['language'], response.json()['open_issues'], response.json()['topics'],
|
||||
response.json()['homepage'], response.json()['clone_url'], response.json()['ssh_url'],
|
||||
response.json()['fork'], response.json()['allow_forking'], response.json()['private'],
|
||||
response.json()['archived'], response.json()['is_template'], response.json()['has_wiki'],
|
||||
response.json()['has_pages'], response.json()['has_projects'], response.json()['has_issues'],
|
||||
response.json()['has_downloads'], response.json()['pushed_at'], response.json()['created_at'],
|
||||
response.json()['updated_at']]
|
||||
|
||||
with open(os.path.join("output", f"{response.json()['name']}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(repo_profile_fields)
|
||||
write_csv.writerow(repo_profile_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# create .csv for repository forks
|
||||
def logRepoForks(fork, count):
|
||||
repo_fork_fields = [ 'Name','ID', 'About', 'Forks', 'Stars', 'Watchers', 'License', 'Branch', 'Visibility', 'Language(s)', 'Open issues', 'Topics', 'Homepage', 'Clone URL', 'SSH URL', 'Is fork?', 'Is forkable?', 'Is private?', 'Is archived?', 'Is template?', 'Has wiki?', 'Has pages?', 'Has projects?', 'Has issues?', 'Has downloads?', 'Pushed at', 'Created at', 'Updated at']
|
||||
repo_fork_row = [fork['full_name'], fork['id'], fork['description'], fork['forks'], fork['stargazers_count'], fork['watchers'], fork['license'], fork['default_branch'], fork['visibility'], fork['language'], fork['open_issues'], fork['topics'], fork['homepage'], fork['clone_url'], fork['ssh_url'], fork['fork'], fork['allow_forking'], fork['private'], fork['archived'], fork['is_template'], fork['has_wiki'], fork['has_pages'], fork['has_projects'], fork['has_issues'], fork['has_downloads'], fork['pushed_at'], fork['created_at'], fork['updated_at']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{fork['name']}_fork_{count}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(repo_fork_fields)
|
||||
writecsv.writerow(repo_fork_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
# create .csv for repository path contents
|
||||
def log_repo_path_contents(content, repo_name):
|
||||
path_content_fields = ['Filename', 'Size (bytes)', 'Type', 'Path', 'SHA', 'URL']
|
||||
path_content_row = [content['name'], content['size'], content['type'], content['path'], content['sha'],
|
||||
content['html_url']]
|
||||
|
||||
with open(os.path.join("output", f"{content['name']}_content_from_{repo_name}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(path_content_fields)
|
||||
write_csv.writerow(path_content_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# create .csv for repository issues
|
||||
def logRepoIssues(issue, repo_name):
|
||||
repo_issue_fields = ['Title', 'ID', 'Node ID', 'Number', 'State', 'Reactions', 'Comments', 'Milestone', 'Assignee', 'Assignees', 'Author association', 'Labels', 'Is locked?', 'Lock reason', 'Closed at', 'Created at', 'Updated at']
|
||||
repo_issue_row = [issue['title'], issue['id'], issue['node_id'], issue['number'], issue['state'], issue['reactions'], issue['comments'], issue['milestone'], issue['assignee'], issue['assignees'], issue['author_association'], issue['labels'], issue['locked'], issue['active_lock_reason'], issue['closed_at'], issue['created_at'], issue['updated_at']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{repo_name}_issue_{issue['id']}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(repo_issue_fields)
|
||||
writecsv.writerow(repo_issue_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
# create .csv for repository stargazer
|
||||
def log_repo_stargazers(stargazer, repo_name):
|
||||
user_follower_fields = ['Profile photo', 'Username', 'ID', 'Node ID', 'Gravatar ID', 'Account type',
|
||||
'Is site admin?', 'URL']
|
||||
user_follower_row = [stargazer['avatar_url'], stargazer['login'], stargazer['id'], stargazer['node_id'],
|
||||
stargazer['gravatar_id'], stargazer['type'], stargazer['site_admin'], stargazer['html_url']]
|
||||
|
||||
with open(os.path.join("output", f"{stargazer['login']}_stargazer_of_{repo_name}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(user_follower_fields)
|
||||
write_csv.writerow(user_follower_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
# create .csv for repository forks
|
||||
def log_repo_forks(fork, count):
|
||||
repo_fork_fields = ['Name', 'ID', 'About', 'Forks', 'Stars', 'Watchers', 'License', 'Branch', 'Visibility',
|
||||
'Language(s)', 'Open issues', 'Topics', 'Homepage', 'Clone URL', 'SSH URL', 'Is fork?',
|
||||
'Is forkable?', 'Is private?', 'Is archived?', 'Is template?', 'Has wiki?', 'Has pages?',
|
||||
'Has projects?', 'Has issues?', 'Has downloads?', 'Pushed at', 'Created at', 'Updated at']
|
||||
repo_fork_row = [fork['full_name'], fork['id'], fork['description'], fork['forks'], fork['stargazers_count'],
|
||||
fork['watchers'], fork['license'], fork['default_branch'], fork['visibility'], fork['language'],
|
||||
fork['open_issues'], fork['topics'], fork['homepage'], fork['clone_url'], fork['ssh_url'],
|
||||
fork['fork'], fork['allow_forking'], fork['private'], fork['archived'], fork['is_template'],
|
||||
fork['has_wiki'], fork['has_pages'], fork['has_projects'], fork['has_issues'],
|
||||
fork['has_downloads'], fork['pushed_at'], fork['created_at'], fork['updated_at']]
|
||||
|
||||
with open(os.path.join("output", f"{fork['name']}_fork_{count}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(repo_fork_fields)
|
||||
write_csv.writerow(repo_fork_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# create .csv for repository releases
|
||||
def logRepoReleases(release, repo_name):
|
||||
repo_release_fields = ['Name', 'ID', 'Node ID', 'Tag', 'Branch', 'Assets', 'Is draft?', 'Is prerelease?', 'Created at', 'Published at']
|
||||
repo_release_row = [release['name'], release['id'], release['node_id'], release['tag_name'], release['target_commitish'], release['assets'], release['draft'], release['prerelease'], release['created_at'], release['published_at']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{repo_name}_release_{release['name']}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(repo_release_fields)
|
||||
writecsv.writerow(repo_release_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
|
||||
|
||||
# Create .csv file for repository contributors
|
||||
def logRepoContributors(contributor, repo_name):
|
||||
repo_contributor_fields = ['Profile photo', 'Username', 'ID', 'Node ID', 'Gravatar ID', 'Account type', 'Is site admin?', 'URL']
|
||||
repo_contributor_row = [contributor['avatar_url'], contributor['login'], contributor['id'], contributor['node_id'], contributor['gravatar_id'], contributor['type'], contributor['site_admin'], contributor['html_url']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{contributor['login']}_contributor_of_{repo_name}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(repo_contributor_fields)
|
||||
writecsv.writerow(repo_contributor_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
print(f"{SignVar.info} {logRoller.loggingSkipped}\n")
|
||||
|
||||
|
||||
# Create .csv for organization' events
|
||||
def logOrgEvents(event, organization):
|
||||
org_event_fields = ['ID', 'Type', 'Created at', 'Payload']
|
||||
org_event_row = [event['id'], event['type'], event['created_at'], event['payload']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{organization}_event_{event['id']}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(org_event_fields)
|
||||
writecsv.writerow(org_event_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
|
||||
|
||||
# Create .csv for organization' repositories
|
||||
def logOrgRepos(repository, organization):
|
||||
org_repo_fields = [ 'Name','ID', 'About', 'Forks', 'Stars', 'Watchers', 'License', 'Branch', 'Visibility', 'Language(s)', 'Open issues', 'Topics', 'Homepage', 'Clone URL', 'SSH URL', 'Is fork?', 'Is forkable?', 'Is private?', 'Is archived?', 'Is template?', 'Has wiki?', 'Has pages?', 'Has projects?', 'Has issues?', 'Has downloads?', 'Pushed at', 'Created at', 'Updated at']
|
||||
org_repo_row = [repository['full_name'], repository['id'], repository['description'], repository['forks'], repository['stargazers_count'], repository['watchers'], repository['license'], repository['default_branch'], repository['visibility'], repository['language'], repository['open_issues'], repository['topics'], repository['homepage'], repository['clone_url'], repository['ssh_url'], repository['fork'], repository['allow_forking'], repository['private'], repository['archived'], repository['is_template'], repository['has_wiki'], repository['has_pages'], repository['has_projects'], repository['has_issues'], repository['has_downloads'], repository['pushed_at'], repository['created_at'], repository['updated_at']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{repository['name']}_repository_of_{organization}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(org_repo_fields)
|
||||
writecsv.writerow(org_repo_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
|
||||
|
||||
# .csv for user' repositories
|
||||
def logUserRepos(repository, username):
|
||||
user_repo_fields = [ 'Name','ID', 'About', 'Forks', 'Stars', 'Watchers', 'License', 'Branch', 'Visibility', 'Language(s)', 'Open issues', 'Topics', 'Homepage', 'Clone URL', 'SSH URL', 'Is fork?', 'Is forkable?', 'Is private?', 'Is archived?', 'Is template?', 'Has wiki?', 'Has pages?', 'Has projects?', 'Has issues?', 'Has downloads?', 'Pushed at', 'Created at', 'Updated at']
|
||||
user_repo_row = [repository['full_name'], repository['id'], repository['description'], repository['forks'], repository['stargazers_count'], repository['watchers'], repository['license'], repository['default_branch'], repository['visibility'], repository['language'], repository['open_issues'], repository['topics'], repository['homepage'], repository['clone_url'], repository['ssh_url'], repository['fork'], repository['allow_forking'], repository['private'], repository['archived'], repository['is_template'], repository['has_wiki'], repository['has_pages'], repository['has_projects'], repository['has_issues'], repository['has_downloads'], repository['pushed_at'], repository['created_at'], repository['updated_at']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{repository['name']}_{username}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(user_repo_fields)
|
||||
writecsv.writerow(user_repo_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
|
||||
# create .csv for repository issues
|
||||
def log_repo_issues(issue, repo_name):
|
||||
repo_issue_fields = ['Title', 'ID', 'Node ID', 'Number', 'State', 'Reactions', 'Comments', 'Milestone', 'Assignee',
|
||||
'Assignees', 'Author association', 'Labels', 'Is locked?', 'Lock reason', 'Closed at',
|
||||
'Created at', 'Updated at']
|
||||
repo_issue_row = [issue['title'], issue['id'], issue['node_id'], issue['number'], issue['state'],
|
||||
issue['reactions'], issue['comments'], issue['milestone'], issue['assignee'], issue['assignees'],
|
||||
issue['author_association'], issue['labels'], issue['locked'], issue['active_lock_reason'],
|
||||
issue['closed_at'], issue['created_at'], issue['updated_at']]
|
||||
|
||||
# .csv for user events
|
||||
def logUserEvents(event):
|
||||
user_event_fields = ['Actor', 'Type', 'Repository', 'Created at', 'Payload']
|
||||
user_event_row = [event['actor']['login'], event['type'], event['repo']['name'], event['created_at'], event['payload']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{event['actor']['login']}_event_{event['id']}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(user_event_fields)
|
||||
writecsv.writerow(user_event_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
|
||||
|
||||
# .csv for user gists
|
||||
def logUserGists(gist):
|
||||
user_gist_fields = ['ID', 'Node ID', 'About', 'Comments', 'Files', 'Git Push URL', 'Is public?', 'Is truncated?', 'Updated at']
|
||||
user_gist_row = [gist['id'], gist['node_id'], gist['description'], gist['comments'], gist['files'], gist['git_push_url'], gist['public'], gist['truncated'], gist['updated_at']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{gist['id']}_gists_{gist['owner']['login']}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(user_gist_fields)
|
||||
writecsv.writerow(user_gist_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
|
||||
|
||||
# .csv for user followers
|
||||
def logUserFollowers(follower, username):
|
||||
user_follower_fields = ['Profile photo', 'Username', 'ID', 'Node ID', 'Gravatar ID', 'Account type', 'Is site admin?', 'URL']
|
||||
user_follower_row = [follower['avatar_url'], follower['login'], follower['id'], follower['node_id'], follower['gravatar_id'], follower['type'], follower['site_admin'], follower['html_url']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{follower['login']}_follower_of_{username}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(user_follower_fields)
|
||||
writecsv.writerow(user_follower_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
|
||||
|
||||
# .csv for user following
|
||||
def logUserFollowing(user, username):
|
||||
user_following_fields = ['Profile photo', 'Username', 'ID', 'Node ID', 'Gravatar ID', 'Account type', 'Is site admin?', 'URL']
|
||||
user_following_row = [user['avatar_url'], user['login'], user['id'], user['node_id'], user['gravatar_id'], user['type'], user['site_admin'], user['html_url']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{user['login']}_followed_by_{username}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(user_following_fields)
|
||||
writecsv.writerow(user_following_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
|
||||
|
||||
# .csv for user' subscriptions
|
||||
def logUserSubscriptions(repository, username):
|
||||
user_subscription_fields = [ 'Name','ID', 'About', 'Forks', 'Stars', 'Watchers', 'License', 'Branch', 'Visibility', 'Language(s)', 'Open issues', 'Topics', 'Homepage', 'Clone URL', 'SSH URL', 'Is fork?', 'Is forkable?', 'Is private?', 'Is archived?', 'Is template?', 'Has wiki?', 'Has pages?', 'Has projects?', 'Has issues?', 'Has downloads?', 'Pushed at', 'Created at', 'Updated at']
|
||||
user_subscription_row = [repository['name'], repository['id'], repository['description'], repository['forks'], repository['stargazers_count'], repository['watchers'], repository['license'], repository['default_branch'], repository['visibility'], repository['language'], repository['open_issues'], repository['topics'], repository['homepage'], repository['clone_url'], repository['ssh_url'], repository['fork'], repository['allow_forking'], repository['private'], repository['archived'], repository['is_template'], repository['has_wiki'], repository['has_pages'], repository['has_projects'], repository['has_issues'], repository['has_downloads'], repository['pushed_at'], repository['created_at'], repository['updated_at']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{username}_subscriptions_{repository['name']}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(user_subscription_fields)
|
||||
writecsv.writerow(user_subscription_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
|
||||
|
||||
# .csv for user organizations
|
||||
def logUserOrgs(organization, username):
|
||||
user_org_fields = ['Profile photo', 'Name', 'ID', 'Node ID', 'URL', 'About']
|
||||
user_org_row = [organization['avatar_url'], organization['login'], organization['id'], organization['node_id'], organization['url'], organization['description']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{organization['login']}_{username}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(user_org_fields)
|
||||
writecsv.writerow(user_org_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
|
||||
with open(os.path.join("output", f"{repo_name}_issue_{issue['id']}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(repo_issue_fields)
|
||||
write_csv.writerow(repo_issue_row)
|
||||
|
||||
# Create .csv for user search
|
||||
def logUserSearch(user, query):
|
||||
user_search_fields = ['Profile photo', 'Username', 'ID', 'Node ID', 'Gravatar ID', 'Account type', 'Is site admin?', 'URL']
|
||||
user_search_row = [user['avatar_url'], user['login'], user['id'], user['node_id'], user['gravatar_id'], user['type'], user['site_admin'], user['html_url']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{user['login']}_user_search_result_for_{query}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(user_search_fields)
|
||||
writecsv.writerow(user_search_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
|
||||
|
||||
# Create .csv for repository search
|
||||
def logRepoSearch(repository, query):
|
||||
repo_search_fields = [ 'Name','ID', 'About', 'Forks', 'Stars', 'Watchers', 'License', 'Branch', 'Visibility', 'Language(s)', 'Open issues', 'Topics', 'Homepage', 'Clone URL', 'SSH URL', 'Is fork?', 'Is forkable?', 'Is private?', 'Is archived?', 'Is template?', 'Has wiki?', 'Has pages?', 'Has projects?', 'Has issues?', 'Has downloads?', 'Pushed at', 'Created at', 'Updated at']
|
||||
repo_search_row = [repository['full_name'], repository['id'], repository['description'], repository['forks'], repository['stargazers_count'], repository['watchers'], repository['license'], repository['default_branch'], repository['visibility'], repository['language'], repository['open_issues'], repository['topics'], repository['homepage'], repository['clone_url'], repository['ssh_url'], repository['fork'], repository['allow_forking'], repository['private'], repository['archived'], repository['is_template'], repository['has_wiki'], repository['has_pages'], repository['has_projects'], repository['has_issues'], repository['has_downloads'], repository['pushed_at'], repository['created_at'], repository['updated_at']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{repository['name']}_repository_search_result_for_{query}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(repo_search_fields)
|
||||
writecsv.writerow(repo_search_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
|
||||
|
||||
# Create .csv for topic search
|
||||
def logTopicSearch(topic, query):
|
||||
topic_search_fields = ['Name', 'Score', 'Curated', 'Featured', 'Display name', 'Created by', 'Created at', 'Updated at']
|
||||
topic_search_row = [topic['name'], topic['score'], topic['curated'], topic['featured'], topic['display_name'], topic['created_by'], topic['created_at'], topic['updated_at']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{topic['name']}_topic_search_result_for_{query}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(topic_search_fields)
|
||||
writecsv.writerow(topic_search_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
|
||||
|
||||
# Create .csv for issues search
|
||||
def logIssueSearch(issue, query):
|
||||
issue_search_fields = ['Title', 'ID', 'Node ID', 'Number', 'State', 'Reactions', 'Comments', 'Milestone', 'Assignee', 'Assignees', 'Author association', 'Labels', 'Is locked?', 'Lock reason', 'Closed at', 'Created at', 'Updated at']
|
||||
issue_search_row = [issue['title'], issue['id'], issue['node_id'], issue['number'], issue['state'], issue['reactions'], issue['comments'], issue['milestone'], issue['assignee'], issue['assignees'], issue['author_association'], issue['labels'], issue['locked'], issue['active_lock_reason'], issue['closed_at'], issue['created_at'], issue['updated_at']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{issue['id']}_issue_search_result_for_{query}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(issue_search_fields)
|
||||
writecsv.writerow(issue_search_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
|
||||
|
||||
# Create .csv for commits search
|
||||
def logCommitsSearch(commit, query):
|
||||
commit_search_fields = ['SHA', 'Author', 'Username', 'Email', 'Committer', 'Repository', 'URL', 'Description']
|
||||
commit_search_row = [commit['commit']['tree']['sha'], commit['commit']['author']['name'], commit['author']['login'], commit['commit']['author']['email'], commit['commit']['committer']['name'], commit['repository']['full_name'], commit['html_url'], commit['commit']['message']]
|
||||
xprint(f"\n{SignVar.prompt} {logRoller.askLogCsv}", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
with open(f"output/{commit['commit']['tree']['sha']}_commit_search_result_for_{query}.csv", 'w') as file:
|
||||
writecsv = csv.writer(file)
|
||||
writecsv.writerow(commit_search_fields)
|
||||
writecsv.writerow(commit_search_row)
|
||||
|
||||
logging.info(logRoller.loggedToCsv.format(file.name))
|
||||
xprint(f"{SignVar.positive} {logRoller.loggedToCsv.format(file.name)}")
|
||||
|
||||
else:
|
||||
logging.info(logRoller.loggingSkipped.format(prompt))
|
||||
xprint(f"{SignVar.info} {logRoller.loggingSkipped.format(prompt)}")
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# create .csv for repository releases
|
||||
def log_repo_releases(release, repo_name):
|
||||
repo_release_fields = ['Name', 'ID', 'Node ID', 'Tag', 'Branch', 'Assets', 'Is draft?', 'Is prerelease?',
|
||||
'Created at', 'Published at']
|
||||
repo_release_row = [release['name'], release['id'], release['node_id'], release['tag_name'],
|
||||
release['target_commitish'], release['assets'], release['draft'], release['prerelease'],
|
||||
release['created_at'], release['published_at']]
|
||||
|
||||
with open(os.path.join("output", f"{repo_name}_release_{release['name']}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(repo_release_fields)
|
||||
write_csv.writerow(repo_release_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# Create .csv file for repository contributors
|
||||
def log_repo_contributors(contributor, repo_name):
|
||||
repo_contributor_fields = ['Profile photo', 'Username', 'ID', 'Node ID', 'Gravatar ID', 'Account type',
|
||||
'Is site admin?', 'URL']
|
||||
repo_contributor_row = [contributor['avatar_url'], contributor['login'], contributor['id'], contributor['node_id'],
|
||||
contributor['gravatar_id'], contributor['type'], contributor['site_admin'],
|
||||
contributor['html_url']]
|
||||
|
||||
with open(os.path.join("output", f"{contributor['login']}_contributor_of_{repo_name}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(repo_contributor_fields)
|
||||
write_csv.writerow(repo_contributor_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# Create .csv for organization' events
|
||||
def log_repo_events(event, organization):
|
||||
org_event_fields = ['ID', 'Type', 'Created at', 'Payload']
|
||||
org_event_row = [event['id'], event['type'], event['created_at'], event['payload']]
|
||||
|
||||
with open(os.path.join("output", f"{organization}_event_{event['id']}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(org_event_fields)
|
||||
write_csv.writerow(org_event_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# Create .csv for organization' repositories
|
||||
def log_org_repos(repository, organization):
|
||||
org_repo_fields = ['Name', 'ID', 'About', 'Forks', 'Stars', 'Watchers', 'License', 'Branch', 'Visibility',
|
||||
'Language(s)', 'Open issues', 'Topics', 'Homepage', 'Clone URL', 'SSH URL', 'Is fork?',
|
||||
'Is forkable?', 'Is private?', 'Is archived?', 'Is template?', 'Has wiki?', 'Has pages?',
|
||||
'Has projects?', 'Has issues?', 'Has downloads?', 'Pushed at', 'Created at', 'Updated at']
|
||||
org_repo_row = [repository['full_name'], repository['id'], repository['description'], repository['forks'],
|
||||
repository['stargazers_count'], repository['watchers'], repository['license'],
|
||||
repository['default_branch'], repository['visibility'], repository['language'],
|
||||
repository['open_issues'], repository['topics'], repository['homepage'], repository['clone_url'],
|
||||
repository['ssh_url'], repository['fork'], repository['allow_forking'], repository['private'],
|
||||
repository['archived'], repository['is_template'], repository['has_wiki'], repository['has_pages'],
|
||||
repository['has_projects'], repository['has_issues'], repository['has_downloads'],
|
||||
repository['pushed_at'], repository['created_at'], repository['updated_at']]
|
||||
|
||||
with open(os.path.join("output", f"{repository['name']}_repository_of_{organization}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(org_repo_fields)
|
||||
write_csv.writerow(org_repo_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# .csv for user' repositories
|
||||
def log_user_repos(repository, username):
|
||||
user_repo_fields = ['Name', 'ID', 'About', 'Forks', 'Stars', 'Watchers', 'License', 'Branch', 'Visibility',
|
||||
'Language(s)', 'Open issues', 'Topics', 'Homepage', 'Clone URL', 'SSH URL', 'Is fork?',
|
||||
'Is forkable?', 'Is private?', 'Is archived?', 'Is template?', 'Has wiki?', 'Has pages?',
|
||||
'Has projects?', 'Has issues?', 'Has downloads?', 'Pushed at', 'Created at', 'Updated at']
|
||||
user_repo_row = [repository['full_name'], repository['id'], repository['description'], repository['forks'],
|
||||
repository['stargazers_count'], repository['watchers'], repository['license'],
|
||||
repository['default_branch'], repository['visibility'], repository['language'],
|
||||
repository['open_issues'], repository['topics'], repository['homepage'], repository['clone_url'],
|
||||
repository['ssh_url'], repository['fork'], repository['allow_forking'], repository['private'],
|
||||
repository['archived'], repository['is_template'], repository['has_wiki'], repository['has_pages'],
|
||||
repository['has_projects'], repository['has_issues'], repository['has_downloads'],
|
||||
repository['pushed_at'], repository['created_at'], repository['updated_at']]
|
||||
|
||||
with open(os.path.join("output", f"{repository['name']}_{username}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(user_repo_fields)
|
||||
write_csv.writerow(user_repo_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# .csv for user events
|
||||
def log_user_events(event):
|
||||
user_event_fields = ['Actor', 'Type', 'Repository', 'Created at', 'Payload']
|
||||
user_event_row = [event['actor']['login'], event['type'], event['repo']['name'], event['created_at'],
|
||||
event['payload']]
|
||||
|
||||
with open(os.path.join("output", f"{event['actor']['login']}_event_{event['id']}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(user_event_fields)
|
||||
write_csv.writerow(user_event_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# .csv for user gists
|
||||
def log_user_gists(gist):
|
||||
user_gist_fields = ['ID', 'Node ID', 'About', 'Comments', 'Files', 'Git Push URL', 'Is public?', 'Is truncated?',
|
||||
'Updated at']
|
||||
user_gist_row = [gist['id'], gist['node_id'], gist['description'], gist['comments'], gist['files'],
|
||||
gist['git_push_url'], gist['public'], gist['truncated'], gist['updated_at']]
|
||||
|
||||
with open(os.path.join("output", f"{gist['id']}_gists_{gist['owner']['login']}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(user_gist_fields)
|
||||
write_csv.writerow(user_gist_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# .csv for user followers
|
||||
def log_user_followers(follower, username):
|
||||
user_follower_fields = ['Profile photo', 'Username', 'ID', 'Node ID', 'Gravatar ID', 'Account type',
|
||||
'Is site admin?', 'URL']
|
||||
user_follower_row = [follower['avatar_url'], follower['login'], follower['id'], follower['node_id'],
|
||||
follower['gravatar_id'], follower['type'], follower['site_admin'], follower['html_url']]
|
||||
|
||||
with open(f"output/{follower['login']}_follower_of_{username}.csv", 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(user_follower_fields)
|
||||
write_csv.writerow(user_follower_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# .csv for user following
|
||||
def log_user_following(user, username):
|
||||
user_following_fields = ['Profile photo', 'Username', 'ID', 'Node ID', 'Gravatar ID', 'Account type',
|
||||
'Is site admin?', 'URL']
|
||||
user_following_row = [user['avatar_url'], user['login'], user['id'], user['node_id'], user['gravatar_id'],
|
||||
user['type'], user['site_admin'], user['html_url']]
|
||||
|
||||
with open(os.path.join("output", f"{user['login']}_followed_by_{username}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(user_following_fields)
|
||||
write_csv.writerow(user_following_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# .csv for user' subscriptions
|
||||
def log_user_subscriptions(repository, username):
|
||||
user_subscription_fields = ['Name', 'ID', 'About', 'Forks', 'Stars', 'Watchers', 'License', 'Branch', 'Visibility',
|
||||
'Language(s)', 'Open issues', 'Topics', 'Homepage', 'Clone URL', 'SSH URL', 'Is fork?',
|
||||
'Is forkable?', 'Is private?', 'Is archived?', 'Is template?', 'Has wiki?',
|
||||
'Has pages?', 'Has projects?', 'Has issues?', 'Has downloads?', 'Pushed at',
|
||||
'Created at', 'Updated at']
|
||||
user_subscription_row = [repository['name'], repository['id'], repository['description'], repository['forks'],
|
||||
repository['stargazers_count'], repository['watchers'], repository['license'],
|
||||
repository['default_branch'], repository['visibility'], repository['language'],
|
||||
repository['open_issues'], repository['topics'], repository['homepage'],
|
||||
repository['clone_url'], repository['ssh_url'], repository['fork'],
|
||||
repository['allow_forking'], repository['private'], repository['archived'],
|
||||
repository['is_template'], repository['has_wiki'], repository['has_pages'],
|
||||
repository['has_projects'], repository['has_issues'], repository['has_downloads'],
|
||||
repository['pushed_at'], repository['created_at'], repository['updated_at']]
|
||||
|
||||
with open(os.path.join("output", f"{username}_subscriptions_{repository['name']}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(user_subscription_fields)
|
||||
write_csv.writerow(user_subscription_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# .csv for user organizations
|
||||
def log_user_orgs(organization, username):
|
||||
user_org_fields = ['Profile photo', 'Name', 'ID', 'Node ID', 'URL', 'About']
|
||||
user_org_row = [organization['avatar_url'], organization['login'], organization['id'], organization['node_id'],
|
||||
organization['url'], organization['description']]
|
||||
|
||||
with open(os.path.join("output", f"{organization['login']}_{username}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(user_org_fields)
|
||||
write_csv.writerow(user_org_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# Create .csv for user search
|
||||
def log_users_search(user, query):
|
||||
user_search_fields = ['Profile photo', 'Username', 'ID', 'Node ID', 'Gravatar ID', 'Account type', 'Is site admin?',
|
||||
'URL']
|
||||
user_search_row = [user['avatar_url'], user['login'], user['id'], user['node_id'], user['gravatar_id'],
|
||||
user['type'], user['site_admin'], user['html_url']]
|
||||
|
||||
with open(os.path.join("output", f"{user['login']}_user_search_result_for_{query}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(user_search_fields)
|
||||
write_csv.writerow(user_search_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# Create .csv for repository search
|
||||
def log_repos_search(repository, query):
|
||||
repo_search_fields = ['Name', 'ID', 'About', 'Forks', 'Stars', 'Watchers', 'License', 'Branch', 'Visibility',
|
||||
'Language(s)', 'Open issues', 'Topics', 'Homepage', 'Clone URL', 'SSH URL', 'Is fork?',
|
||||
'Is forkable?', 'Is private?', 'Is archived?', 'Is template?', 'Has wiki?', 'Has pages?',
|
||||
'Has projects?', 'Has issues?', 'Has downloads?', 'Pushed at', 'Created at', 'Updated at']
|
||||
repo_search_row = [repository['full_name'], repository['id'], repository['description'], repository['forks'],
|
||||
repository['stargazers_count'], repository['watchers'], repository['license'],
|
||||
repository['default_branch'], repository['visibility'], repository['language'],
|
||||
repository['open_issues'], repository['topics'], repository['homepage'], repository['clone_url'],
|
||||
repository['ssh_url'], repository['fork'], repository['allow_forking'], repository['private'],
|
||||
repository['archived'], repository['is_template'], repository['has_wiki'],
|
||||
repository['has_pages'], repository['has_projects'], repository['has_issues'],
|
||||
repository['has_downloads'], repository['pushed_at'], repository['created_at'],
|
||||
repository['updated_at']]
|
||||
|
||||
with open(os.path.join("output", f"{repository['name']}_repository_search_result_for_{query}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(repo_search_fields)
|
||||
write_csv.writerow(repo_search_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# Create .csv for topic search
|
||||
def log_topics_search(topic, query):
|
||||
topic_search_fields = ['Name', 'Score', 'Curated', 'Featured', 'Display name', 'Created by', 'Created at',
|
||||
'Updated at']
|
||||
topic_search_row = [topic['name'], topic['score'], topic['curated'], topic['featured'], topic['display_name'],
|
||||
topic['created_by'], topic['created_at'], topic['updated_at']]
|
||||
|
||||
with open(os.path.join("output", f"{topic['name']}_topic_search_result_for_{query}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(topic_search_fields)
|
||||
write_csv.writerow(topic_search_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# Create .csv for issues search
|
||||
def log_issues_search(issue, query):
|
||||
issue_search_fields = ['Title', 'ID', 'Node ID', 'Number', 'State', 'Reactions', 'Comments', 'Milestone',
|
||||
'Assignee', 'Assignees', 'Author association', 'Labels', 'Is locked?', 'Lock reason',
|
||||
'Closed at', 'Created at', 'Updated at']
|
||||
issue_search_row = [issue['title'], issue['id'], issue['node_id'], issue['number'], issue['state'],
|
||||
issue['reactions'], issue['comments'], issue['milestone'], issue['assignee'],
|
||||
issue['assignees'], issue['author_association'], issue['labels'], issue['locked'],
|
||||
issue['active_lock_reason'], issue['closed_at'], issue['created_at'], issue['updated_at']]
|
||||
|
||||
with open(os.path.join("output", f"{issue['id']}_issue_search_result_for_{query}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(issue_search_fields)
|
||||
write_csv.writerow(issue_search_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
|
||||
# Create .csv for commits search
|
||||
def log_commits_search(commit, query):
|
||||
commit_search_fields = ['SHA', 'Author', 'Username', 'Email', 'Committer', 'Repository', 'URL', 'Description']
|
||||
commit_search_row = [commit['commit']['tree']['sha'], commit['commit']['author']['name'], commit['author']['login'],
|
||||
commit['commit']['author']['email'], commit['commit']['committer']['name'],
|
||||
commit['repository']['full_name'], commit['html_url'], commit['commit']['message']]
|
||||
|
||||
with open(os.path.join("output", f"{commit['commit']['tree']['sha']}_commit_search_result_for_{query}.csv"), 'w') as file:
|
||||
write_csv = csv.writer(file)
|
||||
write_csv.writerow(commit_search_fields)
|
||||
write_csv.writerow(commit_search_row)
|
||||
|
||||
logging.info(logged_to_csv.format(file.name))
|
||||
xprint(f"{POSITIVE} {logged_to_csv.format(file.name)}")
|
||||
|
||||
@@ -1,182 +1,170 @@
|
||||
from rich.table import Table
|
||||
from rich import print as xprint
|
||||
from octosuite.colors import white, green, white_bold, green_bold, header_title, reset
|
||||
"""
|
||||
Help
|
||||
This class holds the help text for available commands.
|
||||
"""
|
||||
class Help:
|
||||
usageText = 'Use syntax {} to get started with %s{}%s.' % (green_bold, reset)
|
||||
usageText1 = '%sUse {} to view all available subcommands.%s' % (white, reset)
|
||||
usageText2 = "%sThe {} command works with subcommands. %s" % (white, reset)
|
||||
|
||||
def Org():
|
||||
xprint(Help.usageText2.format(f"{green_bold}org{reset}") + Help.usageText1.format(f"{green_bold}help:org{reset}"))
|
||||
|
||||
|
||||
def Repo():
|
||||
xprint(Help.usageText2.format(f"{green_bold}repo{reset}") + Help.usageText1.format(f"{green_bold}help:repo{reset}"))
|
||||
|
||||
|
||||
def User():
|
||||
xprint(Help.usageText2.format(f"{green_bold}user{reset}") + Help.usageText1.format(f"{green_bold}help:user{reset}"))
|
||||
|
||||
def Search():
|
||||
xprint(Help.usageText2.format(f"{green_bold}search{reset}") + Help.usageText1.format(f"{green_bold}help:search{reset}"))
|
||||
|
||||
|
||||
def Source():
|
||||
xprint(Help.usageText2.format(f"{green_bold}source{reset}") + Help.usageText1.format(f"{green_bold}help:source{reset}"))
|
||||
|
||||
def Logs():
|
||||
xprint(Help.usageText2.format(f"{green_bold}logs{reset}") + Help.usageText1.format(f"{green_bold}help:logs{reset}"))
|
||||
|
||||
|
||||
def Version():
|
||||
xprint(Help.usageText2.format(f"{green_bold}version{reset}") + Help.usageText1.format(f"{green_bold}help:version{reset}"))
|
||||
|
||||
|
||||
def Csv():
|
||||
xprint(Help.usageText2.format(f"{green_bold}csv{reset}") + Help.usageText1.format(f"{green_bold}help:csv{reset}"))
|
||||
|
||||
|
||||
def versionCommand():
|
||||
version_cmd_table =Table(show_header=True, header_style=header_title)
|
||||
version_cmd_table.add_column("Command", style="dim", width=12)
|
||||
version_cmd_table.add_column("Description")
|
||||
version_cmd_table.add_row("check", "Check for new release(s)")
|
||||
version_cmd_table.add_row("info", "Version information")
|
||||
from octosuite.config import Tree, xprint, white, green, white_bold, green_bold, header_title, reset
|
||||
|
||||
syntax = f"{green}version:<command>{reset}"
|
||||
xprint(f"{Help.usageText.format(syntax, 'version management')}")
|
||||
xprint(version_cmd_table)
|
||||
|
||||
|
||||
def sourceCommand():
|
||||
source_cmd_table =Table(show_header=True, header_style=header_title)
|
||||
source_cmd_table.add_column("Command", style="dim", width=12)
|
||||
source_cmd_table.add_column("Description")
|
||||
source_cmd_table.add_row("zipball", "Download source code Zipball")
|
||||
source_cmd_table.add_row("tarball", "Download source code Tarball")
|
||||
|
||||
syntax = f"{green}source:<command>{reset}"
|
||||
xprint(f"{Help.usageText.format(syntax, 'source code downloads')}")
|
||||
xprint(source_cmd_table)
|
||||
|
||||
|
||||
def searchCommand():
|
||||
search_cmd_table =Table(show_header=True, header_style=header_title)
|
||||
search_cmd_table.add_column("Command", style="dim", width=12)
|
||||
search_cmd_table.add_column("Description")
|
||||
search_cmd_table.add_row("users", "Search user(s)")
|
||||
search_cmd_table.add_row("repos", "Search repositor[y][ies]")
|
||||
search_cmd_table.add_row("topics", "Search topic(s)")
|
||||
search_cmd_table.add_row("issues", "Search issue(s)")
|
||||
search_cmd_table.add_row("commits", "Search commit(s)")
|
||||
|
||||
syntax = f"{green}search:<command>{reset}"
|
||||
xprint(f"{Help.usageText.format(syntax, 'target discovery')}")
|
||||
xprint(search_cmd_table)
|
||||
|
||||
|
||||
def userCommand():
|
||||
user_cmd_table =Table(show_header=True, header_style=header_title)
|
||||
user_cmd_table.add_column("Command", style="dim", width=12)
|
||||
user_cmd_table.add_column("Description")
|
||||
user_cmd_table.add_row("profile", "Get a target's profile info")
|
||||
user_cmd_table.add_row("gists", "Return a users's gists")
|
||||
user_cmd_table.add_row("org", "Return organizations that a target belongs to/owns")
|
||||
user_cmd_table.add_row("repos", "Return a target's repositories")
|
||||
user_cmd_table.add_row("events", "Return a target's events")
|
||||
user_cmd_table.add_row("follows", "Check if user(A) follows user(B)")
|
||||
user_cmd_table.add_row("followers", "Return a target's followers")
|
||||
user_cmd_table.add_row("following", "Return a list of users the target is following")
|
||||
user_cmd_table.add_row("subscriptions", "Return a target's subscriptions")
|
||||
|
||||
syntax = f"{green}user:<command>{reset}"
|
||||
xprint(f"{Help.usageText.format(syntax, 'user investigation(s)')}")
|
||||
xprint(user_cmd_table)
|
||||
|
||||
|
||||
def orgCommand():
|
||||
org_cmd_table =Table(show_header=True, header_style=header_title)
|
||||
org_cmd_table.add_column("Command", style="dim", width=12)
|
||||
org_cmd_table.add_column("Description")
|
||||
org_cmd_table.add_row("profile", "Get a target organization' profile info")
|
||||
org_cmd_table.add_row("repos", "Return a target organization' repositories")
|
||||
org_cmd_table.add_row("events", "Return a target organization' events")
|
||||
org_cmd_table.add_row("member", "Check if a specified user is a public member of the target organization")
|
||||
|
||||
syntax = f"{green}org:<command>{reset}"
|
||||
xprint(f"{Help.usageText.format(syntax, 'organization investigation(s)')}")
|
||||
xprint(org_cmd_table)
|
||||
|
||||
|
||||
def repoCommand():
|
||||
repo_cmd_table =Table(show_header=True, header_style=header_title)
|
||||
repo_cmd_table.add_column("Command", style="dim", width=12)
|
||||
repo_cmd_table.add_column("Description")
|
||||
repo_cmd_table.add_row("profile", "Get a repository's info")
|
||||
repo_cmd_table.add_row("issues", "Return a repository's issues")
|
||||
repo_cmd_table.add_row("forks", "Return a repository's forks")
|
||||
repo_cmd_table.add_row("releases", "Return a repository's releases")
|
||||
repo_cmd_table.add_row("stargazers", "Return a repository's stargazers")
|
||||
repo_cmd_table.add_row("path_contents", "List contents in a path of a repository")
|
||||
|
||||
syntax = f"{green}repo:<command>{reset}"
|
||||
xprint(f"{Help.usageText.format(syntax, 'repository investigation(s)')}")
|
||||
xprint(repo_cmd_table)
|
||||
|
||||
|
||||
def logsCommand():
|
||||
logs_cmd_table =Table(show_header=True, header_style=header_title)
|
||||
logs_cmd_table.add_column("Command", style="dim", width=12)
|
||||
logs_cmd_table.add_column("Description")
|
||||
logs_cmd_table.add_row("view", "View logs")
|
||||
logs_cmd_table.add_row("read", "Read log")
|
||||
logs_cmd_table.add_row("delete", "Delete log")
|
||||
|
||||
syntax = f"{green}logs:<command>{reset}"
|
||||
xprint(f"{Help.usageText.format(syntax, 'log(s) management')}")
|
||||
xprint(logs_cmd_table)
|
||||
|
||||
|
||||
def csvCommand():
|
||||
csv_cmd_table =Table(show_header=True, header_style=header_title)
|
||||
csv_cmd_table.add_column("Command", style="dim", width=12)
|
||||
csv_cmd_table.add_column("Description")
|
||||
csv_cmd_table.add_row("view", "View csv files")
|
||||
csv_cmd_table.add_row("read", "Read csv")
|
||||
csv_cmd_table.add_row("delete", "Delete csv")
|
||||
|
||||
syntax = f"{green}csv:<command>{reset}"
|
||||
xprint(f"{Help.usageText.format(syntax, 'csv management')}")
|
||||
xprint(csv_cmd_table)
|
||||
# helper.py
|
||||
# This file holds the help text for available commands.
|
||||
usage_text = 'Use syntax {} to get started with %s{}%s.' % (green_bold, reset)
|
||||
usage_text_1 = '%sUse {} to view all available subcommands.%s' % (white, reset)
|
||||
usage_text_2 = "%sThe {} command works with subcommands. %s" % (white, reset)
|
||||
|
||||
|
||||
def helpCommand():
|
||||
core_cmd_table =Table(show_header=True, header_style=header_title)
|
||||
core_cmd_table.add_column("Command", style="dim", width=12)
|
||||
core_cmd_table.add_column("Description")
|
||||
core_cmd_table.add_row("help", "Help menu")
|
||||
core_cmd_table.add_row("exit", "Close session")
|
||||
core_cmd_table.add_row("clear", "Clear screen")
|
||||
core_cmd_table.add_row("about", "Program's info")
|
||||
core_cmd_table.add_row("author", "Developer's info")
|
||||
|
||||
help_sub_cmd_table =Table(show_header=True, header_style=header_title)
|
||||
help_sub_cmd_table.add_column("Command", style="dim", width=12)
|
||||
help_sub_cmd_table.add_column("Description")
|
||||
help_sub_cmd_table.add_row("csv", "List all csv management commands")
|
||||
help_sub_cmd_table.add_row("logs", "List all logs management commands")
|
||||
help_sub_cmd_table.add_row("org", "List all organization investigation commands")
|
||||
help_sub_cmd_table.add_row("user", "List all users investigation commands")
|
||||
help_sub_cmd_table.add_row("repo", "List all repository investigation commands")
|
||||
help_sub_cmd_table.add_row("search", "List all target discovery commands")
|
||||
help_sub_cmd_table.add_row("source", "List all source code download commands (for developers)")
|
||||
help_sub_cmd_table.add_row("version", "List all version management commands")
|
||||
def org():
|
||||
xprint(usage_text_2.format(f"{green_bold}org{reset}") + usage_text_1.format(f"{green_bold}help:org{reset}"))
|
||||
|
||||
syntax = f"{green}help:<command>{reset}"
|
||||
xprint(core_cmd_table)
|
||||
xprint(f"\n\n{Help.usageText.format(syntax, 'octosuite')}")
|
||||
xprint(help_sub_cmd_table)
|
||||
|
||||
def repo():
|
||||
xprint(usage_text_2.format(f"{green_bold}repo{reset}") + usage_text_1.format(f"{green_bold}help:repo{reset}"))
|
||||
|
||||
|
||||
def user():
|
||||
xprint(usage_text_2.format(f"{green_bold}user{reset}") + usage_text_1.format(f"{green_bold}help:user{reset}"))
|
||||
|
||||
|
||||
def search():
|
||||
xprint(usage_text_2.format(f"{green_bold}search{reset}") + usage_text_1.format(f"{green_bold}help:search{reset}"))
|
||||
|
||||
|
||||
def source():
|
||||
xprint(usage_text_2.format(f"{green_bold}source{reset}") + usage_text_1.format(f"{green_bold}help:source{reset}"))
|
||||
|
||||
|
||||
def logs():
|
||||
xprint(usage_text_2.format(f"{green_bold}logs{reset}") + usage_text_1.format(f"{green_bold}help:logs{reset}"))
|
||||
|
||||
|
||||
def csv():
|
||||
xprint(usage_text_2.format(f"{green_bold}csv{reset}") + usage_text_1.format(f"{green_bold}help:csv{reset}"))
|
||||
|
||||
|
||||
def source_command():
|
||||
source_cmd_table = Table(show_header=True, header_style=header_title)
|
||||
source_cmd_table.add_column("Command", style="dim")
|
||||
source_cmd_table.add_column("Description")
|
||||
source_cmd_table.add_row("zipball", "Download source code Zipball")
|
||||
source_cmd_table.add_row("tarball", "Download source code Tarball")
|
||||
|
||||
syntax = f"{green}source:<command>{reset}"
|
||||
xprint(f"{usage_text.format(syntax, 'source code downloads')}")
|
||||
xprint(source_cmd_table)
|
||||
|
||||
|
||||
def search_command():
|
||||
search_cmd_table = Table(show_header=True, header_style=header_title)
|
||||
search_cmd_table.add_column("Command", style="dim")
|
||||
search_cmd_table.add_column("Description")
|
||||
search_cmd_table.add_row("users", "Search user(s)")
|
||||
search_cmd_table.add_row("repos", "Search repositor[y][ies]")
|
||||
search_cmd_table.add_row("topics", "Search topic(s)")
|
||||
search_cmd_table.add_row("issues", "Search issue(s)")
|
||||
search_cmd_table.add_row("commits", "Search commit(s)")
|
||||
|
||||
syntax = f"{green}search:<command>{reset}"
|
||||
xprint(f"{usage_text.format(syntax, 'target discovery')}")
|
||||
xprint(search_cmd_table)
|
||||
|
||||
|
||||
def user_command():
|
||||
user_cmd_table = Table(show_header=True, header_style=header_title)
|
||||
user_cmd_table.add_column("Command", style="dim")
|
||||
user_cmd_table.add_column("Description")
|
||||
user_cmd_table.add_row("profile", "Get a target's profile info")
|
||||
user_cmd_table.add_row("gists", "Return a users's gists")
|
||||
user_cmd_table.add_row("org", "Return organizations that a target belongs to/owns")
|
||||
user_cmd_table.add_row("repos", "Return a target's repositories")
|
||||
user_cmd_table.add_row("events", "Return a target's events")
|
||||
user_cmd_table.add_row("follows", "Check if user(A) follows user(B)")
|
||||
user_cmd_table.add_row("followers", "Return a target's followers")
|
||||
user_cmd_table.add_row("following", "Return a list of users the target is following")
|
||||
user_cmd_table.add_row("subscriptions", "Return a target's subscriptions")
|
||||
|
||||
syntax = f"{green}user:<command>{reset}"
|
||||
xprint(f"{usage_text.format(syntax, 'user investigation(s)')}")
|
||||
xprint(user_cmd_table)
|
||||
|
||||
|
||||
def org_command():
|
||||
org_cmd_table = Table(show_header=True, header_style=header_title)
|
||||
org_cmd_table.add_column("Command", style="dim")
|
||||
org_cmd_table.add_column("Description")
|
||||
org_cmd_table.add_row("profile", "Get a target organization' profile info")
|
||||
org_cmd_table.add_row("repos", "Return a target organization' repositories")
|
||||
org_cmd_table.add_row("events", "Return a target organization' events")
|
||||
org_cmd_table.add_row("member", "Check if a specified user is a public member of the target organization")
|
||||
|
||||
syntax = f"{green}org:<command>{reset}"
|
||||
xprint(f"{usage_text.format(syntax, 'organization investigation(s)')}")
|
||||
xprint(org_cmd_table)
|
||||
|
||||
|
||||
def repo_command():
|
||||
repo_cmd_table = Table(show_header=True, header_style=header_title)
|
||||
repo_cmd_table.add_column("Command", style="dim")
|
||||
repo_cmd_table.add_column("Description")
|
||||
repo_cmd_table.add_row("profile", "Get a repository's info")
|
||||
repo_cmd_table.add_row("issues", "Return a repository's issues")
|
||||
repo_cmd_table.add_row("forks", "Return a repository's forks")
|
||||
repo_cmd_table.add_row("releases", "Return a repository's releases")
|
||||
repo_cmd_table.add_row("stargazers", "Return a repository's stargazers")
|
||||
repo_cmd_table.add_row("contributors", "Return a repository's contributors")
|
||||
repo_cmd_table.add_row("path_contents", "List contents in a path of a repository")
|
||||
|
||||
syntax = f"{green}repo:<command>{reset}"
|
||||
xprint(f"{usage_text.format(syntax, 'repository investigation(s)')}")
|
||||
xprint(repo_cmd_table)
|
||||
|
||||
|
||||
def logs_command():
|
||||
logs_cmd_table = Table(show_header=True, header_style=header_title)
|
||||
logs_cmd_table.add_column("Command", style="dim")
|
||||
logs_cmd_table.add_column("Description")
|
||||
logs_cmd_table.add_row("view", "View logs")
|
||||
logs_cmd_table.add_row("read", "Read log")
|
||||
logs_cmd_table.add_row("delete", "Delete log")
|
||||
logs_cmd_table.add_row("clear", "clear logs")
|
||||
|
||||
syntax = f"{green}logs:<command>{reset}"
|
||||
xprint(f"{usage_text.format(syntax, 'log(s) management')}")
|
||||
xprint(logs_cmd_table)
|
||||
|
||||
|
||||
def csv_command():
|
||||
csv_cmd_table = Table(show_header=True, header_style=header_title)
|
||||
csv_cmd_table.add_column("Command", style="dim")
|
||||
csv_cmd_table.add_column("Description")
|
||||
csv_cmd_table.add_row("view", "View csv files")
|
||||
csv_cmd_table.add_row("read", "Read csv")
|
||||
csv_cmd_table.add_row("delete", "Delete csv")
|
||||
csv_cmd_table.add_row("clear", "clear csv files")
|
||||
|
||||
syntax = f"{green}csv:<command>{reset}"
|
||||
xprint(f"{usage_text.format(syntax, 'csv management')}")
|
||||
xprint(csv_cmd_table)
|
||||
|
||||
|
||||
def help_command():
|
||||
core_cmd_table = Table(show_header=True, header_style=header_title)
|
||||
core_cmd_table.add_column("Command", style="dim", width=12)
|
||||
core_cmd_table.add_column("Description")
|
||||
core_cmd_table.add_row("ls", "List contents of the specified directory")
|
||||
core_cmd_table.add_row("cd", "Move to specified directory")
|
||||
core_cmd_table.add_row("help", "Help menu")
|
||||
core_cmd_table.add_row("exit", "Close session")
|
||||
core_cmd_table.add_row("clear", "Clear screen")
|
||||
core_cmd_table.add_row("about", "Program's info")
|
||||
core_cmd_table.add_row("author", "Developer's info")
|
||||
|
||||
help_sub_cmd_table = Table(show_header=True, header_style=header_title)
|
||||
help_sub_cmd_table.add_column("Command", style="dim", width=12)
|
||||
help_sub_cmd_table.add_column("Description")
|
||||
help_sub_cmd_table.add_row("csv", "List all csv management commands")
|
||||
help_sub_cmd_table.add_row("logs", "List all logs management commands")
|
||||
help_sub_cmd_table.add_row("org", "List all organization investigation commands")
|
||||
help_sub_cmd_table.add_row("user", "List all users investigation commands")
|
||||
help_sub_cmd_table.add_row("repo", "List all repository investigation commands")
|
||||
help_sub_cmd_table.add_row("search", "List all target discovery commands")
|
||||
help_sub_cmd_table.add_row("source", "List all source code download commands (for developers)")
|
||||
|
||||
syntax = f"{green}help:<command>{reset}"
|
||||
xprint(core_cmd_table)
|
||||
xprint(f"\n\n{usage_text.format(syntax, 'octosuite')}")
|
||||
xprint(help_sub_cmd_table)
|
||||
|
||||
@@ -1,27 +1,21 @@
|
||||
"""
|
||||
logRoller
|
||||
This class is where the main notification strings/messages are held,
|
||||
and are being used in two different cases (they're beig used by logging to be written to log files, and being printed out to the screen).
|
||||
"""
|
||||
class logRoller:
|
||||
Ctrl = "Session terminated with {}."
|
||||
Error = "An error occurred: {}"
|
||||
sessionOpened = "Opened new session on {}:{}"
|
||||
sessionClosed = "Session closed at {}."
|
||||
viewingLogs = "Viewing logs..."
|
||||
viewingCsv = "Viewing CSV file(s)..."
|
||||
deletedLog = "Deleted log -> {}"
|
||||
readingLog = "Reading log -> {}"
|
||||
readingCsv = 'Reading csv -> {}'
|
||||
deletedCsv = 'Deleted csv -> {}'
|
||||
fileDownloading = "Downloading -> {}..."
|
||||
fileDownloaded = "Downloaded -> downloads/{}"
|
||||
infoNotFound = "Information not found -> ({} - {} - {})"
|
||||
repoNotFound = "Repository not found -> ({})"
|
||||
userNotFound = "User not found -> (@{})"
|
||||
orgNotFound = "Organization not found -> (@{})"
|
||||
repoOrUserNotFound = "Repository or user not found -> ({} - @{})"
|
||||
askLogCsv = "Do you wish to log this output to a .csv file? (Y/n) "
|
||||
loggedToCsv = "Output logged -> ({})"
|
||||
loggingSkipped = "Logging skipped -> ({})"
|
||||
limitInput = "Limit '{}' output to how many? (1-100) "
|
||||
# LogRoller This class is where the main notification strings/messages are held, and are being used in two different
|
||||
# cases (they're being used by logging to be written to log files, and being printed out to the screen).
|
||||
|
||||
|
||||
ctrl_c = "Session terminated with Ctrl+C."
|
||||
error = "An error occurred: {}"
|
||||
session_opened = "Opened new session on {}:{}"
|
||||
session_closed = "Session closed at {}."
|
||||
viewing_logs = "Viewing logs"
|
||||
viewing_csv = "Viewing CSV file(s)..."
|
||||
deleted = "Deleted: {}"
|
||||
reading = "Reading: {}"
|
||||
file_downloading = "Downloading: {}"
|
||||
file_downloaded = "Downloaded: downloads/{}"
|
||||
info_not_found = "Information not found: {}, {}, {}"
|
||||
user_not_found = "User not found: @{}"
|
||||
org_not_found = "Organization not found: @{}"
|
||||
repo_or_user_not_found = "Repository or User not found: {}, @{}"
|
||||
prompt_log_csv = "Would you like to log this output to a .csv file?"
|
||||
logged_to_csv = "Output logged: {}"
|
||||
limit_output = "Limit '{}' output to how many? (1-100)"
|
||||
|
||||
@@ -1,919 +1,52 @@
|
||||
#!usr/bin/python
|
||||
|
||||
import os
|
||||
import csv
|
||||
import sys
|
||||
import json
|
||||
import logging
|
||||
import getpass
|
||||
import requests
|
||||
import platform
|
||||
import subprocess
|
||||
from rich.table import Table
|
||||
from datetime import datetime
|
||||
from rich import print as xprint
|
||||
from octosuite.helper import Help
|
||||
from octosuite.sign_vars import SignVar
|
||||
from octosuite.log_roller import logRoller
|
||||
from octosuite.csv_loggers import csvLogger
|
||||
from octosuite.banner import name_logo, version_tag
|
||||
from octosuite.colors import red, white, green, red_bold, white_bold, green_bold, header_title, reset
|
||||
# import everything from the octosuite.py file
|
||||
from octosuite.octosuite import * # I drifted away from the 'pythonic way' here
|
||||
|
||||
|
||||
# API endpoint
|
||||
endpoint = 'https://api.github.com'
|
||||
# Path attribute
|
||||
path_attrs =['size','type','path','sha','html_url']
|
||||
# Path attribute dictionary
|
||||
path_attr_dict = {'size': 'Size (bytes)',
|
||||
'type': 'Type',
|
||||
'path': 'Path',
|
||||
'sha': 'SHA',
|
||||
'html_url': 'URL'}
|
||||
|
||||
|
||||
# Organization attributes
|
||||
org_attrs = ['avatar_url','login','id','node_id','email','description','blog','location','followers','following','twitter_username','public_gists','public_repos','type','is_verified','has_organization_projects','has_repository_projects','created_at','updated_at']
|
||||
# Organization attribute dictionary
|
||||
org_attr_dict = {'avatar_url': 'Profile Photo',
|
||||
'login': 'Username',
|
||||
'id': 'ID',
|
||||
'node_id': 'Node ID',
|
||||
'email': 'Email',
|
||||
'description': 'About',
|
||||
'location': 'Location',
|
||||
'blog': 'Blog',
|
||||
'followers': 'Followers',
|
||||
'following': 'Following',
|
||||
'twitter_username': 'Twitter handle',
|
||||
'public_gists': 'Gists',
|
||||
'public_repos': 'Repositories',
|
||||
'type': 'Account type',
|
||||
'is_verified': 'Is verified?',
|
||||
'has_organization_projects': 'Has organization projects?',
|
||||
'has_repository_projects': 'Has repository projects?',
|
||||
'created_at': 'Created at',
|
||||
'updated_at': 'Updated at'}
|
||||
|
||||
|
||||
# Repository attributes
|
||||
repo_attrs = ['id','description','forks','stargazers_count','watchers','license','default_branch','visibility','language','open_issues','topics','homepage','clone_url','ssh_url','fork','allow_forking','private','archived','has_downloads','has_issues','has_pages','has_projects','has_wiki','pushed_at','created_at','updated_at']
|
||||
# Repository attribute dictionary
|
||||
repo_attr_dict = {'id': 'ID',
|
||||
'description': 'About',
|
||||
'forks': 'Forks',
|
||||
'stargazers_count': 'Stars',
|
||||
'watchers': 'Watchers',
|
||||
'license': 'License',
|
||||
'default_branch': 'Branch',
|
||||
'visibility': 'Visibility',
|
||||
'language': 'Language(s)',
|
||||
'open_issues': 'Open issues',
|
||||
'topics': 'Topics',
|
||||
'homepage': 'Homepage',
|
||||
'clone_url': 'Clone URL',
|
||||
'ssh_url': 'SSH URL',
|
||||
'fork': 'Is fork?',
|
||||
'allow_forking': 'Is forkable?',
|
||||
'private': 'Is private?',
|
||||
'archived': 'Is archived?',
|
||||
'is_template': 'Is template?',
|
||||
'has_wiki': 'Has wiki?',
|
||||
'has_pages': 'Has pages?',
|
||||
'has_projects': 'Has projects?',
|
||||
'has_issues': 'Has issues?',
|
||||
'has_downloads': 'Has downloads?',
|
||||
'pushed_at': 'Pushed at',
|
||||
'created_at': 'Created at',
|
||||
'updated_at': 'Updated at'}
|
||||
|
||||
|
||||
# Repo releases attributes
|
||||
repo_releases_attrs = ['id', 'node_id','tag_name','target_commitish','assets','draft','prerelease','created_at','published_at']
|
||||
# Repo releases attribute dictionary
|
||||
repo_releases_attr_dict = {'id': 'ID',
|
||||
'node_id': 'Node ID',
|
||||
'tag_name': 'Tag',
|
||||
'target_commitish': 'Branch',
|
||||
'assets': 'Assets',
|
||||
'draft': 'Is draft?',
|
||||
'prerelease': 'Is prerelease?',
|
||||
'created_at': 'Created at',
|
||||
'published_at': 'Published at'}
|
||||
|
||||
|
||||
# Profile attributes
|
||||
profile_attrs = ['avatar_url','login','id','node_id','bio','blog','location','followers','following','twitter_username','public_gists','public_repos','company','hireable','site_admin','created_at','updated_at']
|
||||
# Profile attribute dictionary
|
||||
profile_attr_dict = {'avatar_url': 'Profile Photo',
|
||||
'login': 'Username',
|
||||
'id': 'ID',
|
||||
'node_id': 'Node ID',
|
||||
'bio': 'Bio',
|
||||
'blog': 'Blog',
|
||||
'location': 'Location',
|
||||
'followers': 'Followers',
|
||||
'following': 'Following',
|
||||
'twitter_username': 'Twitter Handle',
|
||||
'public_gists': 'Gists (public)',
|
||||
'public_repos': 'Repositories (public)',
|
||||
'company': 'Organization',
|
||||
'hireable': 'Is hireable?',
|
||||
'site_admin': 'Is site admin?',
|
||||
'created_at': 'Joined at',
|
||||
'updated_at': 'Updated at'}
|
||||
|
||||
|
||||
# User attributes
|
||||
user_attrs = ['avatar_url','id','node_id','gravatar_id','site_admin','type','html_url']
|
||||
# User attribute dictionary
|
||||
user_attr_dict = {'avatar_url': 'Profile Photo',
|
||||
'id': 'ID',
|
||||
'node_id': 'Node ID',
|
||||
'gravatar_id': 'Gravatar ID',
|
||||
'site_admin': 'Is site admin?',
|
||||
'type': 'Account type',
|
||||
'html_url': 'URL'}
|
||||
|
||||
|
||||
# Topic atrributes
|
||||
topic_attrs = ['score','curated','featured','display_name','created_by','created_at','updated_at']
|
||||
# Topic attribute dictionary
|
||||
topic_attr_dict = {'score': 'Score',
|
||||
'curated': 'Curated',
|
||||
'featured': 'Featured',
|
||||
'display_name': 'Display name',
|
||||
'created_by': 'Created by',
|
||||
'created_at': 'Created at',
|
||||
'updated_at': 'Updated at'}
|
||||
|
||||
|
||||
# Gists attributes
|
||||
gists_attrs = ['node_id','description','comments','files','git_push_url','public','truncated','updated_at']
|
||||
# Gists attribute dictionary
|
||||
gists_attr_dict = {'node_id': 'Node ID',
|
||||
'description': 'About',
|
||||
'comments': 'Comments',
|
||||
'files': 'Files',
|
||||
'git_push_url': 'Git Push URL',
|
||||
'public': 'Is public?',
|
||||
'truncated': 'Is truncated?',
|
||||
'updated_at': 'Updated at'}
|
||||
|
||||
|
||||
# Issue attributes
|
||||
issue_attrs = ['id','node_id','score','state','number','comments','milestone','assignee','assignees','labels','locked','draft','closed_at']
|
||||
# Issue attribute dict
|
||||
issue_attr_dict = {'id': 'ID',
|
||||
'node_id': 'Node ID',
|
||||
'score': 'Score',
|
||||
'state': 'State',
|
||||
'closed_at': 'Closed at',
|
||||
'number': 'Number',
|
||||
'comments': 'Comments',
|
||||
'milestone': 'Milestone',
|
||||
'assignee': 'Assignee',
|
||||
'assignees': 'Assignees',
|
||||
'labels': 'Labels',
|
||||
'draft': 'Is draft?',
|
||||
'locked': 'Is locked?',
|
||||
'created_at': 'Created at'}
|
||||
|
||||
|
||||
# Repo issues attributes
|
||||
repo_issues_attrs = ['id','node_id','state', 'reactions','number','comments','milestone','assignee','active_lock_reason', 'author_association','assignees','labels','locked','closed_at','created_at','updated_at']
|
||||
# Issue attribute dict
|
||||
repo_issues_attr_dict = {'id': 'ID',
|
||||
'node_id': 'Node ID',
|
||||
'number': 'Number',
|
||||
'state': 'State',
|
||||
'reactions': 'Reactions',
|
||||
'comments': 'Comments',
|
||||
'milestone': 'Milestone',
|
||||
'assignee': 'Assignee',
|
||||
'assignees': 'Assignees',
|
||||
'author_association': 'Author association',
|
||||
'labels': 'Labels',
|
||||
'locked': 'Is locked?',
|
||||
'active_lock_reason': 'Lock reason',
|
||||
'closed_at': 'Closed at',
|
||||
'created_at': 'Created at',
|
||||
'updated_at': 'Updated at'}
|
||||
|
||||
|
||||
# User organizations attributes
|
||||
user_orgs_attrs = ['avatar_url','id','node_id','url','description']
|
||||
user_orgs_attr_dict = {'avatar_url': 'Profile Photo',
|
||||
'id': 'ID',
|
||||
'node_id': 'Node ID',
|
||||
'url': 'URL',
|
||||
'description': 'About'}
|
||||
|
||||
|
||||
# Author dictionary
|
||||
author_dict = {'Alias': 'rly0nheart',
|
||||
'Country': ':zambia: Zambia, Africa',
|
||||
'About.me': 'https://about.me/rly0nheart',
|
||||
'Buy Me A Coffee': 'https://buymeacoffee.com/189381184'}
|
||||
|
||||
|
||||
'''
|
||||
pathFinder()
|
||||
This function is responsible for creating/checking the availability of the (.logs, output, downloads) folders,
|
||||
enabling logging to automatically log network/user activity to a file,
|
||||
and logging the start of a session.
|
||||
'''
|
||||
def pathFinder():
|
||||
'''
|
||||
Here we create/check 3 directories (.logs, output, downloads) on startup
|
||||
If they exists, we ignore, otherwise, we create them
|
||||
'''
|
||||
directory_list = ['.logs', 'output', 'downloads']
|
||||
for directory in directory_list:
|
||||
os.makedirs(directory, exist_ok=True)
|
||||
|
||||
'''
|
||||
Configure logging to log activities to a file, which will be named by the date and time a session was opened.
|
||||
'''
|
||||
now = datetime.now()
|
||||
now_formatted = now.strftime("%Y-%m-%d %H:%M:%S%p")
|
||||
logging.basicConfig(filename=f".logs/{now_formatted}.log", format="[%(asctime)s] [%(levelname)s] %(message)s", datefmt="%Y-%m-%d %H:%M:%S%p", level=logging.DEBUG)
|
||||
# Log the start of a session
|
||||
logging.info(logRoller.sessionOpened.format(platform.node(), getpass.getuser()))
|
||||
|
||||
|
||||
'''
|
||||
onStart()
|
||||
This is the main function, responsible for mapping commands, calling other functions, and catching exceptions
|
||||
'''
|
||||
def onStart():
|
||||
pathFinder()
|
||||
# A list of tuples mapping commands to their functions
|
||||
command_map = [("exit", exitSession),
|
||||
("clear",clearScreen),
|
||||
("about", about),
|
||||
("author", author),
|
||||
("help", Help.helpCommand),
|
||||
("help:version", Help.versionCommand),
|
||||
("help:source", Help.sourceCommand),
|
||||
("help:search", Help.searchCommand),
|
||||
("help:user", Help.userCommand),
|
||||
("help:repo", Help.repoCommand),
|
||||
("help:logs", Help.logsCommand),
|
||||
("help:csv", Help.csvCommand),
|
||||
("help:org", Help.orgCommand),
|
||||
("version", Help.Version),
|
||||
("version:info", versionInfo),
|
||||
("version:check", versionCheck),
|
||||
("source", Help.Source),
|
||||
("source:tarball", downloadTarball),
|
||||
("source:zipball", downloadZipball),
|
||||
("org", Help.Org),
|
||||
("org:events", orgEvents),
|
||||
("org:profile", orgProfile),
|
||||
("org:repos", orgRepos),
|
||||
("org:member", orgMember),
|
||||
("repo", Help.Repo),
|
||||
("repo:path_contents", pathContents),
|
||||
("repo:profile", repoProfile),
|
||||
("repo:contributors", repoContributors),
|
||||
("repo:stargazers", repoStargazers),
|
||||
("repo:forks", repoForks),
|
||||
("repo:issues", repoIssues),
|
||||
("repo:releases", repoReleases),
|
||||
("user", Help.User),
|
||||
("user:repos", userRepos),
|
||||
("user:gists", userGists),
|
||||
("user:orgs", userOrgs),
|
||||
("user:profile", userProfile),
|
||||
("user:events", userEvents),
|
||||
("user:followers", userFollowers),
|
||||
("user:follows", userFollows),
|
||||
("user:following", userFollowing),
|
||||
("user:subscriptions", userSubscriptions),
|
||||
("search", Help.Search),
|
||||
("search:users", userSearch),
|
||||
("search:repos", repoSearch),
|
||||
("search:topics", topicSearch),
|
||||
("search:issues", issueSearch),
|
||||
("search:commits", commitsSearch),
|
||||
("logs", Help.Logs),
|
||||
("logs:view",viewLogs),
|
||||
("logs:read",readLog),
|
||||
("logs:delete",deleteLog),
|
||||
("csv", Help.Csv),
|
||||
("csv:view", viewCsv),
|
||||
("csv:read", readCsv),
|
||||
("csv:delete", deleteCsv)]
|
||||
|
||||
|
||||
xprint(name_logo)
|
||||
'''
|
||||
Main loop keeps octosuite running, this will break if Octosuite detects a KeyboardInterrupt (Ctrl+C)
|
||||
or if the 'exit' command is entered.
|
||||
'''
|
||||
while True:
|
||||
try:
|
||||
xprint(f"{white}┌──({red}{getpass.getuser()}{white}@{red}octosuite{white})\n├──[~{green}{os.getcwd()}{white}]\n└╼ {reset}", end="");command_input = input().lower()
|
||||
print("\n")
|
||||
'''
|
||||
Iterating over the command_map and check if the user input matches any command in it [command_map],
|
||||
if there's a match, we return its function. If no match is found, we ignore it.
|
||||
'''
|
||||
for command, function in command_map:
|
||||
if command_input == command:
|
||||
function()
|
||||
def octosuite():
|
||||
try:
|
||||
run = Octosuite()
|
||||
path_finder()
|
||||
configure_logging()
|
||||
check_updates()
|
||||
if args.method:
|
||||
"""
|
||||
Iterate over the argument_map and check if the passed command line argument matches any argument in it [argument_map],
|
||||
if there's a match, we return its method. If no match is found, we do nothing (which will return the usage).
|
||||
"""
|
||||
for argument, method in run.argument_map:
|
||||
if args.method == argument:
|
||||
method()
|
||||
print("\n")
|
||||
else:
|
||||
pass
|
||||
else:
|
||||
"""
|
||||
Main loop keeps octosuite running, this will break if Octosuite detects a KeyboardInterrupt (Ctrl+C)
|
||||
or if the 'exit' command is entered.
|
||||
"""
|
||||
xprint(banner()[0], banner()[1])
|
||||
while True:
|
||||
command_input = Prompt.ask(f"{white}┌──({red}{getpass.getuser()}{white}@{red}octosuite{white})\n├──[~{green}{os.getcwd()}{white}]\n└╼{reset}")
|
||||
"""
|
||||
Iterate over the command_map and check if the user input matches any command in it [command_map],
|
||||
if there's a match, we return its method. If no match is found, we ignore it.
|
||||
"""
|
||||
if command_input[:2] == 'cd':
|
||||
os.chdir(command_input[3:])
|
||||
elif command_input[:2] == 'ls':
|
||||
os.system(f'dir {command_input[3:]}' if os.name == 'nt' else f'ls {command_input[3:]}')
|
||||
else:
|
||||
for command, method in run.command_map:
|
||||
if command_input == command:
|
||||
method()
|
||||
print("\n")
|
||||
else:
|
||||
pass
|
||||
|
||||
# This catches the KeyboardInterrupt exception (Ctrl+C)
|
||||
except KeyboardInterrupt:
|
||||
logging.warning(logRoller.Ctrl.format("Ctrl+C"))
|
||||
xprint(f"{SignVar.warning} {logRoller.Ctrl.format('Ctrl+C')}")
|
||||
break
|
||||
|
||||
# This initially catches all exceptions (except the KeyboardInterrupt)
|
||||
except Exception as e:
|
||||
logging.error(logRoller.Error.format(e))
|
||||
xprint(f"{SignVar.error} {logRoller.Error.format(e)}")
|
||||
|
||||
|
||||
# Fetching organization info
|
||||
def orgProfile():
|
||||
xprint(f"{white}>> @{green}Organization {white}(username){reset} ", end="");organization = input()
|
||||
response = requests.get(f"{endpoint}/orgs/{organization}")
|
||||
if response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.orgNotFound.format(organization)}")
|
||||
elif response.status_code == 200:
|
||||
xprint(f"\n{white}{response.json()['name']}{reset}")
|
||||
for attr in org_attrs:
|
||||
xprint(f"{white}├─ {org_attr_dict[attr]}:{reset} {response.json()[attr]}")
|
||||
csvLogger.logOrgProfile(response)
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
# Fetching user information
|
||||
def userProfile():
|
||||
xprint(f"{white}>> @{green}Username{reset} ", end="");username = input()
|
||||
response = requests.get(f"{endpoint}/users/{username}")
|
||||
if response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.userNotFound.format(username)}")
|
||||
elif response.status_code == 200:
|
||||
xprint(f"\n{white}{response.json()['name']}{reset}")
|
||||
for attr in profile_attrs:
|
||||
xprint(f"{white}├─ {profile_attr_dict[attr]}:{reset} {response.json()[attr]}")
|
||||
csvLogger.logUserProfile(response)
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
# Fetching repository information
|
||||
def repoProfile():
|
||||
xprint(f"{white}>> %{green}Repository{reset} ", end="");repo_name = input()
|
||||
xprint(f"{white}>> @{green}Owner{white} (username) ", end="");username = input()
|
||||
response = requests.get(f"{endpoint}/repos/{username}/{repo_name}")
|
||||
if response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.repoOrUserNotFound.format(repo_name, username)}")
|
||||
elif response.status_code == 200:
|
||||
xprint(f"\n{white}{response.json()['full_name']}{reset}")
|
||||
for attr in repo_attrs:
|
||||
xprint(f"{white}├─ {repo_attr_dict[attr]}:{reset} {response.json()[attr]}")
|
||||
csvLogger.logRepoProfile(response)
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
# Get path contents
|
||||
def pathContents():
|
||||
xprint(f"{white}>> %{green}Repository{reset} ", end="");repo_name = input()
|
||||
xprint(f"{white}>> @{green}Owner{white} (username) ", end="");username = input()
|
||||
xprint(f"{white}>> ~{green}/path/name{reset} ", end="");path_name = input()
|
||||
response = requests.get(f"{endpoint}/repos/{username}/{repo_name}/contents/{path_name}")
|
||||
if response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.infoNotFound.format(repo_name, username, path_name)}")
|
||||
elif response.status_code == 200:
|
||||
content_count = 0
|
||||
for content in response.json():
|
||||
content_count += 1
|
||||
xprint(f"\n{white}{content['name']}{reset}")
|
||||
for attr in path_attrs:
|
||||
xprint(f"{white}├─ {path_attr_dict[attr]}:{reset} {content[attr]}")
|
||||
csvLogger.logRepoPathContents(content, repo_name)
|
||||
xprint(SignVar.info, f"Found {content_count} file(s) in {repo_name}/{path_name}.")
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
# repo contributors
|
||||
def repoContributors():
|
||||
xprint(f"{white}>> %{green}Repository{reset} ", end="");repo_name = input()
|
||||
xprint(f"{white}>> @{green}Owner{white} (username) ", end="");username = input()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("contributors"), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/repos/{username}/{repo_name}/contributors?per_page={limit}")
|
||||
if response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.repoOrUserNotFound.format(repo_name, username)}")
|
||||
elif response.status_code == 200:
|
||||
for contributor in response.json():
|
||||
xprint(f"\n{white}{contributor['login']}{reset}")
|
||||
for attr in user_attrs:
|
||||
xprint(f"{white}├─ {user_attr_dict[attr]}:{reset} {contributor[attr]}")
|
||||
csvLogger.logRepoContributors(contributor, repo_name)
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
# repo stargazers
|
||||
def repoStargazers():
|
||||
xprint(f"{white}>> %{green}Repository{reset} ");repo_name = input()
|
||||
xprint(f"{white}>> @{green}Owner{white} (username){reset} ", end="");username = input()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("repository stargazers"), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/repos/{username}/{repo_name}/stargazers?per_page={limit}")
|
||||
if response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.repoOrUserNotFound.format(repo_name, username)}")
|
||||
elif response.json() == {}:
|
||||
xprint(f"{SignVar.negative} Repository does not have any stargazers -> ({repo_name})")
|
||||
elif response.status_code == 200:
|
||||
for stargazer in response.json():
|
||||
xprint(f"\n{white}{stargazer['login']}{reset}")
|
||||
for attr in user_attrs:
|
||||
xprint(f"{white}├─ {user_attr_dict[attr]}:{reset} {stargazer[attr]}")
|
||||
csvLogger.logRepoStargazers(stargazer, repo_name)
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
# repo forks
|
||||
def repoForks():
|
||||
xprint(f"{white}>> %{green}Repository{reset} ", end="");repo_name = input()
|
||||
xprint(f"{white}>> @{green}Owner{white} (username){reset} ", end="");username = input()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("repository forks"), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/repos/{username}/{repo_name}/forks?per_page={limit}")
|
||||
if response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.repoOrUserNotFound.format(repo_name, username)}")
|
||||
elif response.json() == {}:
|
||||
xprint(f"{SignVar.negative} Repository does not have forks -> ({repo_name})")
|
||||
elif response.status_code == 200:
|
||||
count = 0
|
||||
for fork in response.json():
|
||||
count += 1
|
||||
xprint(f"\n{white}{fork['full_name']}{reset}")
|
||||
for attr in repo_attrs:
|
||||
xprint(f"{white}├─ {repo_attr_dict[attr]}:{reset} {fork[attr]}")
|
||||
csvLogger.logRepoForks(fork, count)
|
||||
else:
|
||||
xprint(response.json())
|
||||
except KeyboardInterrupt:
|
||||
logging.warning(ctrl_c)
|
||||
xprint(f"\n{WARNING} {ctrl_c}")
|
||||
|
||||
|
||||
# Repo issues
|
||||
def repoIssues():
|
||||
xprint(f"{white}>> %{green}Repository{reset} ", end="");repo_name = input()
|
||||
xprint(f"{white}>> @{green}Owner{white} (username){reset} ", end="");username = input()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("repository issues"), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/repos/{username}/{repo_name}/issues?per_page={limit}")
|
||||
if response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.repoOrUserNotFound.format(repo_name, username)}")
|
||||
elif response.json() == []:
|
||||
xprint(f"{SignVar.negative} Repository does not have open issues -> ({repo_name})")
|
||||
elif response.status_code == 200:
|
||||
for issue in response.json():
|
||||
xprint(f"\n{white}{issue['title']}{reset}")
|
||||
for attr in repo_issues_attrs:
|
||||
xprint(f"{white}├─ {repo_issues_attr_dict[attr]}:{reset} {issue[attr]}")
|
||||
xprint(issue['body'])
|
||||
csvLogger.logRepoIssues(issue, repo_name)
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
# Repo releases
|
||||
def repoReleases():
|
||||
xprint(f"{white}>> %{green}Repository{reset} ", end="");repo_name = input()
|
||||
xprint(f"{white}>> @{green}Owner{white} (username){reset} ", end="");username = input()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("repository releases"), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/repos/{username}/{repo_name}/releases?per_page={limit}")
|
||||
if response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.repoOrUserNotFound.format(repo_name, username)}")
|
||||
elif response.json() == []:
|
||||
xprint(f"{SignVar.negative} Repository does not have releases -> ({repo_name})")
|
||||
elif response.status_code == 200:
|
||||
for release in response.json():
|
||||
xprint(f"\n{white}{release['name']}{reset}")
|
||||
for attr in repo_releases_attrs:
|
||||
xprint(f"{white}├─ {repo_releases_attr_dict[attr]}:{reset} {release[attr]}")
|
||||
xprint(release['body'])
|
||||
csvLogger.logRepoReleases(release, repo_name)
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
# Fetching organization repositories
|
||||
def orgRepos():
|
||||
xprint(f"{white}>> @{green}Organization{white} (username){reset} ", end="");organization = input()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("organization repositories"), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/orgs/{organization}/repos?per_page={limit}")
|
||||
if response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.orgNotFound.format(organization)}")
|
||||
elif response.status_code == 200:
|
||||
for repository in response.json():
|
||||
xprint(f"\n{white}{repository['full_name']}{reset}")
|
||||
for attr in repo_attrs:
|
||||
xprint(f"{white}├─ {repo_attr_dict[attr]}:{reset} {repository[attr]}")
|
||||
csvLogger.logOrgRepos(repository, organization)
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
# organization events
|
||||
def orgEvents():
|
||||
xprint(f"{white}>> @{green}Organization{white} (username){reset} ", end="");organization = input()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("organization repositories"), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/orgs/{organization}/events?per_page={limit}")
|
||||
if response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.orgNotFound.format(organization)}")
|
||||
elif response.status_code == 200:
|
||||
for event in response.json():
|
||||
xprint(f"\n{white}{event['id']}{reset}")
|
||||
xprint(f"{white}├─ Type:{reset} {event['type']}\n{white}├─ Created at:{reset} {event['created_at']}")
|
||||
xprint(event['payload'])
|
||||
csvLogger.logOrgEvents(event, organization)
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
# organization member
|
||||
def orgMember():
|
||||
xprint(f"{white}>> @{green}Organization{white} (username){reset} ", end="");organization = input()
|
||||
xprint(f"{white}>> @{green}Username{reset} ", end="");username = input()
|
||||
response = requests.get(f"{endpoint}/orgs/{organization}/public_members/{username}")
|
||||
if response.status_code == 204:
|
||||
xprint(f"{SignVar.positive} User ({username}) is a public member of the organization -> ({organization})")
|
||||
else:
|
||||
xprint(f"{SignVar.negative} {response.json()['message']}")
|
||||
|
||||
|
||||
# Fetching user repositories
|
||||
def userRepos():
|
||||
xprint(f"{white}>> @{green}Username{reset} ", end="");username = input()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("repositories"), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/users/{username}/repos?per_page={limit}")
|
||||
if response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.userNotFound.format(username)}")
|
||||
elif response.status_code == 200:
|
||||
for repository in response.json():
|
||||
xprint(f"\n{white}{repository['full_name']}{reset}")
|
||||
for attr in repo_attrs:
|
||||
xprint(f"{white}├─ {repo_attr_dict[attr]}:{reset} {repository[attr]}")
|
||||
csvLogger.logUserRepos(repository, username)
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
# Fetching user's gists
|
||||
def userGists():
|
||||
xprint(f"{white}>> @{green}Username{reset} ", end="");username = input()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format('gists'), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/users/{username}/gists?per_page={limit}")
|
||||
#xprint(response.json())
|
||||
if response.json() == []:
|
||||
xprint(f"{SignVar.negative} User does not have gists.")
|
||||
elif response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.userNotFound.format(username)}")
|
||||
elif response.status_code == 200:
|
||||
for gist in response.json():
|
||||
xprint(f"\n{white}{gist['id']}{reset}")
|
||||
for attr in gists_attrs:
|
||||
xprint(f"{white}├─ {gists_attr_dict[attr]}:{reset} {gist[attr]}")
|
||||
csvLogger.logUserGists(gist)
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
|
||||
# Fetching a list of organizations that a user owns or belongs to
|
||||
def userOrgs():
|
||||
xprint(f"{white}>> @{green}Username{reset} ", end="");username = input()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("user organizations"), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/users/{username}/orgs?per_page={limit}")
|
||||
if response.json() == []:
|
||||
xprint(f"{SignVar.negative} User ({username}) does not (belong to/own) any organizations.")
|
||||
elif response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.userNotFound.format(username)}")
|
||||
elif response.status_code == 200:
|
||||
for organization in response.json():
|
||||
print(f"\n{white}{organization['login']}{reset}")
|
||||
for attr in user_orgs_attrs:
|
||||
xprint(f"{white}├─ {user_orgs_attr_dict[attr]}:{reset} {organization[attr]}")
|
||||
csvLogger.logUserOrgs(organization, username)
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
# Fetching a users events
|
||||
def userEvents():
|
||||
xprint(f"{white}>> @{green}Username{reset} ", end="");username = input()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("events"), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/users/{username}/events/public?per_page={limit}")
|
||||
if response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.userNotFound.format(username)}")
|
||||
elif response.status_code == 200:
|
||||
for event in response.json():
|
||||
xprint(f"\n{white}{event['id']}{reset}")
|
||||
xprint(f"{white}├─ Actor:{reset} {event['actor']['login']}")
|
||||
xprint(f"{white}├─ Type:{reset} {event['type']}")
|
||||
xprint(f"{white}├─ Repository:{reset} {event['repo']['name']}")
|
||||
xprint(f"{white}├─ Created at:{reset} {event['created_at']}")
|
||||
xprint(event['payload'])
|
||||
csvLogger.logUserEvents(event)
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
# Fetching a target user's subscriptions
|
||||
def userSubscriptions():
|
||||
xprint(f"{white}>> @{green}Username{reset} ", end="");username = input().lower()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("user subscriptions"), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/users/{username}/subscriptions?per_page={limit}")
|
||||
if response.json() == []:
|
||||
xprint(f"{SignVar.negative} User does not have any subscriptions.")
|
||||
elif response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.userNotFound.format(username)}")
|
||||
elif response.status_code == 200:
|
||||
for repository in response.json():
|
||||
xprint(f"\n{white}{repository['full_name']}{reset}")
|
||||
for attr in repo_attrs:
|
||||
xprint(f"{white}├─ {repo_attr_dict[attr]}:{reset} {repository[attr]}")
|
||||
csvLogger.logUserSubscriptions(repository, username)
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
# Fetching a list of users the target follows
|
||||
def userFollowing():
|
||||
xprint(f"{white}>> @{green}Username{reset} ", end="");username = input().lower()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("user' following"), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/users/{username}/following?per_page={limit}")
|
||||
if response.json() == []:
|
||||
xprint(f"{SignVar.negative} User ({username})does not follow anyone.")
|
||||
elif response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.userNotFound.format(username)}")
|
||||
elif response.status_code == 200:
|
||||
for user in response.json():
|
||||
xprint(f"\n{white}@{user['login']}{reset}")
|
||||
for attr in user_attrs:
|
||||
xprint(f"{white}├─ {user_attr_dict[attr]}:{reset} {user[attr]}")
|
||||
csvLogger.logUserFollowing(user, username)
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
# Fetching user's followera'
|
||||
def userFollowers():
|
||||
xprint(f"{white}>> @{green}Username{reset} ", end="");username = input().lower()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("user followers"),end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/users/{username}/followers?per_page={limit}")
|
||||
if response.json() == []:
|
||||
xprint(f"{SignVar.negative} User ({username})does not have followers.")
|
||||
elif response.status_code == 404:
|
||||
xprint(f"{SignVar.negative} {logRoller.userNotFound.format(username)}")
|
||||
elif response.status_code == 200:
|
||||
for follower in response.json():
|
||||
xprint(f"\n{white}@{follower['login']}{reset}")
|
||||
for attr in user_attrs:
|
||||
xprint(f"{white}├─ {user_attr_dict[attr]}:{reset} {follower[attr]}")
|
||||
csvLogger.logUserFollowers(follower, username)
|
||||
else:
|
||||
xprint(response.json())
|
||||
|
||||
|
||||
# Checking whether or not user[A] follows user[B]
|
||||
def userFollows():
|
||||
xprint(f"{white}>> @{green}user{white}(A) (username){reset} ", end="");user_a = input()
|
||||
xprint(f"{white}>> @{green}user{white}(B) (username){reset} ", end="");user_b = input()
|
||||
response = requests.get(f"{endpoint}/users/{user_a}/following/{user_b}")
|
||||
if response.status_code == 204:
|
||||
xprint(f"{SignVar.positive} @{user_a} FOLLOWS @{user_b}")
|
||||
else:
|
||||
xprint(f"{SignVar.negative} @{user_a} DOES NOT FOLLOW @{user_b}")
|
||||
|
||||
|
||||
# User search
|
||||
def userSearch():
|
||||
xprint(f"{white}>> @{green}Query{white} (eg. john){reset} ", end="");query = input()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("user search"), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/search/users?q={query}&per_page={limit}").json()
|
||||
for user in response['items']:
|
||||
xprint(f"\n{white}@{user['login']}{reset}")
|
||||
for attr in user_attrs:
|
||||
xprint(f"{white}├─ {user_attr_dict[attr]}:{reset} {user[attr]}")
|
||||
csvLogger.logUserSearch(user, query)
|
||||
|
||||
|
||||
# Repository search
|
||||
def repoSearch():
|
||||
xprint(f"{white}>> %{green}Query{white} (eg. git){reset} ", end="");query = input()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("repositor[y][ies] search"), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/search/repositories?q={query}&per_page={limit}").json()
|
||||
for repository in response['items']:
|
||||
xprint(f"\n{white}{repository['full_name']}{reset}")
|
||||
for attr in repo_attrs:
|
||||
xprint(f"{white}├─ {repo_attr_dict[attr]}:{reset} {repository[attr]}")
|
||||
csvLogger.logRepoSearch(repository, query)
|
||||
|
||||
|
||||
# Topics search
|
||||
def topicSearch():
|
||||
xprint(f"{white}>> #{green}Query{white} (eg. osint){reset} ", end="");query = input()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("topic(s) search"),end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/search/topics?q={query}&per_page={limit}").json()
|
||||
for topic in response['items']:
|
||||
xprint(f"\n{white}{topic['name']}{reset}")
|
||||
for attr in topic_attrs:
|
||||
xprint(f"{white}├─ {topic_attr_dict[attr]}:{reset} {topic[attr]}")
|
||||
csvLogger.logTopicSearch(topic, query)
|
||||
|
||||
|
||||
# Issue search
|
||||
def issueSearch():
|
||||
xprint(f"{white}>> !{green}Query{white} (eg. error){reset} ", end="");query = input()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("issue(s) search"), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/search/issues?q={query}&per_page={limit}").json()
|
||||
for issue in response['items']:
|
||||
xprint(f"\n\n{white}{issue['title']}{reset}")
|
||||
for attr in repo_issues_attrs:
|
||||
xprint(f"{white}├─ {repo_issues_attr_dict[attr]}:{reset} {issue[attr]}")
|
||||
xprint(issue['body'])
|
||||
csvLogger.logIssueSearch(issue, query)
|
||||
|
||||
|
||||
# Commits search
|
||||
def commitsSearch():
|
||||
xprint(f"{white}>> :{green}Query{white} (eg. filename:index.php){reset} ", end="");query = input()
|
||||
xprint(SignVar.prompt, logRoller.limitInput.format("commit(s) search"), end="");limit = int(input())
|
||||
response = requests.get(f"{endpoint}/search/commits?q={query}&per_page={limit}").json()
|
||||
for commit in response['items']:
|
||||
xprint(f"\n{white}{commit['commit']['tree']['sha']}{reset}")
|
||||
xprint(f"{white}├─ Author:{reset} {commit['commit']['author']['name']}")
|
||||
xprint(f"{white}├─ Username:{reset} {commit['author']['login']}")
|
||||
xprint(f"{white}├─ Email:{reset} {commit['commit']['author']['email']}")
|
||||
xprint(f"{white}├─ Commiter:{reset} {commit['commit']['committer']['name']}")
|
||||
xprint(f"{white}├─ Repository:{reset} {commit['repository']['full_name']}")
|
||||
xprint(f"{white}├─ URL:{reset} {commit['html_url']}")
|
||||
xprint(commit['commit']['message'])
|
||||
csvLogger.logCommitsSearch(commit, query)
|
||||
|
||||
|
||||
# View csv files
|
||||
def viewCsv():
|
||||
logging.info(logRoller.viewingCsv)
|
||||
csv_files = os.listdir("output")
|
||||
csv_table =Table(show_header=True, header_style=header_title)
|
||||
csv_table.add_column("CSV", style="dim", width=12)
|
||||
csv_table.add_column("Size (bytes)")
|
||||
for csv_file in csv_files:
|
||||
csv_table.add_row(str(csv_file), str(os.path.getsize("output/"+csv_file)))
|
||||
xprint(csv_table)
|
||||
|
||||
|
||||
# Read a specified csv file
|
||||
def readCsv():
|
||||
xprint(f"{white}>> {green}.csv {reset}(filename) ", end="");csv_file = input()
|
||||
with open(f"output/{csv_file}.csv", "r") as file:
|
||||
logging.info(logRoller.readingCsv.format(csv_file))
|
||||
xprint("\n"+file.read())
|
||||
|
||||
|
||||
# Delete a specified csv file
|
||||
def deleteCsv():
|
||||
xprint(f"{white}>> {green}.csv {reset}filename{reset} ", end="");csv_file = input()
|
||||
if sys.platform.lower().startswith(("win", "darwin")):
|
||||
subprocess.run(['del',f'.output\{csv_file}.csv'])
|
||||
else:
|
||||
subprocess.run(['sudo','rm',f'output/{csv_file}.csv'],shell=False)
|
||||
|
||||
logging.info(logRoller.deletedCsv.format(csv_file))
|
||||
xprint(f"{SignVar.positive} {logRoller.deletedCsv.format(csv_file)}")
|
||||
|
||||
|
||||
# View octosuite log files
|
||||
def viewLogs():
|
||||
logging.info(logRoller.viewingLogs)
|
||||
logs = os.listdir(".logs")
|
||||
logs_table =Table(show_header=True, header_style=header_title)
|
||||
logs_table.add_column("Log", style="dim", width=12)
|
||||
logs_table.add_column("Size (bytes)")
|
||||
for log in logs:
|
||||
logs_table.add_row(str(log), str(os.path.getsize(".logs/"+log)))
|
||||
xprint(logs_table)
|
||||
|
||||
|
||||
# Read a specified log file
|
||||
def readLog():
|
||||
xprint(f"{white}>> {green}.log date{reset} (eg. 2022-04-27 10:09:36AM) ", end="");log_file = input()
|
||||
with open(f".logs/{log_file}.log", "r") as log:
|
||||
logging.info(logRoller.readingLog.format(log_file))
|
||||
xprint("\n"+log.read())
|
||||
|
||||
|
||||
# Delete a specified log file
|
||||
def deleteLog():
|
||||
xprint(f"{white}>> {green}.log date{reset} (eg. 2022-04-27 10:09:36AM) ", end="");log_file = input()
|
||||
if sys.platform.lower().startswith(("win", "darwin")):
|
||||
subprocess.run(['del',f'.logs\{log_file}.log'])
|
||||
else:
|
||||
subprocess.run(['sudo','rm',f'.logs/{log_file}.log'],shell=False)
|
||||
|
||||
logging.info(logRoller.deletedLog.format(log_file))
|
||||
xprint(f"{SignVar.positive} {logRoller.deletedLog.format(log_file)}")
|
||||
|
||||
|
||||
# Downloading release tarball
|
||||
def downloadTarball():
|
||||
logging.info(logRoller.fileDownloading.format(f"octosuite.v{version_tag}.tar"))
|
||||
xprint(SignVar.info, logRoller.fileDownloading.format(f"octosuite.v{version_tag}.tar"))
|
||||
data = requests.get(f"{endpoint}/repos/rly0nheart/octosuite/tarballball/{version_tag}")
|
||||
with open(f"downloads/octosuite.v{version_tag}.tar", "wb") as file:
|
||||
file.write(data.content)
|
||||
file.close()
|
||||
|
||||
logging.info(logRoller.fileDownloaded.format(f"octosuite.v{version_tag}.tar"))
|
||||
xprint(SignVar.positive, logRoller.fileDownloaded.format(f"octosuite.v{version_tag}.tar"))
|
||||
|
||||
|
||||
# Downloading release zipball
|
||||
def downloadZipball():
|
||||
logging.info(logRoller.fileDownloading.format(f"octosuite.v{version_tag}.zip"))
|
||||
xprint(SignVar.info, logRoller.fileDownloading.format(f"octosuite.v{version_tag}.zip"))
|
||||
data = requests.get(f"{endpoint}/repos/rly0nheart/octosuite/zipball/{version_tag}")
|
||||
with open(f"downloads/octosuite.v{version_tag}.zip", "wb") as file:
|
||||
file.write(data.content)
|
||||
file.close()
|
||||
|
||||
logging.info(logRoller.fileDownloaded.format(f"octosuite.v{version_tag}.zip"))
|
||||
xprint(SignVar.positive, logRoller.fileDownloaded.format(f"octosuite.v{version_tag}.zip"))
|
||||
|
||||
|
||||
def versionCheck():
|
||||
response = requests.get(f"{endpoint}/repos/rly0nheart/octosuite/releases/latest")
|
||||
if response.json()['tag_name'] == version_tag:
|
||||
xprint(f"{SignVar.positive} Octosuite is up to date. Check again soon! :)")
|
||||
else:
|
||||
xprint(f"{SignVar.info} A new release is available (octosuite.v{response.json()['tag_name']}). Exit Octosuite and run '{green_bold}pip install --upgrade octosuite{white}' to download and install the update.")
|
||||
|
||||
|
||||
# Author info
|
||||
def author():
|
||||
xprint(f"{white}Richard Mwewa (Ritchie){reset}")
|
||||
for key,value in author_dict.items():
|
||||
xprint(f"{white}├─ {key}:{reset} {value}")
|
||||
|
||||
|
||||
# About program
|
||||
def about():
|
||||
xprint(f"""
|
||||
{white_bold}OCTOSUITE © 2022 Richard Mwewa{reset}
|
||||
|
||||
An advanced and lightning fast framework for gathering open-source intelligence on GitHub users and organizations.
|
||||
With over 20+ features, Octosuite only runs on 2 external dependencies, and returns the gathered intelligence in a highly readable format.
|
||||
|
||||
'_This is how you gather GitHub OSINT like a god:fire:_'
|
||||
|
||||
{white_bold}Read the wiki:{reset} https://github.com/rly0nheart/octosuite/wiki
|
||||
{white_bold}GitHub REST API documentation:{reset} https://docs.github.com/rest
|
||||
""")
|
||||
|
||||
|
||||
# Close session
|
||||
def exitSession():
|
||||
xprint(f"{SignVar.prompt} This will close the current session, continue? (Y/n) ", end="");prompt = input().lower()
|
||||
if prompt == 'y':
|
||||
logging.info(logRoller.sessionClosed.format(datetime.now()))
|
||||
xprint(f"{SignVar.info} {logRoller.sessionClosed.format(datetime.now())}")
|
||||
exit()
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
# Clear screen
|
||||
def clearScreen():
|
||||
'''
|
||||
We use 'cls' on Windows machines to clear the screen,
|
||||
otherwise, we use 'clear'
|
||||
'''
|
||||
if sys.platform.lower().startswith(("win", "darwin")):
|
||||
subprocess.run(['cls'])
|
||||
else:
|
||||
subprocess.run(['clear'], shell=False)
|
||||
|
||||
|
||||
# Show version information
|
||||
def versionInfo():
|
||||
'''
|
||||
Yes... the changelog is hard coded lol
|
||||
'''
|
||||
xprint(f"""
|
||||
{white_bold}Whats new in v{version_tag}?{reset}
|
||||
[ {green}improvement{reset} ] The Octosuite GUI (.exe/.app) is now available on GitHub
|
||||
|
||||
""")
|
||||
except Exception as e:
|
||||
logging.error(error.format(e))
|
||||
xprint(f"{ERROR} {error.format(e)}")
|
||||
|
||||
13
octosuite/message_prefixes.py
Normal file
13
octosuite/message_prefixes.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from octosuite.config import red, white, green, yellow, reset
|
||||
|
||||
"""
|
||||
message prefixes that show what
|
||||
a notification in OctoSuite might be all about. This might not be very important or necessary in some cases,
|
||||
but I think it's better to know the severity of the notifications you get in a program.
|
||||
"""
|
||||
PROMPT = f"{white}[{green}PROMPT{white}]{reset}"
|
||||
WARNING = f"{white}[{yellow}WARNING{white}]{reset}"
|
||||
ERROR = f"{white}[{red}ERROR{white}]{reset}"
|
||||
POSITIVE = f"{white}[{green}POSITIVE{white}]{reset}"
|
||||
NEGATIVE = f"{white}[{red}NEGATIVE{white}]{reset}"
|
||||
INFO = f"{white}[{green}INFO{white}]{reset}"
|
||||
1103
octosuite/octosuite.py
Normal file
1103
octosuite/octosuite.py
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,15 +0,0 @@
|
||||
from octosuite.colors import red, white, green, reset
|
||||
|
||||
'''
|
||||
SignVar
|
||||
*Even here, I couldn't think of a good name.*
|
||||
The Attributes class holds the signs/symbols that show what a notification in OctoSuite might be all about.
|
||||
This might not be very important or necessary in some cases, but I think it's better to know the severerity of the notifications you get in a program.
|
||||
'''
|
||||
class SignVar:
|
||||
prompt = f"{white}[{green} ? {white}]{reset}"
|
||||
warning = f"{white}[{red} ! {white}]{reset}"
|
||||
error = f"{white}[{red} x {white}]{reset}"
|
||||
positive = f"{white}[{green} + {white}]{reset}"
|
||||
negative = f"{white}[{red} - {white}]{reset}"
|
||||
info = f"{white}[{green} * {white}]{reset}"
|
||||
10
setup.py
10
setup.py
@@ -5,16 +5,16 @@ with open("README.md", "r", encoding="utf-8") as file:
|
||||
|
||||
setuptools.setup(
|
||||
name="octosuite",
|
||||
version="2.2.2",
|
||||
version="3.0.4",
|
||||
author="Richard Mwewa",
|
||||
author_email="richardmwewa@duck.com",
|
||||
author_email="rly0nheart@duck.com",
|
||||
packages=["octosuite"],
|
||||
description="Advanced Github OSINT Framework",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/rly0nheart/octosuite",
|
||||
url="https://github.com/bellingcat/octosuite",
|
||||
license="GNU General Public License v3 (GPLv3)",
|
||||
install_requires=["requests", "rich"],
|
||||
install_requires=["requests", "rich", "psutil", "pyreadline3"],
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
'Intended Audience :: Information Technology',
|
||||
@@ -25,7 +25,7 @@ setuptools.setup(
|
||||
],
|
||||
entry_points={
|
||||
"console_scripts": [
|
||||
"octosuite=octosuite.main:onStart",
|
||||
"octosuite=octosuite.main:octosuite",
|
||||
]
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user