Skip to content

Commit 3c312da

Browse files
authored
Hide inputs from action logs
1 parent 1650994 commit 3c312da

10 files changed

Lines changed: 803 additions & 558 deletions

File tree

.github/workflows/generator-android.yml

Lines changed: 120 additions & 120 deletions
Large diffs are not rendered by default.

.github/workflows/generator-linux.yml

Lines changed: 266 additions & 130 deletions
Large diffs are not rendered by default.

.github/workflows/generator-macos.yml

Lines changed: 165 additions & 144 deletions
Large diffs are not rendered by default.

.github/workflows/generator-windows.yml

Lines changed: 125 additions & 125 deletions
Large diffs are not rendered by default.

docker-compose.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
services:
22
rdgen:
33
# use bryangerlach/rdgen:latest for the latest build
4+
#build: .
45
image: bryangerlach/rdgen:latest
56
restart: unless-stopped
67
environment:
78
SECRET_KEY: "django-insecure-!(t-!f#6g#sr%yfded9(xha)g+=!6craeez^cp+*&bz_7vdk61"
89
GHUSER: "github_username"
910
GHBEARER: "github_access_token"
1011
GENURL: "accessible_url_of_server"
12+
ZIP_PASSWORD: ""
13+
GHBRANCH: "master"
1114
PROTOCOL: "https"
1215
REPONAME: "rdgen"
1316
ports:

rdgen/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
GHUSER = os.environ.get("GHUSER", '')
2525
GHBEARER = os.environ.get("GHBEARER", '')
2626
GENURL = os.environ.get("GENURL", '')
27+
GHBRANCH = os.environ.get("GHBRANCH",'master')
28+
ZIP_PASSWORD = os.environ.get("ZIP_PASSWORD",'insecure')
2729
PROTOCOL = os.environ.get("PROTOCOL", 'https')
2830
REPONAME = os.environ.get("REPONAME", 'rdgen')
2931

rdgen/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@
3232
url(r'^startgh',views.startgh),
3333
url(r'^get_png',views.get_png),
3434
url(r'^save_custom_client',views.save_custom_client),
35+
url(r'^get_zip',views.get_zip),
3536
]

rdgenerator/views.py

Lines changed: 116 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
import base64
1010
import json
1111
import uuid
12+
import pyzipper
1213
from django.conf import settings as _settings
1314
from django.db.models import Q
1415
from .forms import GenerateForm
1516
from .models import GithubRun
1617
from PIL import Image
1718
from urllib.parse import quote
18-
from cryptography.hazmat.primitives import hashes, serialization
19-
from cryptography.hazmat.primitives.asymmetric import padding
2019

2120
def generator_view(request):
2221
if request.method == 'POST':
@@ -48,6 +47,8 @@ def generator_view(request):
4847
installation = form.cleaned_data['installation']
4948
settings = form.cleaned_data['settings']
5049
appname = form.cleaned_data['appname']
50+
if not appname:
51+
appname = "rustdesk"
5152
filename = form.cleaned_data['exename']
5253
compname = form.cleaned_data['compname']
5354
if not compname:
@@ -98,18 +99,22 @@ def generator_view(request):
9899
iconfile = form.cleaned_data.get('iconfile')
99100
if not iconfile:
100101
iconfile = form.cleaned_data.get('iconbase64')
101-
iconlink = save_png(iconfile,myuuid,full_url,"icon.png")
102+
iconlink_url, iconlink_uuid, iconlink_file = save_png(iconfile,myuuid,full_url,"icon.png")
102103
except:
103104
print("failed to get icon, using default")
104-
iconlink = "false"
105+
iconlink_url = "false"
106+
iconlink_uuid = "false"
107+
iconlink_file = "false"
105108
try:
106109
logofile = form.cleaned_data.get('logofile')
107110
if not logofile:
108111
logofile = form.cleaned_data.get('logobase64')
109-
logolink = save_png(logofile,myuuid,full_url,"logo.png")
112+
logolink_url, logolink_uuid, logolink_file = save_png(logofile,myuuid,full_url,"logo.png")
110113
except:
111114
print("failed to get logo")
112-
logolink = "false"
115+
logolink_url = "false"
116+
logolink_uuid = "false"
117+
logolink_file = "false"
113118

114119
###create the custom.txt json here and send in as inputs below
115120
decodedCustom = {}
@@ -192,21 +197,20 @@ def generator_view(request):
192197
base64_bytes = base64.b64encode(string_bytes)
193198
encodedCustom = base64_bytes.decode("ascii")
194199

