No Input Sanitization #8

Open
opened 2026-02-02 15:11:11 -05:00 by jared · 0 comments
Owner

async def ask(interaction: discord.Interaction, question: str):
# Question sent directly to Ollama without sanitization

Fix:

def sanitize_input(text: str, max_length: int = 500) -> str:
"""Sanitize user input"""
text = text.strip()[:max_length]
# Remove potentially dangerous characters
text = ''.join(char for char in text if char.isprintable())
return text

In command:

question = sanitize_input(question, max_length=500)

async def ask(interaction: discord.Interaction, question: str): # Question sent directly to Ollama without sanitization Fix: def sanitize_input(text: str, max_length: int = 500) -> str: """Sanitize user input""" text = text.strip()[:max_length] # Remove potentially dangerous characters text = ''.join(char for char in text if char.isprintable()) return text # In command: question = sanitize_input(question, max_length=500)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/discordBot#8