security: never print cookie-file content; scrub credential URLs from worker-appended error log lines
This commit is contained in:
parent
6430819dac
commit
b9aeaac692
2 changed files with 6 additions and 5 deletions
6
app.py
6
app.py
|
|
@ -690,11 +690,13 @@ async def run_job(job_id, job_data):
|
|||
jobs[job_id]['logs'].append("No metadata file generated.")
|
||||
else:
|
||||
jobs[job_id]['status'] = 'failed'
|
||||
jobs[job_id]['logs'].append(f"Process failed with exit code {returncode}")
|
||||
jobs[job_id]['logs'].append(_scrub_secrets(f"Process failed with exit code {returncode}"))
|
||||
|
||||
except Exception as e:
|
||||
jobs[job_id]['status'] = 'failed'
|
||||
jobs[job_id]['logs'].append(f"Execution error: {str(e)}")
|
||||
# Exception text can embed URLs with credentials (e.g. the proxy URL
|
||||
# inside a yt-dlp/httpx error) — scrub before it reaches client logs.
|
||||
jobs[job_id]['logs'].append(_scrub_secrets(f"Execution error: {str(e)}"))
|
||||
|
||||
@app.get("/health")
|
||||
async def health():
|
||||
|
|
|
|||
5
main.py
5
main.py
|
|
@ -474,10 +474,9 @@ def download_youtube_video(url, output_dir="."):
|
|||
with open(cookies_path, 'w') as f:
|
||||
f.write(cookies_env)
|
||||
if os.path.exists(cookies_path):
|
||||
# Never print file CONTENT here: with a headerless cookies
|
||||
# blob this would leak live YouTube session cookies to logs.
|
||||
print(f" Debug: Cookies file created. Size: {os.path.getsize(cookies_path)} bytes")
|
||||
with open(cookies_path, 'r') as f:
|
||||
content = f.read(100)
|
||||
print(f" Debug: First 100 chars of cookie file: {content}")
|
||||
except Exception as e:
|
||||
print(f"⚠️ Failed to write cookies file: {e}")
|
||||
cookies_path = None
|
||||
|
|
|
|||
Loading…
Reference in a new issue