diff --git a/app.py b/app.py index 9b5833a..a8a9d72 100644 --- a/app.py +++ b/app.py @@ -436,8 +436,12 @@ def api_diagnose_start(): return jsonify({'error': 'Resolved interface name contains invalid characters'}), 400 job_id = str(uuid.uuid4()) + requesting_user = _get_user()['username'] with _diag_lock: - _diag_jobs[job_id] = {'status': 'running', 'result': None, 'created_at': time.time()} + _diag_jobs[job_id] = { + 'status': 'running', 'result': None, + 'created_at': time.time(), 'user': requesting_user, + } def _run(): try: @@ -467,6 +471,8 @@ def api_diagnose_poll(job_id: str): job = _diag_jobs.get(job_id) if not job: return jsonify({'error': 'Job not found'}), 404 + if job.get('user') != _get_user()['username']: + return jsonify({'error': 'Forbidden'}), 403 return jsonify({'status': job['status'], 'result': job.get('result')}) @@ -524,7 +530,7 @@ def api_avatar(): return '', 404 if not avatar_data or len(avatar_data) < 100: - open(sentinel, 'w').close() + with open(sentinel, 'w'): pass return '', 404 # Validate JPEG magic bytes (FF D8 FF) diff --git a/templates/index.html b/templates/index.html index bc5af00..cdc7f6f 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,7 +5,7 @@