195-
#github limits inputs to 10, so lump extras into one with json
196-
extras = {}
197-
extras['genurl'] = _settings.GENURL
198-
#extras['runasadmin'] = runasadmin
199-
extras['urlLink'] = urlLink
200-
extras['downloadLink'] = downloadLink
201-
extras['delayFix'] = 'true' if delayFix else 'false'
202-
extras['version'] = version
203-
extras['rdgen'] = 'true'
204-
extras['cycleMonitor'] = 'true' if cycleMonitor else 'false'
205-
extras['xOffline'] = 'true' if xOffline else 'false'
206-
extras['removeNewVersionNotif'] = 'true' if removeNewVersionNotif else 'false'
207-
extras['compname'] = compname
208-
extras['androidappid'] = androidappid
209-
extra_input = json.dumps(extras)
200+
# #github limits inputs to 10, so lump extras into one with json
201+
# extras = {}
202+
# extras['genurl'] = _settings.GENURL
203+
# #extras['runasadmin'] = runasadmin
204+
# extras['urlLink'] = urlLink
205+
# extras['downloadLink'] = downloadLink
206+
# extras['delayFix'] = 'true' if delayFix else 'false'
207+
# extras['rdgen'] = 'true'
208+
# extras['cycleMonitor'] = 'true' if cycleMonitor else 'false'
209+
# extras['xOffline'] = 'true' if xOffline else 'false'
210+
# extras['removeNewVersionNotif'] = 'true' if removeNewVersionNotif else 'false'
211+
# extras['compname'] = compname
212+
# extras['androidappid'] = androidappid
213+
# extra_input = json.dumps(extras)
210214

211215
####from here run the github action, we need user, repo, access token.
212216
if platform == 'windows':
@@ -223,19 +227,59 @@ def generator_view(request):
223227
url = 'https://api.github.com/repos/'+_settings.GHUSER+'/'+_settings.REPONAME+'/actions/workflows/generator-windows.yml/dispatches'
224228

