Skip to content

Commit a50e4e8

Browse files
Merge pull request #5 from devwithkrishna/alert-autofix-3
Potential fix for code scanning alert no. 3: Log Injection
2 parents 2844f1e + 1b85abb commit a50e4e8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

app/quickapi.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ async def create_item(item: UserColorEntry):
4141
user_colour.append(item)
4242
print(user_colour)
4343
# Sanitize log message to prevent log injection
44-
logger.info("New user-color entry added: username=%s, color=%s", item.username, item.color)
44+
sanitized_username = item.username.replace('\r\n', '').replace('\n', '')
45+
sanitized_color = item.color.replace('\r\n', '').replace('\n', '')
46+
logger.info("New user-color entry added: username=%s, color=%s", sanitized_username, sanitized_color)
4547
return item
4648

4749
# List all user_colour mappings

0 commit comments

Comments
 (0)