Skip to content

Commit 6cd8531

Browse files
Copilothiyouga
andcommitted
Add HTML escaping to prevent XSS attacks and update module docstring
Co-authored-by: hiyouga <16256802+hiyouga@users.noreply.github.com>
1 parent 4ead2ce commit 6cd8531

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

src_py/agenthub/monitor.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
"""
16-
Conversation monitoring module for saving and viewing conversation history.
16+
Conversation trace module for saving and viewing conversation history.
1717
1818
This module provides functionality to save conversation history to local files
1919
and serve them via a web interface for real-time monitoring.
@@ -428,7 +428,7 @@ def create_web_app(self) -> Flask:
428428
{% for key, value in config.items() %}
429429
{% if key != 'monitor_path' %}
430430
<div class="config-item">
431-
<strong>{{ key }}:</strong> {{ value }}
431+
<strong>{{ key|e }}:</strong> {{ value|e }}
432432
</div>
433433
{% endif %}
434434
{% endfor %}
@@ -447,25 +447,25 @@ def create_web_app(self) -> Flask:
447447
<div class="message-content" id="content-{{ msg_idx }}">
448448
{% for item in message.content_items %}
449449
<div class="content-item">
450-
<div class="content-type">{{ item.type }}</div>
450+
<div class="content-type">{{ item.type|e }}</div>
451451
{% if item.type == 'text' %}
452-
<div class="content-text">{{ item.text }}</div>
452+
<div class="content-text">{{ item.text|e }}</div>
453453
{% elif item.type == 'thinking' %}
454-
<div class="content-text thinking">{{ item.thinking }}</div>
454+
<div class="content-text thinking">{{ item.thinking|e }}</div>
455455
{% elif item.type == 'tool_call' %}
456456
<div class="tool-call">
457-
<strong>Tool:</strong> {{ item.name }}<br>
458-
<strong>Arguments:</strong> {{ item.argument }}<br>
459-
<strong>Call ID:</strong> {{ item.tool_call_id }}
457+
<strong>Tool:</strong> {{ item.name|e }}<br>
458+
<strong>Arguments:</strong> {{ item.argument|e }}<br>
459+
<strong>Call ID:</strong> {{ item.tool_call_id|e }}
460460
</div>
461461
{% elif item.type == 'tool_result' %}
462462
<div class="tool-result">
463-
<strong>Result:</strong> {{ item.result }}<br>
464-
<strong>Call ID:</strong> {{ item.tool_call_id }}
463+
<strong>Result:</strong> {{ item.result|e }}<br>
464+
<strong>Call ID:</strong> {{ item.tool_call_id|e }}
465465
</div>
466466
{% elif item.type == 'image_url' %}
467467
<div class="content-text">
468-
<strong>Image URL:</strong> {{ item.image_url }}
468+
<strong>Image URL:</strong> {{ item.image_url|e }}
469469
</div>
470470
{% endif %}
471471
</div>
@@ -570,8 +570,8 @@ def create_web_app(self) -> Flask:
570570
<div class="breadcrumb">
571571
<strong>Path:</strong> {{ breadcrumb|safe }}
572572
</div>
573-
<a href="{{ back_url }}" class="back-button">← Back to Directory</a>
574-
<div class="file-content">{{ content }}</div>
573+
<a href="{{ back_url|e }}" class="back-button">← Back to Directory</a>
574+
<div class="file-content">{{ content|e }}</div>
575575
</body>
576576
</html>
577577
"""

0 commit comments

Comments
 (0)