225229
#url = 'https://api.github.com/repos/'+_settings.GHUSER+'/rustdesk/actions/workflows/test.yml/dispatches'
230+
inputs_raw = {
231+
"server":server,
232+
"key":key,
233+
"apiServer":apiServer,
234+
"custom":encodedCustom,
235+
"uuid":myuuid,
236+
"iconlink_url":iconlink_url,
237+
"iconlink_uuid":iconlink_uuid,
238+
"iconlink_file":iconlink_file,
239+
"logolink_url":logolink_url,
240+
"logolink_uuid":logolink_uuid,
241+
"logolink_file":logolink_file,
242+
"appname":appname,
243+
"genurl":_settings.GENURL,
244+
"urlLink":urlLink,
245+
"downloadLink":downloadLink,
246+
"delayFix": 'true' if delayFix else 'false',
247+
"rdgen":'true',
248+
"cycleMonitor": 'true' if cycleMonitor else 'false',
249+
"xOffline": 'true' if xOffline else 'false',
250+
"removeNewVersionNotif": 'true' if removeNewVersionNotif else 'false',
251+
"compname": compname,
252+
"androidappid":androidappid,
253+
"filename":filename
254+
}
255+
256+
temp_json_path = f"data_{uuid.uuid4()}.json"
257+
zip_filename = f"secrets_{uuid.uuid4()}.zip"
258+
zip_path = "temp_zips/%s" % (zip_filename)
259+
Path("temp_zips").mkdir(parents=True, exist_ok=True)
260+
261+
with open(temp_json_path, "w") as f:
262+
json.dump(inputs_raw, f)
263+
264+
with pyzipper.AESZipFile(zip_path, 'w', compression=pyzipper.ZIP_LZMA, encryption=pyzipper.WZ_AES) as zf:
265+
zf.setpassword(_settings.ZIP_PASSWORD.encode())
266+
zf.write(temp_json_path, arcname="secrets.json")
267+
268+
# 4. Cleanup the plain JSON file immediately
269+
if os.path.exists(temp_json_path):
270+
os.remove(temp_json_path)
271+
272+
zipJson = {}
273+
zipJson['url'] = full_url
274+
zipJson['file'] = zip_filename
275+
276+
zip_url = json.dumps(zipJson)
277+
226278
data = {
227-
"ref":"master",
279+
"ref":_settings.GHBRANCH,
228280
"inputs":{
229-
"server":server,
230-
"key":key,
231-
"apiServer":apiServer,
232-
"custom":encodedCustom,
233-
"uuid":myuuid,
234-
"iconlink":iconlink,
235-
"logolink":logolink,
236-
"appname":appname,
237-
"extras":extra_input,
238-
"filename":filename
281+
"version":version,
282+
"zip_url":zip_url
239283
}
240284
}
241285
#print(data)
@@ -357,7 +401,7 @@ def startgh(request):
357401
####from here run the github action, we need user, repo, access token.
358402
url = 'https://api.github.com/repos/'+_settings.GHUSER+'/'+_settings.REPONAME+'/actions/workflows/generator-'+data_.get('platform')+'.yml/dispatches'
359403
data = {
360-
"ref":"master",
404+
"ref": _settings.GHBRANCH,
361405
"inputs":{
362406
"server":data_.get('server'),
363407
"key":data_.get('key'),
@@ -400,12 +444,12 @@ def save_png(file, uuid, domain, name):
400444
with open(file_save_path, "wb+") as f:
401445
for chunk in file.chunks():
402446
f.write(chunk)
403-
imageJson = {}
404-
imageJson['url'] = domain
405-
imageJson['uuid'] = uuid
406-
imageJson['file'] = name
447+
# imageJson = {}
448+
# imageJson['url'] = domain
449+
# imageJson['uuid'] = uuid
450+
# imageJson['file'] = name
407451
#return "%s/%s" % (domain, file_save_path)
408-
return json.dumps(imageJson)
452+
return domain, uuid, name
409453

410454
def save_custom_client(request):
411455
file = request.FILES['file']
@@ -417,3 +461,37 @@ def save_custom_client(request):
417461
f.write(chunk)
418462

419463
return HttpResponse("File saved successfully!")
464+
465+
def cleanup_secrets(request):
466+
# Pass the UUID as a query param or in JSON body
467+
my_uuid = request.GET.get('uuid')
468+
469+
if not my_uuid:
470+
return HttpResponse("Missing UUID", status=400)
471+
472+
# 1. Find the files in your temp directory matching the UUID
473+
temp_dir = os.path.join('temp_zips')
474+
475+
# We look for any file starting with 'secrets_' and containing the uuid
476+
for filename in os.listdir(temp_dir):
477+
if my_uuid in filename and filename.endswith('.zip'):
478+
file_path = os.path.join(temp_dir, filename)
479+
try:
480+
os.remove(file_path)
481+
print(f"Successfully deleted {file_path}")
482+
except OSError as e:
483+
print(f"Error deleting file: {e}")
484+
485+
return HttpResponse("Cleanup successful", status=200)
486+
487+
def get_zip(request):
488+
filename = request.GET['filename']
489+
#filename = filename+".exe"
490+
file_path = os.path.join('temp_zips',filename)
491+
with open(file_path, 'rb') as file:
492+
response = HttpResponse(file, headers={
493+
'Content-Type': 'application/vnd.microsoft.portable-executable',
494+
'Content-Disposition': f'attachment; filename="{filename}"'
495+
})
496+
497+
return response

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ django
22
requests
33
pillow
44
gunicorn
5-
cryptography>=42.0.0
5+
pyzipper

setup.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@
2020
* Now click New repository secret
2121
* Set the Name to GENURL
2222
* Set the Secret to https://rdgen.hostname.com (or whatever your server will be accessed from)
23+
* Now click New repository secret again
24+
* Set the Name to ZIP_PASSWORD
25+
* Set the Secret to any password you want (use this in the next step as well) - generate a password by running: ```python3 -c 'import secrets; print(secrets.token_hex(100))'```
2326
4. Now download the docker-compose.yml file and fill in the environment variables:
2427
* SECRET_KEY="your secret key" - generate a secret key by running: ```python3 -c 'import secrets; print(secrets.token_hex(100))'```
2528
* GHUSER="your github username"
2629
* GHBEARER="your fine-grained access token"
30+
* ZIP_PASSWORD="the same password that you entered as a github secret"
2731
* PROTOCOL="https" *optional - defaults to "https", change to "http" if you need to
2832
* REPONAME="rdgen" *optional - defaults to "rdgen", change this if you renamed the repo when you forked it
2933
5. Now just run ```docker compose up -d```

0 commit comments

Comments
 (0)