Skip to content

Commit 9efaa30

Browse files
Fix information leakage in API error responses
Co-authored-by: alvin000009238 <107313913+alvin000009238@users.noreply.github.com>
1 parent f93682b commit 9efaa30

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

app/routes/grades.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def fetch_grades_route():
3636
return jsonify({'success': True, 'message': '成績已更新', 'data': data})
3737
except Exception as exc:
3838
logger.error(f'Error fetching grades (API): {exc}', exc_info=True)
39-
return jsonify({'success': False, 'error': str(exc)}), 500
39+
return jsonify({'success': False, 'error': '伺服器內部錯誤'}), 500
4040

4141

4242
@bp.route('/api/structure', methods=['GET'])
@@ -64,7 +64,7 @@ def get_structure_route():
6464
return jsonify({'structure': structure})
6565
except Exception as exc:
6666
logger.error(f'Error getting structure (API): {exc}', exc_info=True)
67-
return jsonify({'error': str(exc)}), 500
67+
return jsonify({'error': '伺服器內部錯誤'}), 500
6868

6969

7070

app/routes/share.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def create_share_link():
8282
return jsonify({'success': True, 'id': share_id})
8383
except Exception as exc:
8484
logger.error(f'Error creating share: {exc}', exc_info = True)
85-
return jsonify({'error': str(exc)}), 500
85+
return jsonify({'error': '伺服器內部錯誤'}), 500
8686

8787

8888
@bp.route('/api/share/<share_id>', methods=['PUT'])
@@ -147,7 +147,7 @@ def update_share_link(share_id):
147147
return jsonify({'success': True, 'id': share_id})
148148
except Exception as exc:
149149
logger.error(f'Error updating share: {exc}', exc_info=True)
150-
return jsonify({'error': str(exc)}), 500
150+
return jsonify({'error': '伺服器內部錯誤'}), 500
151151

152152

153153
@bp.route('/api/share/<share_id>', methods=['GET'])
@@ -167,7 +167,7 @@ def get_shared_grades(share_id):
167167
return jsonify({'success': True, 'data': data})
168168
except Exception as exc:
169169
logger.error(f'Error reading share: {exc}', exc_info = True)
170-
return jsonify({'error': str(exc)}), 500
170+
return jsonify({'error': '伺服器內部錯誤'}), 500
171171

172172

173173
@bp.route('/share/<share_id>')

app/routes/system.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def health_check():
5454
return jsonify({
5555
'status': 'error',
5656
'redis': 'disconnected',
57-
'detail': str(e),
57+
'detail': '伺服器內部錯誤',
5858
}), 503
5959

6060
return jsonify({'status': 'ok', 'redis': redis_status}), 200

0 commit comments

Comments
 (0)