gitraze 0.0.2__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gitraze-0.2.0/LICENSE +21 -0
- {gitraze-0.0.2 → gitraze-0.2.0}/PKG-INFO +7 -3
- {gitraze-0.0.2 → gitraze-0.2.0}/README.md +3 -2
- gitraze-0.2.0/gitraze/cli.py +109 -0
- gitraze-0.2.0/gitraze/config.py +28 -0
- gitraze-0.2.0/gitraze/core/api_rest.py +66 -0
- gitraze-0.2.0/gitraze/modules/repo.py +32 -0
- gitraze-0.2.0/gitraze/modules/search.py +107 -0
- {gitraze-0.0.2 → gitraze-0.2.0}/gitraze/modules/user.py +1 -1
- {gitraze-0.0.2 → gitraze-0.2.0}/gitraze/utils/helpers.py +9 -1
- {gitraze-0.0.2 → gitraze-0.2.0}/gitraze.egg-info/PKG-INFO +7 -3
- {gitraze-0.0.2 → gitraze-0.2.0}/gitraze.egg-info/SOURCES.txt +1 -0
- {gitraze-0.0.2 → gitraze-0.2.0}/gitraze.egg-info/requires.txt +1 -0
- {gitraze-0.0.2 → gitraze-0.2.0}/pyproject.toml +2 -2
- gitraze-0.0.2/gitraze/cli.py +0 -80
- gitraze-0.0.2/gitraze/config.py +0 -7
- gitraze-0.0.2/gitraze/core/api_rest.py +0 -34
- gitraze-0.0.2/gitraze/modules/repo.py +0 -1
- gitraze-0.0.2/gitraze/modules/search.py +0 -1
- {gitraze-0.0.2 → gitraze-0.2.0}/gitraze/__init__.py +0 -0
- {gitraze-0.0.2 → gitraze-0.2.0}/gitraze/core/__init__.py +0 -0
- {gitraze-0.0.2 → gitraze-0.2.0}/gitraze/core/api_graphql.py +0 -0
- {gitraze-0.0.2 → gitraze-0.2.0}/gitraze/modules/__init__.py +0 -0
- {gitraze-0.0.2 → gitraze-0.2.0}/gitraze/modules/analytics.py +0 -0
- {gitraze-0.0.2 → gitraze-0.2.0}/gitraze/utils/__init__.py +0 -0
- {gitraze-0.0.2 → gitraze-0.2.0}/gitraze.egg-info/dependency_links.txt +0 -0
- {gitraze-0.0.2 → gitraze-0.2.0}/gitraze.egg-info/entry_points.txt +0 -0
- {gitraze-0.0.2 → gitraze-0.2.0}/gitraze.egg-info/top_level.txt +0 -0
- {gitraze-0.0.2 → gitraze-0.2.0}/setup.cfg +0 -0
gitraze-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AK Pandey (akpandey-dev)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitraze
|
|
3
|
-
Version: 0.0
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A CLI and Python library for GitHub reconnaissance, search, and analysis
|
|
5
5
|
Author: AK Pandey
|
|
6
6
|
License: MIT
|
|
@@ -10,8 +10,11 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Requires-Python: >=3.8
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
13
14
|
Requires-Dist: requests
|
|
14
15
|
Requires-Dist: colorama
|
|
16
|
+
Requires-Dist: re
|
|
17
|
+
Dynamic: license-file
|
|
15
18
|
|
|
16
19
|
# Gitraze
|
|
17
20
|
|
|
@@ -62,8 +65,9 @@ Example:
|
|
|
62
65
|
```bash
|
|
63
66
|
gitraze --help
|
|
64
67
|
gitraze user octocat
|
|
65
|
-
gitraze repo torvalds/linux
|
|
66
|
-
gitraze search "machine learning"
|
|
68
|
+
gitraze repo torvalds/linux
|
|
69
|
+
gitraze search "machine learning"
|
|
70
|
+
gitraze analyze github # Coming soon!
|
|
67
71
|
```
|
|
68
72
|
|
|
69
73
|
Example output:
|
|
@@ -47,8 +47,9 @@ Example:
|
|
|
47
47
|
```bash
|
|
48
48
|
gitraze --help
|
|
49
49
|
gitraze user octocat
|
|
50
|
-
gitraze repo torvalds/linux
|
|
51
|
-
gitraze search "machine learning"
|
|
50
|
+
gitraze repo torvalds/linux
|
|
51
|
+
gitraze search "machine learning"
|
|
52
|
+
gitraze analyze github # Coming soon!
|
|
52
53
|
```
|
|
53
54
|
|
|
54
55
|
Example output:
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
from gitraze.utils.helpers import pretty_print
|
|
3
|
+
from gitraze.modules.user import get_user_rest
|
|
4
|
+
from gitraze.modules.repo import get_repo_rest
|
|
5
|
+
from gitraze.modules.search import get_search_rest
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def main():
|
|
9
|
+
parser = argparse.ArgumentParser(
|
|
10
|
+
prog="gitraze",
|
|
11
|
+
description="GitRaze CLI Tool"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
# Global flag
|
|
15
|
+
parser.add_argument(
|
|
16
|
+
"--version",
|
|
17
|
+
action="version",
|
|
18
|
+
version="gitraze 0.2.0"
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
22
|
+
|
|
23
|
+
# --- USER ---
|
|
24
|
+
user_parser = subparsers.add_parser("user", help="Fetch user info (GitHub username)")
|
|
25
|
+
user_parser.add_argument("username", help="Format: username")
|
|
26
|
+
|
|
27
|
+
# --- REPO ---
|
|
28
|
+
repo_parser = subparsers.add_parser("repo", help="Fetch repo info (Repository in owner/repo format)")
|
|
29
|
+
repo_parser.add_argument("repo", help="Format: owner/repo")
|
|
30
|
+
|
|
31
|
+
# --- SEARCH ---
|
|
32
|
+
search_parser = subparsers.add_parser("search", help="Search GitHub")
|
|
33
|
+
search_parser.add_argument("category",choices=["repos", "users", "issues", "prs", "topics"],help="repos | users | issues | prs | topics")
|
|
34
|
+
search_parser.add_argument("query", nargs="+", help="Search category (repos, users, issues, topics)")
|
|
35
|
+
search_parser.add_argument("-n", "--limit", type=int, default=1, help="Number of results to show")
|
|
36
|
+
|
|
37
|
+
# --- ANALYZE ---
|
|
38
|
+
analyze_parser = subparsers.add_parser("analyze", help="Analyze target")
|
|
39
|
+
analyze_parser.add_argument("target", nargs="+")
|
|
40
|
+
|
|
41
|
+
args = parser.parse_args()
|
|
42
|
+
|
|
43
|
+
# --- ROUTING ---
|
|
44
|
+
if args.command == "user":
|
|
45
|
+
handle_user(args)
|
|
46
|
+
elif args.command == "repo":
|
|
47
|
+
handle_repo(args)
|
|
48
|
+
elif args.command == "search":
|
|
49
|
+
handle_search(args)
|
|
50
|
+
elif args.command == "analyze":
|
|
51
|
+
handle_analysis(args)
|
|
52
|
+
else:
|
|
53
|
+
parser.print_help()
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# --- HANDLERS ---
|
|
57
|
+
|
|
58
|
+
def handle_user(args):
|
|
59
|
+
print("[+] Fetching user data...")
|
|
60
|
+
data = get_user_rest(args.username)
|
|
61
|
+
|
|
62
|
+
if "error" in data:
|
|
63
|
+
print(data["error"])
|
|
64
|
+
return
|
|
65
|
+
|
|
66
|
+
print("[✓] Done")
|
|
67
|
+
pretty_print(data, title=f"User: {args.username}")
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def handle_repo(args):
|
|
71
|
+
print("[+] Fetching repository data...")
|
|
72
|
+
parts = args.repo.split("/")
|
|
73
|
+
|
|
74
|
+
if len(parts) != 2:
|
|
75
|
+
print("Invalid format. Use: owner/repo")
|
|
76
|
+
return
|
|
77
|
+
owner, repo = parts
|
|
78
|
+
data = get_repo_rest(owner, repo)
|
|
79
|
+
|
|
80
|
+
if "error" in data:
|
|
81
|
+
print(data["error"])
|
|
82
|
+
return
|
|
83
|
+
|
|
84
|
+
print("[✓] Done")
|
|
85
|
+
pretty_print(data, title=f"User: {owner}, Repository: {repo}")
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def handle_search(args):
|
|
89
|
+
category = args.category
|
|
90
|
+
query = " ".join(args.query)
|
|
91
|
+
print(f"[+] Searching {category} for '{query}'...")
|
|
92
|
+
|
|
93
|
+
data = get_search_rest(args.category, args.query, args.limit)
|
|
94
|
+
if "error" in data:
|
|
95
|
+
print(data["error"])
|
|
96
|
+
return
|
|
97
|
+
|
|
98
|
+
print("[✓] Done")
|
|
99
|
+
if isinstance(data, list):
|
|
100
|
+
for i, item in enumerate(data, 1):
|
|
101
|
+
pretty_print(item, title=f"{category} [{i}] -> {query}")
|
|
102
|
+
else:
|
|
103
|
+
pretty_print(data, title=f"Search: {category} -> {query}")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def handle_analysis(args):
|
|
107
|
+
target = " ".join(args.target)
|
|
108
|
+
print(f"[ANALYZE] Analyzing '{target}'")
|
|
109
|
+
print("Not implemented yet")
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# config.py
|
|
2
|
+
|
|
3
|
+
'''=============REST=============='''
|
|
4
|
+
|
|
5
|
+
# --- BASE CONFIGS ---
|
|
6
|
+
REST_BASE_URL = "https://api.github.com"
|
|
7
|
+
GRAPHQL_URL = "https://api.github.com/graphql"
|
|
8
|
+
DEFAULT_TIMEOUT = 10
|
|
9
|
+
DEFAULT_HEADERS = {
|
|
10
|
+
"Accept": "application/vnd.github+json"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
# --- USER CONFIG ---
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# --- REPO CONFIG ---
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# --- SEARCH CONFIG ---
|
|
20
|
+
SEARCH_MAP = {
|
|
21
|
+
"repos": "repositories",
|
|
22
|
+
"users": "users",
|
|
23
|
+
"issues": "issues",
|
|
24
|
+
"topics": "topics",
|
|
25
|
+
"prs": "issues"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# api_rest.py
|
|
2
|
+
import requests
|
|
3
|
+
from gitraze.config import REST_BASE_URL, DEFAULT_HEADERS, DEFAULT_TIMEOUT
|
|
4
|
+
from gitraze.config import SEARCH_MAP
|
|
5
|
+
|
|
6
|
+
def get_user(username):
|
|
7
|
+
url = f"{REST_BASE_URL}/users/{username}"
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
response = requests.get(
|
|
11
|
+
url,
|
|
12
|
+
headers=DEFAULT_HEADERS,
|
|
13
|
+
timeout=DEFAULT_TIMEOUT
|
|
14
|
+
)
|
|
15
|
+
response.raise_for_status()
|
|
16
|
+
return response.json()
|
|
17
|
+
|
|
18
|
+
except requests.exceptions.Timeout:
|
|
19
|
+
return {"error": "Request timed out. Check your connection."}
|
|
20
|
+
|
|
21
|
+
except requests.exceptions.RequestException as e:
|
|
22
|
+
return {"error": f"Request failed: {str(e)}"}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def get_repo(owner, repo):
|
|
26
|
+
url = f"{REST_BASE_URL}/repos/{owner}/{repo}"
|
|
27
|
+
try:
|
|
28
|
+
response = requests.get(
|
|
29
|
+
url,
|
|
30
|
+
headers=DEFAULT_HEADERS,
|
|
31
|
+
timeout=DEFAULT_TIMEOUT
|
|
32
|
+
)
|
|
33
|
+
response.raise_for_status()
|
|
34
|
+
return response.json()
|
|
35
|
+
|
|
36
|
+
except requests.exceptions.Timeout:
|
|
37
|
+
return {"error": "Request timed out. Check your connection."}
|
|
38
|
+
|
|
39
|
+
except requests.exceptions.RequestException as e:
|
|
40
|
+
return {"error": f"Request failed: {str(e)}"}
|
|
41
|
+
|
|
42
|
+
def get_search(category, query):
|
|
43
|
+
url = f"{REST_BASE_URL}/search/{SEARCH_MAP.get(category)}"
|
|
44
|
+
if category == "issues":
|
|
45
|
+
query = query + " type:issue"
|
|
46
|
+
elif category == "prs":
|
|
47
|
+
query += " type:pr"
|
|
48
|
+
|
|
49
|
+
params = {
|
|
50
|
+
"q": query
|
|
51
|
+
}
|
|
52
|
+
try:
|
|
53
|
+
response = requests.get(
|
|
54
|
+
url,
|
|
55
|
+
headers=DEFAULT_HEADERS,
|
|
56
|
+
params=params,
|
|
57
|
+
timeout=DEFAULT_TIMEOUT
|
|
58
|
+
)
|
|
59
|
+
response.raise_for_status()
|
|
60
|
+
return response.json()
|
|
61
|
+
|
|
62
|
+
except requests.exceptions.Timeout:
|
|
63
|
+
return {"error": "Request timed out. Check your connection."}
|
|
64
|
+
|
|
65
|
+
except requests.exceptions.RequestException as e:
|
|
66
|
+
return {"error": f"Request failed: {str(e)}"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# repo.py
|
|
2
|
+
from gitraze.utils.helpers import format_date
|
|
3
|
+
from gitraze.core.api_rest import get_repo as rest_get_repo
|
|
4
|
+
|
|
5
|
+
def get_repo_rest(owner, repo):
|
|
6
|
+
data = rest_get_repo(owner, repo)
|
|
7
|
+
|
|
8
|
+
if "error" in data:
|
|
9
|
+
return data
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
"name": data.get("name"),
|
|
13
|
+
"full_name": data.get("full_name"),
|
|
14
|
+
"owner": data.get("owner", {}).get("login"),
|
|
15
|
+
"description": data.get("description"),
|
|
16
|
+
"private": data.get("private"),
|
|
17
|
+
"fork": data.get("fork"),
|
|
18
|
+
"language": data.get("language"),
|
|
19
|
+
"topics": data.get("topics"),
|
|
20
|
+
"stars": data.get("stargazers_count"),
|
|
21
|
+
"forks": data.get("forks_count"),
|
|
22
|
+
"watchers": data.get("watchers_count"),
|
|
23
|
+
"open_issues": data.get("open_issues_count"),
|
|
24
|
+
"size": data.get("size"),
|
|
25
|
+
"default_branch": data.get("default_branch"),
|
|
26
|
+
"repo_url": data.get("html_url"),
|
|
27
|
+
"clone_url": data.get("clone_url"),
|
|
28
|
+
"created_at": format_date(data.get("created_at")),
|
|
29
|
+
"updated_at": format_date(data.get("updated_at")),
|
|
30
|
+
"pushed_at": format_date(data.get("pushed_at")),
|
|
31
|
+
"license": data.get("license", {}).get("name") if data.get("license") else None,
|
|
32
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# search.py
|
|
2
|
+
from gitraze.utils.helpers import format_date
|
|
3
|
+
from gitraze.utils.helpers import clean_html
|
|
4
|
+
from gitraze.core.api_rest import get_search
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def get_search_rest(category, query, limit=1):
|
|
8
|
+
data = get_search(category, query)
|
|
9
|
+
if "error" in data:
|
|
10
|
+
return data
|
|
11
|
+
items = data.get("items", [])
|
|
12
|
+
|
|
13
|
+
if category == "issues":
|
|
14
|
+
items = [i for i in items if "pull_request" not in i]
|
|
15
|
+
elif category == "prs":
|
|
16
|
+
items = [i for i in items if "pull_request" in i]
|
|
17
|
+
|
|
18
|
+
if category not in ["repos", "users", "issues", "prs", "topics"]:
|
|
19
|
+
return {"error": "Invalid category"}
|
|
20
|
+
if not items:
|
|
21
|
+
return {"error": "No results found"}
|
|
22
|
+
items = items[:limit]
|
|
23
|
+
results = []
|
|
24
|
+
|
|
25
|
+
for item in items:
|
|
26
|
+
match(category):
|
|
27
|
+
case "repos":
|
|
28
|
+
results.append({
|
|
29
|
+
"full_name": item.get("full_name"),
|
|
30
|
+
"html_url": item.get("html_url"),
|
|
31
|
+
"description": clean_html(item.get("description")),
|
|
32
|
+
"stargazers_count": item.get("stargazers_count"),
|
|
33
|
+
"watchers_count": item.get("watchers_count"),
|
|
34
|
+
"forks_count": item.get("forks_count"),
|
|
35
|
+
"open_issues_count": item.get("open_issues_count"),
|
|
36
|
+
"archived": item.get("archived"),
|
|
37
|
+
"disabled": item.get("disabled"),
|
|
38
|
+
"updated_at": format_date(item.get("updated_at")),
|
|
39
|
+
"pushed_at": format_date(item.get("pushed_at")),
|
|
40
|
+
"language": item.get("language"),
|
|
41
|
+
"visibility": item.get("visibility"),
|
|
42
|
+
"default_branch": item.get("default_branch"),
|
|
43
|
+
"owner": item.get("owner", {}).get("login"),
|
|
44
|
+
"For More, use": "$ gitraze repo <owner/repo>"
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
case "users":
|
|
48
|
+
results.append({
|
|
49
|
+
"login": item.get("login"),
|
|
50
|
+
"html_url": item.get("html_url"),
|
|
51
|
+
"type": item.get("type"),
|
|
52
|
+
"score": item.get("score"),
|
|
53
|
+
"site_admin": item.get("site_admin"),
|
|
54
|
+
"repos_url": item.get("repos_url"),
|
|
55
|
+
"followers_url": item.get("followers_url"),
|
|
56
|
+
"following_url": item.get("following_url"),
|
|
57
|
+
"organizations_url": item.get("organizations_url"),
|
|
58
|
+
"For More, use": "$ gitraze user <username>"
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
case "issues":
|
|
62
|
+
results.append({
|
|
63
|
+
"title": item.get("title"),
|
|
64
|
+
"html_url": item.get("html_url"),
|
|
65
|
+
"state": item.get("state"),
|
|
66
|
+
"number": item.get("number"),
|
|
67
|
+
"comments": item.get("comments"),
|
|
68
|
+
"created_at": format_date(item.get("created_at")),
|
|
69
|
+
"updated_at": format_date(item.get("updated_at")),
|
|
70
|
+
"closed_at": format_date(item.get("closed_at")),
|
|
71
|
+
"user": item.get("user", {}).get("login"),
|
|
72
|
+
"repository_url": item.get("repository_url"),
|
|
73
|
+
"labels": [label.get("name") for label in item.get("labels", [])]
|
|
74
|
+
})
|
|
75
|
+
case "prs":
|
|
76
|
+
results.append({
|
|
77
|
+
"title": item.get("title"),
|
|
78
|
+
"html_url": item.get("html_url"),
|
|
79
|
+
"state": item.get("state"),
|
|
80
|
+
"number": item.get("number"),
|
|
81
|
+
"comments": item.get("comments"),
|
|
82
|
+
"created_at": format_date(item.get("created_at")),
|
|
83
|
+
"updated_at": format_date(item.get("updated_at")),
|
|
84
|
+
"closed_at": format_date(item.get("closed_at")),
|
|
85
|
+
"merged_at": format_date(item.get("pull_request", {}).get("merged_at")),
|
|
86
|
+
"user": item.get("user", {}).get("login"),
|
|
87
|
+
"repository_url": item.get("repository_url"),
|
|
88
|
+
"labels": [label.get("name") for label in item.get("labels", [])],
|
|
89
|
+
"draft": item.get("draft"),
|
|
90
|
+
"pr_url": item.get("pull_request", {}).get("html_url")
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
case "topics":
|
|
94
|
+
results.append({
|
|
95
|
+
"name": item.get("name"),
|
|
96
|
+
"display_name": item.get("display_name"),
|
|
97
|
+
"short_description": clean_html(item.get("short_description")),
|
|
98
|
+
"description": clean_html(item.get("description")),
|
|
99
|
+
"score": item.get("score"),
|
|
100
|
+
"created_by": item.get("created_by"),
|
|
101
|
+
"released": item.get("released"),
|
|
102
|
+
"created_at": format_date(item.get("created_at")),
|
|
103
|
+
"featured": item.get("featured")
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
return results
|
|
107
|
+
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# helpers.py
|
|
2
2
|
from datetime import datetime
|
|
3
3
|
from colorama import Fore, Style, init
|
|
4
|
+
import re
|
|
4
5
|
|
|
5
6
|
init(autoreset=True)
|
|
6
7
|
|
|
@@ -32,4 +33,11 @@ def pretty_print(data, title=None):
|
|
|
32
33
|
def format_date(date_str):
|
|
33
34
|
if not date_str:
|
|
34
35
|
return None
|
|
35
|
-
|
|
36
|
+
|
|
37
|
+
try:
|
|
38
|
+
return datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%SZ").strftime("%d %b %Y")
|
|
39
|
+
except ValueError:
|
|
40
|
+
return date_str # fallback (don’t crash)
|
|
41
|
+
|
|
42
|
+
def clean_html(text):
|
|
43
|
+
return re.sub(r"<.*?>", "", text) if text else text
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitraze
|
|
3
|
-
Version: 0.0
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: A CLI and Python library for GitHub reconnaissance, search, and analysis
|
|
5
5
|
Author: AK Pandey
|
|
6
6
|
License: MIT
|
|
@@ -10,8 +10,11 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
10
10
|
Classifier: Operating System :: OS Independent
|
|
11
11
|
Requires-Python: >=3.8
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
13
14
|
Requires-Dist: requests
|
|
14
15
|
Requires-Dist: colorama
|
|
16
|
+
Requires-Dist: re
|
|
17
|
+
Dynamic: license-file
|
|
15
18
|
|
|
16
19
|
# Gitraze
|
|
17
20
|
|
|
@@ -62,8 +65,9 @@ Example:
|
|
|
62
65
|
```bash
|
|
63
66
|
gitraze --help
|
|
64
67
|
gitraze user octocat
|
|
65
|
-
gitraze repo torvalds/linux
|
|
66
|
-
gitraze search "machine learning"
|
|
68
|
+
gitraze repo torvalds/linux
|
|
69
|
+
gitraze search "machine learning"
|
|
70
|
+
gitraze analyze github # Coming soon!
|
|
67
71
|
```
|
|
68
72
|
|
|
69
73
|
Example output:
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "gitraze"
|
|
3
|
-
version = "0.0
|
|
3
|
+
version = "0.2.0"
|
|
4
4
|
description = "A CLI and Python library for GitHub reconnaissance, search, and analysis"
|
|
5
5
|
authors = [{ name = "AK Pandey" }]
|
|
6
|
-
dependencies = ["requests", "colorama"]
|
|
6
|
+
dependencies = ["requests", "colorama", "re"]
|
|
7
7
|
readme = "README.md"
|
|
8
8
|
requires-python = ">=3.8"
|
|
9
9
|
license = { text = "MIT" }
|
gitraze-0.0.2/gitraze/cli.py
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
from gitraze.utils.helpers import pretty_print
|
|
3
|
-
from gitraze.modules.user import get_user
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
def main():
|
|
7
|
-
parser = argparse.ArgumentParser(
|
|
8
|
-
prog="gitraze",
|
|
9
|
-
description="GitRaze CLI Tool"
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
# Global flag
|
|
13
|
-
parser.add_argument(
|
|
14
|
-
"--version",
|
|
15
|
-
action="version",
|
|
16
|
-
version="gitraze 0.0.2"
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
subparsers = parser.add_subparsers(dest="command", required=True)
|
|
20
|
-
|
|
21
|
-
# --- USER ---
|
|
22
|
-
user_parser = subparsers.add_parser("user", help="Fetch user info (GitHub username)")
|
|
23
|
-
user_parser.add_argument("username")
|
|
24
|
-
|
|
25
|
-
# --- REPO ---
|
|
26
|
-
repo_parser = subparsers.add_parser("repo", help="Fetch repo info (Repository in owner/repo format)")
|
|
27
|
-
repo_parser.add_argument("repo")
|
|
28
|
-
|
|
29
|
-
# --- SEARCH ---
|
|
30
|
-
search_parser = subparsers.add_parser("search", help="Search GitHub")
|
|
31
|
-
search_parser.add_argument("query", nargs="+")
|
|
32
|
-
|
|
33
|
-
# --- ANALYZE ---
|
|
34
|
-
analyze_parser = subparsers.add_parser("analyze", help="Analyze target")
|
|
35
|
-
analyze_parser.add_argument("target", nargs="+")
|
|
36
|
-
|
|
37
|
-
args = parser.parse_args()
|
|
38
|
-
|
|
39
|
-
# --- ROUTING ---
|
|
40
|
-
if args.command == "user":
|
|
41
|
-
handle_user(args)
|
|
42
|
-
elif args.command == "repo":
|
|
43
|
-
handle_repo(args)
|
|
44
|
-
elif args.command == "search":
|
|
45
|
-
handle_search(args)
|
|
46
|
-
elif args.command == "analyze":
|
|
47
|
-
handle_analysis(args)
|
|
48
|
-
else:
|
|
49
|
-
parser.print_help()
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
# --- HANDLERS ---
|
|
53
|
-
|
|
54
|
-
def handle_user(args):
|
|
55
|
-
print("[+] Fetching user data...")
|
|
56
|
-
data = get_user(args.username)
|
|
57
|
-
|
|
58
|
-
if "error" in data:
|
|
59
|
-
print(data["error"])
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
print("[✓] Done")
|
|
63
|
-
pretty_print(data, title=f"User: {args.username}")
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
def handle_repo(args):
|
|
67
|
-
print(f"[REPO] Fetching data for {args.repo}")
|
|
68
|
-
print("Not implemented yet")
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
def handle_search(args):
|
|
72
|
-
query = " ".join(args.query)
|
|
73
|
-
print(f"[SEARCH] Searching for '{query}'")
|
|
74
|
-
print("Not implemented yet")
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
def handle_analysis(args):
|
|
78
|
-
target = " ".join(args.target)
|
|
79
|
-
print(f"[ANALYZE] Analyzing '{target}'")
|
|
80
|
-
print("Not implemented yet")
|
gitraze-0.0.2/gitraze/config.py
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# api_rest.py
|
|
2
|
-
import requests
|
|
3
|
-
from gitraze.config import REST_BASE_URL, DEFAULT_HEADERS, DEFAULT_TIMEOUT
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import requests
|
|
7
|
-
|
|
8
|
-
def get_user(username):
|
|
9
|
-
url = f"{REST_BASE_URL}/users/{username}"
|
|
10
|
-
|
|
11
|
-
try:
|
|
12
|
-
response = requests.get(
|
|
13
|
-
url,
|
|
14
|
-
headers=DEFAULT_HEADERS,
|
|
15
|
-
timeout=DEFAULT_TIMEOUT
|
|
16
|
-
)
|
|
17
|
-
response.raise_for_status()
|
|
18
|
-
return response.json()
|
|
19
|
-
|
|
20
|
-
except requests.exceptions.Timeout:
|
|
21
|
-
return {"error": "Request timed out. Check your connection."}
|
|
22
|
-
|
|
23
|
-
except requests.exceptions.RequestException as e:
|
|
24
|
-
return {"error": f"Request failed: {str(e)}"}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def get_repo(owner, repo):
|
|
28
|
-
url = f"{REST_BASE_URL}/repos/{owner}/{repo}"
|
|
29
|
-
response = requests.get(url, headers=DEFAULT_HEADERS, timeout=DEFAULT_TIMEOUT)
|
|
30
|
-
|
|
31
|
-
if response.status_code != 200:
|
|
32
|
-
return {"error": f"Failed to fetch repo: {response.status_code}"}
|
|
33
|
-
|
|
34
|
-
return response.json()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# repo.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# search.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|